From b3fd227085a3e0c8b11106f3d3a7b4eb74261ae5 Mon Sep 17 00:00:00 2001 From: NOBUGGERS Date: Fri, 8 Apr 2022 09:58:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=AC=E5=85=B1=E6=93=8D=E4=BD=9C=E6=8F=90?= =?UTF-8?q?=E5=8F=96=EF=BC=8C=E7=94=A8=E4=BE=8B=E6=89=A7=E8=A1=8C=E5=89=8D?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=96=87=E4=BB=B6=E8=AF=BB=E5=8F=96=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E6=88=90=E5=8A=9F=E7=9A=84=E5=88=A4=E6=96=AD=20=20Sig?= =?UTF-8?q?ned-off-by:=20NOBUGGERS=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: NOBUGGERS --- ...layerLocalTestBase.js => MediaTestBase.js} | 12 +- .../media_js_standard/audioPlayer/Test.json | 50 +-- .../js/test/PlayerLocalTestAudioAPI.test.js | 106 +++-- .../js/test/PlayerLocalTestAudioFUNC.test.js | 145 ++++--- .../test/PlayerLocalTestAudioFormat.test.js | 80 ++-- .../media_js_standard/videoPlayer/Test.json | 4 +- .../videoPlayer/src/main/js/test/List.test.js | 1 + .../test/VideoPlayerAPICallbackTest.test.js | 402 ++++++------------ .../test/VideoPlayerFuncCallbackTest.test.js | 115 ++--- .../test/VideoPlayerFuncPromiseTest.test.js | 207 ++++----- .../src/main/js/test/VideoPlayerTestBase.js | 37 +- 11 files changed, 478 insertions(+), 681 deletions(-) rename multimedia/media/media_js_standard/{audioPlayer/src/main/js/test/PlayerLocalTestBase.js => MediaTestBase.js} (83%) diff --git a/multimedia/media/media_js_standard/audioPlayer/src/main/js/test/PlayerLocalTestBase.js b/multimedia/media/media_js_standard/MediaTestBase.js similarity index 83% rename from multimedia/media/media_js_standard/audioPlayer/src/main/js/test/PlayerLocalTestBase.js rename to multimedia/media/media_js_standard/MediaTestBase.js index f23198e99..e88aebb95 100644 --- a/multimedia/media/media_js_standard/audioPlayer/src/main/js/test/PlayerLocalTestBase.js +++ b/multimedia/media/media_js_standard/MediaTestBase.js @@ -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 diff --git a/multimedia/media/media_js_standard/audioPlayer/Test.json b/multimedia/media/media_js_standard/audioPlayer/Test.json index 70ad4293d..1a7e3fe2d 100644 --- a/multimedia/media/media_js_standard/audioPlayer/Test.json +++ b/multimedia/media/media_js_standard/audioPlayer/Test.json @@ -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/" ] } ] diff --git a/multimedia/media/media_js_standard/audioPlayer/src/main/js/test/PlayerLocalTestAudioAPI.test.js b/multimedia/media/media_js_standard/audioPlayer/src/main/js/test/PlayerLocalTestAudioAPI.test.js index 4b041dad9..4e50c0ec0 100644 --- a/multimedia/media/media_js_standard/audioPlayer/src/main/js/test/PlayerLocalTestAudioAPI.test.js +++ b/multimedia/media/media_js_standard/audioPlayer/src/main/js/test/PlayerLocalTestAudioAPI.test.js @@ -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'); diff --git a/multimedia/media/media_js_standard/audioPlayer/src/main/js/test/PlayerLocalTestAudioFUNC.test.js b/multimedia/media/media_js_standard/audioPlayer/src/main/js/test/PlayerLocalTestAudioFUNC.test.js index b0d940d89..fdab7d1f3 100644 --- a/multimedia/media/media_js_standard/audioPlayer/src/main/js/test/PlayerLocalTestAudioFUNC.test.js +++ b/multimedia/media/media_js_standard/audioPlayer/src/main/js/test/PlayerLocalTestAudioFUNC.test.js @@ -14,15 +14,13 @@ */ import media from '@ohos.multimedia.media' -import fileIO from '@ohos.fileio' -import {getFileDescriptor, closeFileDescriptor} from './PlayerLocalTestBase.js'; +import {getFileDescriptor, closeFileDescriptor, isFileOpen} from '../../../../../MediaTestBase.js'; import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' describe('PlayerLocalTestAudioFUNC', function () { let audioPlayer = media.createAudioPlayer(); let isTimeOut = false; - const AUDIO_SOURCE = '/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/01.mp3'; - const AUDIO_FILE = '01.mp3'; + const AUDIO_SOURCE = '01.mp3'; const PLAY_TIME = 3000; const DURATION_TIME = 219600; const SEEK_TIME = 5000; @@ -44,13 +42,11 @@ describe('PlayerLocalTestAudioFUNC', function () { const RAND_NUM = 5; const TIME_OUT = 40000; const MAX_VOLUME = 1; - let fdPath; - let fdValue; - let fileDescriptor; + let fdHead = 'fd://'; + let fileDescriptor = undefined; beforeAll(async function() { - await getFd(); - await getFileDescriptor(AUDIO_FILE).then((res) => { + await getFileDescriptor(AUDIO_SOURCE).then((res) => { fileDescriptor = res; }); console.info('beforeAll case'); @@ -66,8 +62,7 @@ describe('PlayerLocalTestAudioFUNC', function () { }) afterAll(async function() { - await fileIO.close(fdValue); - await closeFileDescriptor(AUDIO_FILE); + await closeFileDescriptor(AUDIO_SOURCE); console.info('afterAll case'); }) @@ -75,19 +70,6 @@ describe('PlayerLocalTestAudioFUNC', 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(); @@ -109,7 +91,7 @@ describe('PlayerLocalTestAudioFUNC', function () { switch (mySteps[0]) { case SRC_STATE: console.info(`case to prepare`); - audioPlayer.src = fdPath; + audioPlayer.src = fdHead + fileDescriptor.fd; break; case FDSRC_STATE: console.info(`case to prepare`); @@ -272,11 +254,11 @@ describe('PlayerLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_04_0100', 0, async function (done) { - console.info(`case update`); + isFileOpen(fileDescriptor, done); let mySteps = new Array(SRC_STATE, PLAY_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdPath; + audioPlayer.src = fdHead + fileDescriptor.fd; }) /* * @@ -288,10 +270,11 @@ describe('PlayerLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_04_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; }) /* * @@ -303,10 +286,11 @@ describe('PlayerLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_04_0300', 0, async function (done) { + isFileOpen(fileDescriptor, done); let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, PLAY_STATE, RESET_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdPath; + audioPlayer.src = fdHead + fileDescriptor.fd; }) /* * @@ -318,10 +302,11 @@ describe('PlayerLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_04_0500', 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; }) /* * @@ -333,10 +318,11 @@ describe('PlayerLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_04_0600', 0, async function (done) { + isFileOpen(fileDescriptor, done); let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, PLAY_STATE, PAUSE_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdPath; + audioPlayer.src = fdHead + fileDescriptor.fd; }) /* * @@ -348,10 +334,11 @@ describe('PlayerLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_04_0700', 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; }) /* * @@ -363,10 +350,11 @@ describe('PlayerLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_04_0800', 0, async function (done) { + isFileOpen(fileDescriptor, done); let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, PLAY_STATE, STOP_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdPath; + audioPlayer.src = fdHead + fileDescriptor.fd; }) /* * @@ -378,11 +366,12 @@ describe('PlayerLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_04_0900', 0, async function (done) { + isFileOpen(fileDescriptor, 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.src = fdPath; + audioPlayer.src = fdHead + fileDescriptor.fd; }) /* * @@ -394,11 +383,12 @@ describe('PlayerLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_04_1000', 0, async function (done) { + isFileOpen(fileDescriptor, 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.src = fdPath; + audioPlayer.src = fdHead + fileDescriptor.fd; }) /* * @@ -410,11 +400,12 @@ describe('PlayerLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_04_1100', 0, async function (done) { + isFileOpen(fileDescriptor, done); let mySteps = new Array(SRC_STATE, PLAY_STATE, STOP_STATE, RESET_STATE, SRC_STATE, PLAY_STATE, RESET_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdPath; + audioPlayer.src = fdHead + fileDescriptor.fd; }) /* * @@ -426,10 +417,11 @@ describe('PlayerLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_04_1300', 0, async function (done) { + isFileOpen(fileDescriptor, done); let mySteps = new Array(SRC_STATE, PLAY_STATE, STOP_STATE, PAUSE_STATE, ERROR_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdPath; + audioPlayer.src = fdHead + fileDescriptor.fd; }) /* * @@ -441,10 +433,11 @@ describe('PlayerLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_04_1400', 0, async function (done) { + isFileOpen(fileDescriptor, done); let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, 0, PAUSE_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdPath; + audioPlayer.src = fdHead + fileDescriptor.fd; }) /* * @@ -456,11 +449,12 @@ describe('PlayerLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_04_1500', 0, async function (done) { + isFileOpen(fileDescriptor, done); let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, SEEK_STATE, DURATION_TIME, PLAY_STATE, FINISH_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdPath; + audioPlayer.src = fdHead + fileDescriptor.fd; }) /* * @@ -472,10 +466,11 @@ describe('PlayerLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_04_1600', 0, async function (done) { + isFileOpen(fileDescriptor, done); let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, PLAY_STATE, SEEK_STATE, 0, PAUSE_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdPath; + audioPlayer.src = fdHead + fileDescriptor.fd; }) /* * @@ -487,10 +482,11 @@ describe('PlayerLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_04_1700', 0, async function (done) { + isFileOpen(fileDescriptor, done); let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, 0, RESET_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdPath; + audioPlayer.src = fdHead + fileDescriptor.fd; }) /* * @@ -502,10 +498,11 @@ describe('PlayerLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_04_1800', 0, async function (done) { + isFileOpen(fileDescriptor, done); let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, 0, STOP_STATE, RESET_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdPath; + audioPlayer.src = fdHead + fileDescriptor.fd; }) /* * @@ -517,10 +514,11 @@ describe('PlayerLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_04_1900', 0, async function (done) { + isFileOpen(fileDescriptor, done); let mySteps = new Array(SRC_STATE, PLAY_STATE, STOP_STATE, SEEK_STATE, 0, ERROR_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdPath; + audioPlayer.src = fdHead + fileDescriptor.fd; }) /* * @@ -532,10 +530,11 @@ describe('PlayerLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_04_2000', 0, async function (done) { + isFileOpen(fileDescriptor, done); let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, SEEK_STATE, 0, RESET_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdPath; + audioPlayer.src = fdHead + fileDescriptor.fd; }) /* * @@ -547,11 +546,12 @@ describe('PlayerLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_04_2100', 0, async function (done) { + isFileOpen(fileDescriptor, done); let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, SEEK_STATE, DURATION_TIME / RAND_NUM, STOP_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdPath; + audioPlayer.src = fdHead + fileDescriptor.fd; }) /* * @@ -563,10 +563,11 @@ describe('PlayerLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_04_2200', 0, async function (done) { + isFileOpen(fileDescriptor, done); let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, PLAY_STATE, SEEK_STATE, 0, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdPath; + audioPlayer.src = fdHead + fileDescriptor.fd; }) /* * @@ -578,10 +579,11 @@ describe('PlayerLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_04_2300', 0, async function (done) { + isFileOpen(fileDescriptor, done); let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, PLAY_STATE, SEEK_STATE, 0, STOP_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdPath; + audioPlayer.src = fdHead + fileDescriptor.fd; }) /* * @@ -593,11 +595,12 @@ describe('PlayerLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_04_2400', 0, async function (done) { + isFileOpen(fileDescriptor, done); let mySteps = new Array(SRC_STATE, PLAY_STATE, STOP_STATE, SEEK_STATE, 0, ERROR_STATE, RESET_STATE, SRC_STATE, PLAY_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdPath; + audioPlayer.src = fdHead + fileDescriptor.fd; }) /* * @@ -609,10 +612,11 @@ describe('PlayerLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_04_2500', 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; }) /* * @@ -624,11 +628,12 @@ describe('PlayerLocalTestAudioFUNC', function () { * @tc.level : Level 3 */ it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_04_2600', 0, async function (done) { + isFileOpen(fileDescriptor, done); let mySteps = new Array(SRC_STATE, PLAY_STATE, STOP_STATE, SEEK_STATE, SEEK_TIME, ERROR_STATE, PAUSE_STATE, ERROR_STATE, RESET_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdPath; + audioPlayer.src = fdHead + fileDescriptor.fd; }) /* * @@ -640,11 +645,12 @@ describe('PlayerLocalTestAudioFUNC', function () { * @tc.level : Level 3 */ it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_04_2700', 0, async function (done) { + isFileOpen(fileDescriptor, done); let mySteps = new Array(SRC_STATE, PLAY_STATE, STOP_STATE, SEEK_STATE, SEEK_TIME, ERROR_STATE, RESET_STATE, SRC_STATE, PLAY_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdPath; + audioPlayer.src = fdHead + fileDescriptor.fd; }) /* * @@ -656,10 +662,11 @@ describe('PlayerLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_04_2800', 0, async function (done) { + isFileOpen(fileDescriptor, done); let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, DURATION_TIME, FINISH_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdPath; + audioPlayer.src = fdHead + fileDescriptor.fd; }) /* * @@ -671,11 +678,12 @@ describe('PlayerLocalTestAudioFUNC', function () { * @tc.level : Level 3 */ it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_04_2900', 0, async function (done) { + isFileOpen(fileDescriptor, done); let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, DURATION_TIME + DELTA_TIME, FINISH_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdPath; + audioPlayer.src = fdHead + fileDescriptor.fd; }) /* * @@ -687,10 +695,11 @@ describe('PlayerLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_04_3000', 0, async function (done) { + isFileOpen(fileDescriptor, done); let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, DURATION_TIME / RAND_NUM, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdPath; + audioPlayer.src = fdHead + fileDescriptor.fd; }) /* * @@ -702,10 +711,11 @@ describe('PlayerLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_04_3200', 0, async function (done) { + isFileOpen(fileDescriptor, done); let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, SEEK_STATE, 0, PLAY_STATE, RESET_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdPath; + audioPlayer.src = fdHead + fileDescriptor.fd; }) /* * @@ -717,11 +727,12 @@ describe('PlayerLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_04_3300', 0, async function (done) { + isFileOpen(fileDescriptor, done); let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, SEEK_STATE, DURATION_TIME, PLAY_STATE, FINISH_STATE, RESET_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdPath; + audioPlayer.src = fdHead + fileDescriptor.fd; }) /* * @@ -733,11 +744,12 @@ describe('PlayerLocalTestAudioFUNC', function () { * @tc.level : Level 3 */ it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_04_3400', 0, async function (done) { + isFileOpen(fileDescriptor, done); let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, SEEK_STATE, DURATION_TIME + DELTA_TIME, PLAY_STATE, FINISH_STATE, RESET_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdPath; + audioPlayer.src = fdHead + fileDescriptor.fd; }) /* * @@ -749,11 +761,12 @@ describe('PlayerLocalTestAudioFUNC', function () { * @tc.level : Level 3 */ it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_04_3500', 0, async function (done) { + isFileOpen(fileDescriptor, done); let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, DURATION_TIME + DELTA_TIME, FINISH_STATE, PLAY_STATE, RESET_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdPath; + audioPlayer.src = fdHead + fileDescriptor.fd; }) /* * @@ -765,6 +778,7 @@ describe('PlayerLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_04_3600', 0, async function (done) { + isFileOpen(fileDescriptor, done); let playCount = 0; let seekCount = 0; let isTimeDone = false; @@ -807,7 +821,7 @@ describe('PlayerLocalTestAudioFUNC', function () { testAudioPlayer.release(); isTimeDone = true; }); - testAudioPlayer.src = fdPath; + testAudioPlayer.src = fdHead + fileDescriptor.fd; setTimeout(function() { if (!isTimeDone) { expect(isTimeOut).assertTrue(); @@ -825,11 +839,13 @@ describe('PlayerLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_04_3700', 0, async function (done) { + isFileOpen(fileDescriptor, done); + let mySteps = new Array(SRC_STATE, PLAY_STATE, VOLUME_STATE, 0, VOLUME_STATE, MAX_VOLUME, RESET_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdPath; + audioPlayer.src = fdHead + fileDescriptor.fd; }) /* * @@ -841,6 +857,7 @@ describe('PlayerLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_05_0100', 0, async function (done) { + isFileOpen(fileDescriptor, done); console.info(`case update`); let mySteps = new Array(SRC_STATE, PLAY_STATE, END_STATE); initAudioPlayer(); @@ -857,6 +874,7 @@ describe('PlayerLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_05_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); @@ -872,6 +890,7 @@ describe('PlayerLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_05_0300', 0, async function (done) { + isFileOpen(fileDescriptor, done); let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, PLAY_STATE, RESET_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); @@ -887,6 +906,7 @@ describe('PlayerLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_05_0500', 0, async function (done) { + isFileOpen(fileDescriptor, done); let mySteps = new Array(SRC_STATE, PLAY_STATE, RESET_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); @@ -902,6 +922,7 @@ describe('PlayerLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_05_0600', 0, async function (done) { + isFileOpen(fileDescriptor, done); let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, PLAY_STATE, PAUSE_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); @@ -917,6 +938,7 @@ describe('PlayerLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_05_0700', 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); @@ -932,6 +954,7 @@ describe('PlayerLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_05_0800', 0, async function (done) { + isFileOpen(fileDescriptor, done); let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, PLAY_STATE, STOP_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); @@ -947,6 +970,7 @@ describe('PlayerLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_05_0900', 0, async function (done) { + isFileOpen(fileDescriptor, 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(); @@ -963,6 +987,7 @@ describe('PlayerLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_05_1000', 0, async function (done) { + isFileOpen(fileDescriptor, 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(); diff --git a/multimedia/media/media_js_standard/audioPlayer/src/main/js/test/PlayerLocalTestAudioFormat.test.js b/multimedia/media/media_js_standard/audioPlayer/src/main/js/test/PlayerLocalTestAudioFormat.test.js index 7e5c44583..c7407881e 100644 --- a/multimedia/media/media_js_standard/audioPlayer/src/main/js/test/PlayerLocalTestAudioFormat.test.js +++ b/multimedia/media/media_js_standard/audioPlayer/src/main/js/test/PlayerLocalTestAudioFormat.test.js @@ -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); }) }) diff --git a/multimedia/media/media_js_standard/videoPlayer/Test.json b/multimedia/media/media_js_standard/videoPlayer/Test.json index b7fd02d01..e318313eb 100644 --- a/multimedia/media/media_js_standard/videoPlayer/Test.json +++ b/multimedia/media/media_js_standard/videoPlayer/Test.json @@ -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": [ ], diff --git a/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/List.test.js b/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/List.test.js index cae717499..9c1b1b64b 100644 --- a/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/List.test.js +++ b/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/List.test.js @@ -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') diff --git a/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerAPICallbackTest.test.js b/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerAPICallbackTest.test.js index e47312f36..ddba14d26 100644 --- a/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerAPICallbackTest.test.js +++ b/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerAPICallbackTest.test.js @@ -14,15 +14,14 @@ */ import media from '@ohos.multimedia.media' -import router from '@system.router' -import fileIO from '@ohos.fileio' +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('VideoPlayerAPICallbackTest', 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 = 1000; const SEEK_TIME = 5000; - const SEEK_CLOSEST = 3; const WIDTH_VALUE = 720; const HEIGHT_VALUE = 480; const DURATION_TIME = 10034; @@ -46,32 +45,35 @@ describe('VideoPlayerAPICallbackTest', function () { const NEXT_FRAME_TIME = 8333; const PREV_FRAME_TIME = 4166; let surfaceID = ''; - let fdPath; - let fdValue; - let temp = 0; + let fileDescriptor = undefined; + let page = 0; + let fdHead = 'fd://'; let events = require('events'); let eventEmitter = new events.EventEmitter(); - beforeAll(function() { + beforeAll(async function() { console.info('beforeAll case'); + await getFileDescriptor(VIDEO_SOURCE).then((res) => { + fileDescriptor = res; + }); }) beforeEach(async function() { - console.info('case flush surfaceID start'); - await toNewPage(); - console.info('case flush surfaceID end'); - 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'); }) afterAll(async function() { - await fileIO.close(fdValue); + await closeFileDescriptor(VIDEO_SOURCE); console.info('afterAll case'); }) @@ -89,38 +91,6 @@ describe('VideoPlayerAPICallbackTest', function () { console.info(`case error called,errMessage is ${error.message}`); } - 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'); - }); - } - - 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 sleep(time) { for(let t = Date.now(); Date.now() - t <= time;); } @@ -169,7 +139,7 @@ describe('VideoPlayerAPICallbackTest', function () { eventEmitter.on(SETSURFACE_EVENT, (videoPlayer, steps, done) => { steps.shift(); - videoPlayer.url = fdPath; + videoPlayer.url = fdHead + fileDescriptor.fd; videoPlayer.setDisplaySurface(surfaceID, (err) => { if (typeof (err) == 'undefined') { expect(videoPlayer.state).assertEqual('idle'); @@ -186,7 +156,7 @@ describe('VideoPlayerAPICallbackTest', function () { eventEmitter.on(PREPARE_EVENT, (videoPlayer, steps, done) => { steps.shift(); - videoPlayer.url = fdPath; + videoPlayer.url = fdHead + fileDescriptor.fd; videoPlayer.prepare((err) => { if (typeof (err) == 'undefined') { expect(videoPlayer.state).assertEqual('prepared'); @@ -405,9 +375,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_PREPARE_CALLBACK_0100', 0, async function (done) { - await getFd(); - 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, RELEASE_EVENT, END_EVENT); @@ -423,8 +391,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_PREPARE_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, PREPARE_EVENT, ERROR_EVENT, RELEASE_EVENT, END_EVENT); @@ -440,8 +407,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_PREPARE_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, PREPARE_EVENT, ERROR_EVENT, RELEASE_EVENT, END_EVENT); @@ -457,8 +423,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_PREPARE_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, PREPARE_EVENT, RELEASE_EVENT, END_EVENT); @@ -474,8 +439,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_PREPARE_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, PREPARE_EVENT, RELEASE_EVENT, END_EVENT); @@ -491,8 +455,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_PREPARE_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, PREPARE_EVENT, ERROR_EVENT, RELEASE_EVENT, END_EVENT); @@ -508,8 +471,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_PREPARE_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, PREPARE_EVENT, ERROR_EVENT, RELEASE_EVENT, END_EVENT); @@ -525,8 +487,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_PREPARE_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, PREPARE_EVENT, ERROR_EVENT, RELEASE_EVENT, END_EVENT); @@ -542,8 +503,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_PREPARE_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, PREPARE_EVENT, ERROR_EVENT, RELEASE_EVENT, END_EVENT); @@ -559,8 +519,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_PREPARE_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, RELEASE_EVENT, END_EVENT); @@ -576,8 +535,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_PREPARE_CALLBACK_1100', 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, PREPARE_EVENT, RELEASE_EVENT, END_EVENT); @@ -593,8 +551,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_PREPARE_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, PREPARE_EVENT, PREPARE_EVENT, RELEASE_EVENT, END_EVENT); @@ -610,8 +567,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_PLAY_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, PLAY_EVENT, ERROR_EVENT, RELEASE_EVENT, END_EVENT); eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); @@ -626,8 +582,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_PLAY_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, RELEASE_EVENT, END_EVENT); @@ -643,8 +598,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_PLAY_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); @@ -660,8 +614,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_PLAY_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, PLAY_EVENT, ERROR_EVENT, RELEASE_EVENT, END_EVENT); @@ -677,8 +630,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_PLAY_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, PLAY_EVENT, ERROR_EVENT, RELEASE_EVENT, END_EVENT); @@ -694,8 +646,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_PLAY_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); @@ -711,8 +662,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_PLAY_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, RELEASE_EVENT, END_EVENT); @@ -728,8 +678,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_PLAY_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); @@ -745,8 +694,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_PLAY_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); @@ -762,8 +710,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_PLAY_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, PLAY_EVENT, ERROR_EVENT, RELEASE_EVENT, END_EVENT); @@ -779,8 +726,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_PLAY_CALLBACK_1100', 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, PLAY_EVENT, RELEASE_EVENT, END_EVENT); @@ -796,8 +742,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_PLAY_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, PLAY_EVENT, PLAY_EVENT, RELEASE_EVENT, END_EVENT); @@ -813,8 +758,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_PAUSE_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, PAUSE_EVENT, ERROR_EVENT, RELEASE_EVENT, END_EVENT); eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); @@ -829,8 +773,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_PAUSE_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, PAUSE_EVENT, ERROR_EVENT, RELEASE_EVENT, END_EVENT); @@ -846,8 +789,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_PAUSE_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, RELEASE_EVENT, END_EVENT); @@ -863,8 +805,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_PAUSE_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, PAUSE_EVENT, ERROR_EVENT, RELEASE_EVENT, END_EVENT); @@ -880,8 +821,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_PAUSE_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, PAUSE_EVENT, ERROR_EVENT, RELEASE_EVENT, END_EVENT); @@ -897,8 +837,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_PAUSE_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, PAUSE_EVENT, RELEASE_EVENT, END_EVENT); @@ -914,8 +853,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_PAUSE_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, PAUSE_EVENT, RELEASE_EVENT, END_EVENT); @@ -931,8 +869,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_PAUSE_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, PAUSE_EVENT, RELEASE_EVENT, END_EVENT); @@ -948,8 +885,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_PAUSE_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, PAUSE_EVENT, RELEASE_EVENT, END_EVENT); @@ -965,8 +901,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_PAUSE_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, PAUSE_EVENT, ERROR_EVENT, RELEASE_EVENT, END_EVENT); @@ -982,8 +917,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_PAUSE_CALLBACK_1100', 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, PAUSE_EVENT, ERROR_EVENT, RELEASE_EVENT, END_EVENT); @@ -999,8 +933,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_PAUSE_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, PAUSE_EVENT, PAUSE_EVENT, RELEASE_EVENT, END_EVENT); @@ -1016,8 +949,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_STOP_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, STOP_EVENT, ERROR_EVENT, RELEASE_EVENT, END_EVENT); eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); @@ -1032,8 +964,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_STOP_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, STOP_EVENT, RELEASE_EVENT, END_EVENT); @@ -1049,8 +980,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_STOP_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, STOP_EVENT, RELEASE_EVENT, END_EVENT); @@ -1066,8 +996,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_STOP_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, PAUSE_EVENT, STOP_EVENT, RELEASE_EVENT, END_EVENT); @@ -1083,8 +1012,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_STOP_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, STOP_EVENT, ERROR_EVENT, RELEASE_EVENT, END_EVENT); @@ -1100,8 +1028,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_STOP_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, STOP_EVENT, RELEASE_EVENT, END_EVENT); @@ -1117,8 +1044,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_STOP_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, STOP_EVENT, RELEASE_EVENT, END_EVENT); @@ -1134,8 +1060,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_STOP_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, STOP_EVENT, RELEASE_EVENT, END_EVENT); @@ -1151,8 +1076,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_STOP_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, STOP_EVENT, RELEASE_EVENT, END_EVENT); @@ -1168,8 +1092,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_STOP_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, STOP_EVENT, ERROR_EVENT, RELEASE_EVENT, END_EVENT); @@ -1185,8 +1108,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_STOP_CALLBACK_1100', 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, STOP_EVENT, RELEASE_EVENT, END_EVENT); @@ -1202,8 +1124,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_STOP_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, STOP_EVENT, STOP_EVENT, STOP_EVENT, RELEASE_EVENT, END_EVENT); @@ -1219,8 +1140,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_RESET_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, STOP_EVENT, ERROR_EVENT, RELEASE_EVENT, END_EVENT); eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); @@ -1235,8 +1155,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_RESET_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, RESET_EVENT, RELEASE_EVENT, END_EVENT); @@ -1252,8 +1171,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_RESET_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, RESET_EVENT, RELEASE_EVENT, END_EVENT); @@ -1269,8 +1187,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_RESET_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, PAUSE_EVENT, RESET_EVENT, RELEASE_EVENT, END_EVENT); @@ -1286,8 +1203,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_RESET_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, STOP_EVENT, RESET_EVENT, RELEASE_EVENT, END_EVENT); @@ -1303,8 +1219,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_RESET_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, RESET_EVENT, RELEASE_EVENT, END_EVENT); @@ -1320,8 +1235,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_RESET_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, RESET_EVENT, RELEASE_EVENT, END_EVENT); @@ -1337,8 +1251,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_RESET_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, RESET_EVENT, RELEASE_EVENT, END_EVENT); @@ -1354,8 +1267,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_RESET_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, RESET_EVENT, RELEASE_EVENT, END_EVENT); @@ -1371,8 +1283,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_RESET_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, RESET_EVENT, RELEASE_EVENT, END_EVENT); @@ -1388,8 +1299,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_RESET_CALLBACK_1100', 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, RESET_EVENT, RELEASE_EVENT, END_EVENT); @@ -1405,8 +1315,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_RESET_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, RESET_EVENT, RESET_EVENT, RESET_EVENT, RELEASE_EVENT, END_EVENT); @@ -1422,8 +1331,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_RELEASE_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, RELEASE_EVENT, END_EVENT); eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); @@ -1438,8 +1346,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_RELEASE_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, RELEASE_EVENT, END_EVENT); @@ -1455,8 +1362,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_RELEASE_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, RELEASE_EVENT, END_EVENT); @@ -1472,8 +1378,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_RELEASE_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, PAUSE_EVENT, RELEASE_EVENT, END_EVENT); @@ -1489,8 +1394,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_RELEASE_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, STOP_EVENT, RELEASE_EVENT, END_EVENT); @@ -1506,8 +1410,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_RELEASE_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); @@ -1523,8 +1426,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_RELEASE_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, RELEASE_EVENT, END_EVENT); @@ -1540,8 +1442,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_RELEASE_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); @@ -1557,8 +1458,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_RELEASE_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); @@ -1574,8 +1474,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_RELEASE_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, RELEASE_EVENT, END_EVENT); eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); @@ -1590,8 +1489,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_RELEASE_CALLBACK_1100', 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); @@ -1607,8 +1505,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_RELEASE_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, RESET_EVENT, RELEASE_EVENT, END_EVENT); @@ -1624,8 +1521,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_SEEK_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, SEEK_EVENT, SEEK_TIME, ERROR_EVENT, RELEASE_EVENT, END_EVENT); eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); @@ -1640,8 +1536,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_SEEK_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, SEEK_EVENT, SEEK_TIME, RELEASE_EVENT, END_EVENT); @@ -1657,8 +1552,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_SEEK_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, SEEK_EVENT, SEEK_TIME, RELEASE_EVENT, END_EVENT); @@ -1674,8 +1568,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_SEEK_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, PAUSE_EVENT, SEEK_EVENT, SEEK_TIME, RELEASE_EVENT, END_EVENT); @@ -1691,8 +1584,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_SEEK_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, STOP_EVENT, SEEK_EVENT, SEEK_TIME, ERROR_EVENT, RELEASE_EVENT, END_EVENT); @@ -1708,8 +1600,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_SEEK_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, RESET_EVENT, SEEK_EVENT, SEEK_TIME, ERROR_EVENT, RELEASE_EVENT, END_EVENT); @@ -1725,8 +1616,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_SEEK_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, SETVOLUME_EVENT, VOLUME_VALUE, SEEK_EVENT, @@ -1743,8 +1633,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_SEEK_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, SETSPEED_EVENT, SPEED_VALUE, @@ -1761,8 +1650,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_SEEK_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, SEEK_EVENT, SEEK_TIME, ERROR_EVENT, RELEASE_EVENT, END_EVENT); @@ -1778,8 +1666,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_SEEK_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, PLAY_EVENT, GETDESCRIPTION, SEEK_EVENT, SEEK_TIME, RELEASE_EVENT, END_EVENT); @@ -1795,8 +1682,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_SEEK_CALLBACK_1100', 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, SEEK_EVENT, SEEK_TIME, @@ -1813,8 +1699,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_SEEK_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, SEEK_EVENT, -1, ERROR_EVENT, RELEASE_EVENT, END_EVENT); @@ -1830,8 +1715,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_SEEK_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, SEEK_EVENT, DURATION_TIME + 1000, RELEASE_EVENT, END_EVENT); @@ -1847,8 +1731,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_SETVOLUME_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, SETVOLUME_EVENT, VOLUME_VALUE, RELEASE_EVENT, END_EVENT); eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); @@ -1863,8 +1746,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_SETVOLUME_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, SETVOLUME_EVENT, VOLUME_VALUE, RELEASE_EVENT, END_EVENT); @@ -1880,8 +1762,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_SETVOLUME_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, SETVOLUME_EVENT, VOLUME_VALUE, RELEASE_EVENT, END_EVENT); @@ -1897,8 +1778,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_SETVOLUME_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, PAUSE_EVENT, SETVOLUME_EVENT, VOLUME_VALUE, RELEASE_EVENT, END_EVENT); @@ -1914,8 +1794,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_SETVOLUME_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, STOP_EVENT, SETVOLUME_EVENT, VOLUME_VALUE, RELEASE_EVENT, END_EVENT); @@ -1931,8 +1810,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_SETVOLUME_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, RESET_EVENT, SETVOLUME_EVENT, VOLUME_VALUE, RELEASE_EVENT, END_EVENT); @@ -1948,8 +1826,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_SETVOLUME_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_EVENT, SEEK_TIME, SETVOLUME_EVENT, @@ -1966,8 +1843,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_SETVOLUME_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, SETSPEED_EVENT, SPEED_VALUE, SETVOLUME_EVENT, @@ -1984,8 +1860,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_SETVOLUME_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, SETVOLUME_EVENT, VOLUME_VALUE, END_EVENT); @@ -2001,8 +1876,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_SETVOLUME_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, PLAY_EVENT, GETDESCRIPTION, SETVOLUME_EVENT, VOLUME_VALUE, RELEASE_EVENT, END_EVENT); @@ -2018,8 +1892,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_SETVOLUME_CALLBACK_1100', 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, SETVOLUME_EVENT, VOLUME_VALUE, @@ -2036,8 +1909,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_SETVOLUME_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, SETVOLUME_EVENT, -1, ERROR_EVENT, RELEASE_EVENT, END_EVENT); @@ -2053,8 +1925,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_SETVOLUME_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, SETVOLUME_EVENT, 2, ERROR_EVENT, RELEASE_EVENT, END_EVENT); @@ -2070,8 +1941,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_SETSPEED_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, SETSPEED_EVENT, SPEED_VALUE,ERROR_EVENT, RELEASE_EVENT, END_EVENT); eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); @@ -2086,8 +1956,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_SETSPEED_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, SETSPEED_EVENT, SPEED_VALUE, RELEASE_EVENT, END_EVENT); @@ -2103,8 +1972,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_SETSPEED_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, SETSPEED_EVENT, SPEED_VALUE, RELEASE_EVENT, END_EVENT); @@ -2120,8 +1988,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_SETSPEED_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, PAUSE_EVENT, SETSPEED_EVENT, SPEED_VALUE, RELEASE_EVENT, END_EVENT); @@ -2137,8 +2004,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_SETSPEED_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, STOP_EVENT, SETSPEED_EVENT, SPEED_VALUE, @@ -2155,8 +2021,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_SETSPEED_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, RESET_EVENT, SETSPEED_EVENT, SPEED_VALUE, @@ -2173,8 +2038,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_SETSPEED_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_EVENT, SEEK_TIME, @@ -2191,8 +2055,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_SETSPEED_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, SETSPEED_EVENT, @@ -2209,8 +2072,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_SETSPEED_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, SETSPEED_EVENT, SPEED_VALUE, ERROR_EVENT, RELEASE_EVENT, END_EVENT); @@ -2226,8 +2088,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_SETSPEED_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, PLAY_EVENT, GETDESCRIPTION, SETSPEED_EVENT, SPEED_VALUE, RELEASE_EVENT, END_EVENT); @@ -2243,8 +2104,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_SETSPEED_CALLBACK_1100', 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, SETSPEED_EVENT, SPEED_VALUE, @@ -2261,8 +2121,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_SETSPEED_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, SETSPEED_EVENT, -1, ERROR_EVENT, RELEASE_EVENT, END_EVENT); @@ -2278,8 +2137,7 @@ describe('VideoPlayerAPICallbackTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_SETSPEED_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, SETSPEED_EVENT, 5, ERROR_EVENT, RELEASE_EVENT, END_EVENT); diff --git a/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerFuncCallbackTest.test.js b/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerFuncCallbackTest.test.js index 2655233f1..e74e69964 100644 --- a/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerFuncCallbackTest.test.js +++ b/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerFuncCallbackTest.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); diff --git a/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerFuncPromiseTest.test.js b/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerFuncPromiseTest.test.js index d9cee3c7b..2c27bfc3d 100644 --- a/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerFuncPromiseTest.test.js +++ b/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerFuncPromiseTest.test.js @@ -14,12 +14,12 @@ */ import media from '@ohos.multimedia.media' -import router from '@system.router' -import fileIO from '@ohos.fileio' +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('VideoPlayerFuncPromiseTest', function () { - const VIDEO_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 SEEK_TIME = 5000; const WIDTH_VALUE = 720; @@ -29,27 +29,33 @@ describe('VideoPlayerFuncPromiseTest', function () { const NEXT_FRAME_TIME = 8333; const PREV_FRAME_TIME = 4166; let surfaceID = ''; - let fdPath; - let fdValue; - let temp = 0; - beforeAll(function() { + let fdHead = 'fd://'; + let fileDescriptor = undefined; + let page = 0; + + beforeAll(async function() { console.info('beforeAll case'); + await getFileDescriptor(VIDEO_SOURCE).then((res) => { + fileDescriptor = res; + }); }) 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'); }) afterAll(async function() { - await fileIO.close(fdValue); + await closeFileDescriptor(VIDEO_SOURCE); console.info('afterAll case'); }) @@ -71,38 +77,6 @@ describe('VideoPlayerFuncPromiseTest', function () { console.info(`case error called,errMessage is ${error.message}`); } - 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'); - } - } - - async function getFd() { - fdPath = 'fd://'; - await fileIO.open(VIDEO_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 printfDescription(obj) { let description = ""; for(let i in obj) { @@ -147,9 +121,7 @@ describe('VideoPlayerFuncPromiseTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_PLAYER_MULTIPLE_0100', 0, async function (done) { - await getFd(); - surfaceID = globalThis.value; - console.info('case new surfaceID is ' + surfaceID); + isFileOpen(fileDescriptor, done); let testVideoPlayer1 = null; let testVideoPlayer2 = null; await media.createVideoPlayer().then((video) => { @@ -162,7 +134,7 @@ describe('VideoPlayerFuncPromiseTest', function () { } }, failureCallback).catch(catchCallback); - testVideoPlayer1.url = fdPath; + testVideoPlayer1.url = fdHead + fileDescriptor.fd; await testVideoPlayer1.setDisplaySurface(surfaceID).then(() => { console.info('case setDisplaySurface success'); expect(testVideoPlayer1.state).assertEqual('idle'); @@ -200,7 +172,7 @@ describe('VideoPlayerFuncPromiseTest', function () { } }, failureCallback).catch(catchCallback); - testVideoPlayer2.url = fdPath; + testVideoPlayer2.url = fdHead + fileDescriptor.fd; await testVideoPlayer2.setDisplaySurface(surfaceID).then(() => { console.info('case setDisplaySurface success'); expect(testVideoPlayer2.state).assertEqual('idle'); @@ -239,8 +211,7 @@ describe('VideoPlayerFuncPromiseTest', function () { * @tc.level : Level0 */ it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_0100', 0, async function (done) { - surfaceID = globalThis.value; - console.info('case new surfaceID is ' + surfaceID); + isFileOpen(fileDescriptor, done); let videoPlayer = null; await media.createVideoPlayer().then((video) => { if (typeof (video) != 'undefined') { @@ -253,7 +224,7 @@ describe('VideoPlayerFuncPromiseTest', function () { } }, failureCallback).catch(catchCallback); - videoPlayer.url = fdPath; + videoPlayer.url = fdHead + fileDescriptor.fd; await videoPlayer.setDisplaySurface(surfaceID).then(() => { console.info('case setDisplaySurface success'); expect(videoPlayer.state).assertEqual('idle'); @@ -291,8 +262,7 @@ describe('VideoPlayerFuncPromiseTest', function () { * @tc.level : Level0 */ it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_0200', 0, async function (done) { - surfaceID = globalThis.value; - console.info('case new surfaceID is ' + surfaceID); + isFileOpen(fileDescriptor, done); let videoPlayer = null; await media.createVideoPlayer().then((video) => { if (typeof (video) != 'undefined') { @@ -304,7 +274,7 @@ describe('VideoPlayerFuncPromiseTest', function () { } }, failureCallback).catch(catchCallback); - videoPlayer.url = fdPath; + videoPlayer.url = fdHead + fileDescriptor.fd; await videoPlayer.setDisplaySurface(surfaceID).then(() => { console.info('case setDisplaySurface success'); expect(videoPlayer.state).assertEqual('idle'); @@ -347,8 +317,7 @@ describe('VideoPlayerFuncPromiseTest', function () { * @tc.level : Level0 */ it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_0300', 0, async function (done) { - surfaceID = globalThis.value; - console.info('case new surfaceID is ' + surfaceID); + isFileOpen(fileDescriptor, done); let videoPlayer = null; await media.createVideoPlayer().then((video) => { if (typeof (video) != 'undefined') { @@ -360,7 +329,7 @@ describe('VideoPlayerFuncPromiseTest', function () { } }, failureCallback).catch(catchCallback); - videoPlayer.url = fdPath; + videoPlayer.url = fdHead + fileDescriptor.fd; await videoPlayer.setDisplaySurface(surfaceID).then(() => { expect(videoPlayer.state).assertEqual('idle'); console.info('case setDisplaySurface success'); @@ -412,8 +381,7 @@ describe('VideoPlayerFuncPromiseTest', function () { * @tc.level : Level0 */ it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_0400', 0, async function (done) { - surfaceID = globalThis.value; - console.info('case new surfaceID is ' + surfaceID); + isFileOpen(fileDescriptor, done); let videoPlayer = null; await media.createVideoPlayer().then((video) => { if (typeof (video) != 'undefined') { @@ -425,7 +393,7 @@ describe('VideoPlayerFuncPromiseTest', function () { } }, failureCallback).catch(catchCallback); - videoPlayer.url = fdPath; + videoPlayer.url = fdHead + fileDescriptor.fd; await videoPlayer.setDisplaySurface(surfaceID).then(() => { expect(videoPlayer.state).assertEqual('idle'); console.info('case setDisplaySurface success'); @@ -468,8 +436,7 @@ describe('VideoPlayerFuncPromiseTest', function () { * @tc.level : Level0 */ it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_0500', 0, async function (done) { - surfaceID = globalThis.value; - console.info('case new surfaceID is ' + surfaceID); + isFileOpen(fileDescriptor, done); let videoPlayer = null; await media.createVideoPlayer().then((video) => { if (typeof (video) != 'undefined') { @@ -481,7 +448,7 @@ describe('VideoPlayerFuncPromiseTest', function () { } }, failureCallback).catch(catchCallback); - videoPlayer.url = fdPath; + videoPlayer.url = fdHead + fileDescriptor.fd; await videoPlayer.setDisplaySurface(surfaceID).then(() => { expect(videoPlayer.state).assertEqual('idle'); console.info('case setDisplaySurface success'); @@ -524,8 +491,7 @@ describe('VideoPlayerFuncPromiseTest', function () { * @tc.level : Level0 */ it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_0600', 0, async function (done) { - surfaceID = globalThis.value; - console.info('case new surfaceID is ' + surfaceID); + isFileOpen(fileDescriptor, done); let videoPlayer = null; await media.createVideoPlayer().then((video) => { if (typeof (video) != 'undefined') { @@ -537,7 +503,7 @@ describe('VideoPlayerFuncPromiseTest', function () { } }, failureCallback).catch(catchCallback); - videoPlayer.url = fdPath; + videoPlayer.url = fdHead + fileDescriptor.fd; await videoPlayer.setDisplaySurface(surfaceID).then(() => { expect(videoPlayer.state).assertEqual('idle'); console.info('case setDisplaySurface success'); @@ -581,8 +547,7 @@ describe('VideoPlayerFuncPromiseTest', function () { * @tc.level : Level0 */ it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_0700', 0, async function (done) { - surfaceID = globalThis.value; - console.info('case new surfaceID is ' + surfaceID); + isFileOpen(fileDescriptor, done); let videoPlayer = null; await media.createVideoPlayer().then((video) => { if (typeof (video) != 'undefined') { @@ -594,7 +559,7 @@ describe('VideoPlayerFuncPromiseTest', function () { } }, failureCallback).catch(catchCallback); - videoPlayer.url = fdPath; + videoPlayer.url = fdHead + fileDescriptor.fd; await videoPlayer.setDisplaySurface(surfaceID).then(() => { expect(videoPlayer.state).assertEqual('idle'); console.info('case setDisplaySurface success'); @@ -668,8 +633,7 @@ describe('VideoPlayerFuncPromiseTest', function () { * @tc.level : Level0 */ it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_0800', 0, async function (done) { - surfaceID = globalThis.value; - console.info('case new surfaceID is ' + surfaceID); + isFileOpen(fileDescriptor, done); let videoPlayer = null; await media.createVideoPlayer().then((video) => { if (typeof (video) != 'undefined') { @@ -681,7 +645,7 @@ describe('VideoPlayerFuncPromiseTest', function () { } }, failureCallback).catch(catchCallback); - videoPlayer.url = fdPath; + videoPlayer.url = fdHead + fileDescriptor.fd; await videoPlayer.setDisplaySurface(surfaceID).then(() => { expect(videoPlayer.state).assertEqual('idle'); console.info('case setDisplaySurface success'); @@ -724,8 +688,7 @@ describe('VideoPlayerFuncPromiseTest', function () { * @tc.level : Level0 */ it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_0900', 0, async function (done) { - surfaceID = globalThis.value; - console.info('case new surfaceID is ' + surfaceID); + isFileOpen(fileDescriptor, done); let videoPlayer = null; await media.createVideoPlayer().then((video) => { if (typeof (video) != 'undefined') { @@ -737,7 +700,7 @@ describe('VideoPlayerFuncPromiseTest', function () { } }, failureCallback).catch(catchCallback); - videoPlayer.url = fdPath; + videoPlayer.url = fdHead + fileDescriptor.fd; await videoPlayer.setDisplaySurface(surfaceID).then(() => { expect(videoPlayer.state).assertEqual('idle'); console.info('case setDisplaySurface success'); @@ -785,8 +748,7 @@ describe('VideoPlayerFuncPromiseTest', function () { * @tc.level : Level1 */ it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_1000', 0, async function (done) { - surfaceID = globalThis.value; - console.info('case new surfaceID is ' + surfaceID); + isFileOpen(fileDescriptor, done); let videoPlayer = null; let arrayDescription = null; await media.createVideoPlayer().then((video) => { @@ -799,7 +761,7 @@ describe('VideoPlayerFuncPromiseTest', function () { } }, failureCallback).catch(catchCallback); - videoPlayer.url = fdPath; + videoPlayer.url = fdHead + fileDescriptor.fd; await videoPlayer.setDisplaySurface(surfaceID).then(() => { expect(videoPlayer.state).assertEqual('idle'); console.info('case setDisplaySurface success'); @@ -839,8 +801,7 @@ describe('VideoPlayerFuncPromiseTest', function () { * @tc.level : Level1 */ it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_1100', 0, async function (done) { - surfaceID = globalThis.value; - console.info('case new surfaceID is ' + surfaceID); + isFileOpen(fileDescriptor, done); let videoPlayer = null; await media.createVideoPlayer().then((video) => { if (typeof (video) != 'undefined') { @@ -852,7 +813,7 @@ describe('VideoPlayerFuncPromiseTest', function () { } }, failureCallback).catch(catchCallback); - videoPlayer.url = fdPath; + videoPlayer.url = fdHead + fileDescriptor.fd; await videoPlayer.setDisplaySurface(surfaceID).then(() => { expect(videoPlayer.state).assertEqual('idle'); console.info('case setDisplaySurface success'); @@ -898,8 +859,7 @@ describe('VideoPlayerFuncPromiseTest', function () { * @tc.level : Level1 */ it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_1200', 0, async function (done) { - surfaceID = globalThis.value; - console.info('case new surfaceID is ' + surfaceID); + isFileOpen(fileDescriptor, done); let videoPlayer = null; await media.createVideoPlayer().then((video) => { if (typeof (video) != 'undefined') { @@ -911,7 +871,7 @@ describe('VideoPlayerFuncPromiseTest', function () { } }, failureCallback).catch(catchCallback); - videoPlayer.url = fdPath; + videoPlayer.url = fdHead + fileDescriptor.fd; await videoPlayer.setDisplaySurface(surfaceID).then(() => { expect(videoPlayer.state).assertEqual('idle'); console.info('case setDisplaySurface success'); @@ -959,8 +919,7 @@ describe('VideoPlayerFuncPromiseTest', function () { * @tc.level : Level1 */ it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_1300', 0, async function (done) { - surfaceID = globalThis.value; - console.info('case new surfaceID is ' + surfaceID); + isFileOpen(fileDescriptor, done); let videoPlayer = null; await media.createVideoPlayer().then((video) => { if (typeof (video) != 'undefined') { @@ -972,7 +931,7 @@ describe('VideoPlayerFuncPromiseTest', function () { } }, failureCallback).catch(catchCallback); - videoPlayer.url = fdPath; + videoPlayer.url = fdHead + fileDescriptor.fd; await videoPlayer.setDisplaySurface(surfaceID).then(() => { expect(videoPlayer.state).assertEqual('idle'); console.info('case setDisplaySurface success'); @@ -1020,8 +979,7 @@ describe('VideoPlayerFuncPromiseTest', function () { * @tc.level : Level1 */ it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_1400', 0, async function (done) { - surfaceID = globalThis.value; - console.info('case new surfaceID is ' + surfaceID); + isFileOpen(fileDescriptor, done); let videoPlayer = null; await media.createVideoPlayer().then((video) => { if (typeof (video) != 'undefined') { @@ -1033,7 +991,7 @@ describe('VideoPlayerFuncPromiseTest', function () { } }, failureCallback).catch(catchCallback); - videoPlayer.url = fdPath; + videoPlayer.url = fdHead + fileDescriptor.fd; await videoPlayer.setDisplaySurface(surfaceID).then(() => { expect(videoPlayer.state).assertEqual('idle'); console.info('case setDisplaySurface success'); @@ -1091,8 +1049,7 @@ describe('VideoPlayerFuncPromiseTest', function () { * @tc.level : Level1 */ it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_1500', 0, async function (done) { - surfaceID = globalThis.value; - console.info('case new surfaceID is ' + surfaceID); + isFileOpen(fileDescriptor, done); let videoPlayer = null; await media.createVideoPlayer().then((video) => { if (typeof (video) != 'undefined') { @@ -1104,7 +1061,7 @@ describe('VideoPlayerFuncPromiseTest', function () { } }, failureCallback).catch(catchCallback); - videoPlayer.url = fdPath; + videoPlayer.url = fdHead + fileDescriptor.fd; await videoPlayer.setDisplaySurface(surfaceID).then(() => { expect(videoPlayer.state).assertEqual('idle'); console.info('case setDisplaySurface success'); @@ -1168,8 +1125,7 @@ describe('VideoPlayerFuncPromiseTest', function () { * @tc.level : Level1 */ it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_1600', 0, async function (done) { - surfaceID = globalThis.value; - console.info('case new surfaceID is ' + surfaceID); + isFileOpen(fileDescriptor, done); let videoPlayer = null; await media.createVideoPlayer().then((video) => { if (typeof (video) != 'undefined') { @@ -1181,7 +1137,7 @@ describe('VideoPlayerFuncPromiseTest', function () { } }, failureCallback).catch(catchCallback); - videoPlayer.url = fdPath; + videoPlayer.url = fdHead + fileDescriptor.fd; await videoPlayer.setDisplaySurface(surfaceID).then(() => { expect(videoPlayer.state).assertEqual('idle'); console.info('case setDisplaySurface success'); @@ -1238,8 +1194,7 @@ describe('VideoPlayerFuncPromiseTest', function () { * @tc.level : Level1 */ it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_1700', 0, async function (done) { - surfaceID = globalThis.value; - console.info('case new surfaceID is ' + surfaceID); + isFileOpen(fileDescriptor, done); let videoPlayer = null; await media.createVideoPlayer().then((video) => { if (typeof (video) != 'undefined') { @@ -1251,7 +1206,7 @@ describe('VideoPlayerFuncPromiseTest', function () { } }, failureCallback).catch(catchCallback); - videoPlayer.url = fdPath; + videoPlayer.url = fdHead + fileDescriptor.fd; await videoPlayer.setDisplaySurface(surfaceID).then(() => { expect(videoPlayer.state).assertEqual('idle'); console.info('case setDisplaySurface success'); @@ -1309,8 +1264,7 @@ describe('VideoPlayerFuncPromiseTest', function () { * @tc.level : Level1 */ it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_1800', 0, async function (done) { - surfaceID = globalThis.value; - console.info('case new surfaceID is ' + surfaceID); + isFileOpen(fileDescriptor, done); let videoPlayer = null; await media.createVideoPlayer().then((video) => { if (typeof (video) != 'undefined') { @@ -1322,7 +1276,7 @@ describe('VideoPlayerFuncPromiseTest', function () { } }, failureCallback).catch(catchCallback); - videoPlayer.url = fdPath; + videoPlayer.url = fdHead + fileDescriptor.fd; await videoPlayer.setDisplaySurface(surfaceID).then(() => { expect(videoPlayer.state).assertEqual('idle'); console.info('case setDisplaySurface success'); @@ -1370,8 +1324,7 @@ describe('VideoPlayerFuncPromiseTest', function () { * @tc.level : Level1 */ it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_1900', 0, async function (done) { - surfaceID = globalThis.value; - console.info('case new surfaceID is ' + surfaceID); + isFileOpen(fileDescriptor, done); let videoPlayer = null; await media.createVideoPlayer().then((video) => { if (typeof (video) != 'undefined') { @@ -1383,7 +1336,7 @@ describe('VideoPlayerFuncPromiseTest', function () { } }, failureCallback).catch(catchCallback); - videoPlayer.url = fdPath; + videoPlayer.url = fdHead + fileDescriptor.fd; await videoPlayer.setDisplaySurface(surfaceID).then(() => { expect(videoPlayer.state).assertEqual('idle'); console.info('case setDisplaySurface success'); @@ -1415,7 +1368,7 @@ describe('VideoPlayerFuncPromiseTest', function () { expect(videoPlayer.state).assertEqual('idle'); console.info('case reset called!!'); }, failureCallback).catch(catchCallback); - videoPlayer.url = fdPath; + videoPlayer.url = fdHead + fileDescriptor.fd; await videoPlayer.prepare().then(() => { expect(videoPlayer.state).assertEqual('prepared'); expect(videoPlayer.duration).assertEqual(DURATION_TIME); @@ -1448,8 +1401,7 @@ describe('VideoPlayerFuncPromiseTest', function () { * @tc.level : Level1 */ it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_2000', 0, async function (done) { - surfaceID = globalThis.value; - console.info('case new surfaceID is ' + surfaceID); + isFileOpen(fileDescriptor, done); let videoPlayer = null; await media.createVideoPlayer().then((video) => { if (typeof (video) != 'undefined') { @@ -1461,7 +1413,7 @@ describe('VideoPlayerFuncPromiseTest', function () { } }, failureCallback).catch(catchCallback); - videoPlayer.url = fdPath; + videoPlayer.url = fdHead + fileDescriptor.fd; await videoPlayer.setDisplaySurface(surfaceID).then(() => { expect(videoPlayer.state).assertEqual('idle'); console.info('case setDisplaySurface success'); @@ -1515,8 +1467,7 @@ describe('VideoPlayerFuncPromiseTest', function () { * @tc.level : Level1 */ it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_2100', 0, async function (done) { - surfaceID = globalThis.value; - console.info('case new surfaceID is ' + surfaceID); + isFileOpen(fileDescriptor, done); let videoPlayer = null; await media.createVideoPlayer().then((video) => { if (typeof (video) != 'undefined') { @@ -1528,7 +1479,7 @@ describe('VideoPlayerFuncPromiseTest', function () { } }, failureCallback).catch(catchCallback); - videoPlayer.url = fdPath; + videoPlayer.url = fdHead + fileDescriptor.fd; await videoPlayer.setDisplaySurface(surfaceID).then(() => { expect(videoPlayer.state).assertEqual('idle'); console.info('case setDisplaySurface success'); @@ -1588,8 +1539,7 @@ describe('VideoPlayerFuncPromiseTest', function () { * @tc.level : Level1 */ it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_2200', 0, async function (done) { - surfaceID = globalThis.value; - console.info('case new surfaceID is ' + surfaceID); + isFileOpen(fileDescriptor, done); let videoPlayer = null; await media.createVideoPlayer().then((video) => { if (typeof (video) != 'undefined') { @@ -1610,7 +1560,7 @@ describe('VideoPlayerFuncPromiseTest', function () { }, failureCallback).catch(catchCallback); }); - videoPlayer.url = fdPath; + videoPlayer.url = fdHead + fileDescriptor.fd; await videoPlayer.setDisplaySurface(surfaceID).then(() => { expect(videoPlayer.state).assertEqual('idle'); console.info('case setDisplaySurface success'); @@ -1654,8 +1604,7 @@ describe('VideoPlayerFuncPromiseTest', function () { * @tc.level : Level1 */ it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_2300', 0, async function (done) { - surfaceID = globalThis.value; - console.info('case new surfaceID is ' + surfaceID); + isFileOpen(fileDescriptor, done); let videoPlayer = null; await media.createVideoPlayer().then((video) => { if (typeof (video) != 'undefined') { @@ -1676,7 +1625,7 @@ describe('VideoPlayerFuncPromiseTest', function () { }, failureCallback).catch(catchCallback); }); - videoPlayer.url = fdPath; + videoPlayer.url = fdHead + fileDescriptor.fd; await videoPlayer.setDisplaySurface(surfaceID).then(() => { expect(videoPlayer.state).assertEqual('idle'); console.info('case setDisplaySurface success'); @@ -1726,8 +1675,7 @@ describe('VideoPlayerFuncPromiseTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_2400', 0, async function (done) { - surfaceID = globalThis.value; - console.info('case new surfaceID is ' + surfaceID); + isFileOpen(fileDescriptor, done); let videoPlayer = null; await media.createVideoPlayer().then((video) => { if (typeof (video) != 'undefined') { @@ -1748,7 +1696,7 @@ describe('VideoPlayerFuncPromiseTest', function () { }, failureCallback).catch(catchCallback); }); - videoPlayer.url = fdPath; + videoPlayer.url = fdHead + fileDescriptor.fd; await videoPlayer.setDisplaySurface(surfaceID).then(() => { expect(videoPlayer.state).assertEqual('idle'); console.info('case setDisplaySurface success'); @@ -1795,8 +1743,7 @@ describe('VideoPlayerFuncPromiseTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_2500', 0, async function (done) { - surfaceID = globalThis.value; - console.info('case new surfaceID is ' + surfaceID); + isFileOpen(fileDescriptor, done); let videoPlayer = null; await media.createVideoPlayer().then((video) => { if (typeof (video) != 'undefined') { @@ -1817,7 +1764,7 @@ describe('VideoPlayerFuncPromiseTest', function () { }, failureCallback).catch(catchCallback); }); - videoPlayer.url = fdPath; + videoPlayer.url = fdHead + fileDescriptor.fd; await videoPlayer.setDisplaySurface(surfaceID).then(() => { expect(videoPlayer.state).assertEqual('idle'); console.info('case setDisplaySurface success'); @@ -1862,8 +1809,7 @@ describe('VideoPlayerFuncPromiseTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_2600', 0, async function (done) { - surfaceID = globalThis.value; - console.info('case new surfaceID is ' + surfaceID); + isFileOpen(fileDescriptor, done); let videoPlayer = null; await media.createVideoPlayer().then((video) => { if (typeof (video) != 'undefined') { @@ -1875,7 +1821,7 @@ describe('VideoPlayerFuncPromiseTest', function () { } }, failureCallback).catch(catchCallback); - videoPlayer.url = fdPath; + videoPlayer.url = fdHead + fileDescriptor.fd; await videoPlayer.setDisplaySurface(surfaceID).then(() => { expect(videoPlayer.state).assertEqual('idle'); console.info('case setDisplaySurface success'); @@ -1920,8 +1866,7 @@ describe('VideoPlayerFuncPromiseTest', function () { * @tc.level : Level2 */ it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_2700', 0, async function (done) { - surfaceID = globalThis.value; - console.info('case new surfaceID is ' + surfaceID); + isFileOpen(fileDescriptor, done); let videoPlayer = null; await media.createVideoPlayer().then((video) => { if (typeof (video) != 'undefined') { @@ -1933,7 +1878,7 @@ describe('VideoPlayerFuncPromiseTest', function () { } }, failureCallback).catch(catchCallback); - videoPlayer.url = fdPath; + videoPlayer.url = fdHead + fileDescriptor.fd; await videoPlayer.setDisplaySurface(surfaceID).then(() => { expect(videoPlayer.state).assertEqual('idle'); console.info('case setDisplaySurface success'); diff --git a/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerTestBase.js b/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerTestBase.js index b2879167b..f2680a797 100644 --- a/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerTestBase.js +++ b/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerTestBase.js @@ -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(); } -- GitLab