提交 a43b106b 编写于 作者: N NOBUGGERS

videoPlayer 基类函数 Signed-off-by: NOBUGGERS <ruanmeng@huawei.com>

Signed-off-by: NNOBUGGERS <ruanmeng@huawei.com>
上级 714752d1
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import router from '@system.router'
import media from '@ohos.multimedia.media'
import * as mediaTestBase from './MediaTestBase.js';
export async function toNewPage(pagePath1, pagePath2, page) {
let path = '';
if (page == 0) {
path = 'pages/surfaceTest/surfaceTest';
} else {
path = 'pages/surfaceTest2/surfaceTest2';
}
let options = {
uri: path,
}
try {
await router.push(options);
} catch {
console.info('case route failed');
}
}
export async function clearRouter() {
await router.clear();
}
export async function playVideoSource(url, width, height, duration, playTime) {
console.info(`case media source url: ${url}`)
let videoPlayer = null;
let surfaceID = globalThis.value;
await media.createVideoPlayer().then((video) => {
if (typeof (video) != 'undefined') {
console.info('case createVideoPlayer success');
videoPlayer = video;
} else {
console.error('case createVideoPlayer failed');
expect().assertFail();
}
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
videoPlayer.on('videoSizeChanged', (w, h) => {
console.info('case videoSizeChanged width: ' + w + ' height: ' + h);
});
videoPlayer.on('error', (err) => {
console.error(`case error called, errMessage is ${err.message}`);
expect().assertFail();
});
videoPlayer.url = url;
if (width != null & height != null) {
await videoPlayer.setDisplaySurface(surfaceID).then(() => {
console.info('case setDisplaySurface success, surfaceID: ' + surfaceID);
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
}
await videoPlayer.prepare().then(() => {
console.info('case prepare called');
expect(videoPlayer.duration).assertClose(duration, 500);
if (width != null & height != null) {
expect(videoPlayer.width).assertEqual(width);
expect(videoPlayer.height).assertEqual(height);
}
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoPlayer.getTrackDescription().then((arrayList) => {
console.info('case getTrackDescription called');
if (typeof (arrayList) != 'undefined') {
for (let i = 0; i < arrayList.length; i++) {
mediaTestBase.printDescription(arrayList[i]);
}
} else {
console.error('case getTrackDescription failed');
expect().assertFail();
}
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
let startTime = videoPlayer.currentTime;
await videoPlayer.play().then(() => {
console.info('case play called');
expect(videoPlayer.state).assertEqual('playing');
mediaTestBase.msleep(playTime);
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
let endTime = videoPlayer.currentTime;
expect(endTime - startTime).assertClose(playTime, 1000);
await videoPlayer.seek(videoPlayer.duration / 3).then((seekDoneTime) => {
console.info('case seek called and seekDoneTime is ' + seekDoneTime);
expect(videoPlayer.state).assertEqual('playing');
mediaTestBase.msleep(playTime);
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoPlayer.pause().then(() => {
console.info('case pause called');
expect(videoPlayer.state).assertEqual('paused');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
videoPlayer.loop = true;
await videoPlayer.seek(0, media.SeekMode.SEEK_NEXT_SYNC).then((seekDoneTime) => {
expect(videoPlayer.state).assertEqual('paused');
console.info('case seek called and seekDoneTime is ' + seekDoneTime);
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoPlayer.play().then(() => {
console.info('case play called');
expect(videoPlayer.state).assertEqual('playing');
mediaTestBase.msleep(playTime);
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoPlayer.setSpeed(media.PlaybackSpeed.SPEED_FORWARD_2_00_X).then((speedMode) => {
console.info('case setSpeed called and speedMode is ' + speedMode);
mediaTestBase.msleep(playTime);
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoPlayer.setVolume(0.5).then(() => {
console.info('case setVolume called');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoPlayer.seek(duration, media.SeekMode.SEEK_NEXT_SYNC).then((seekDoneTime) => {
console.info('case seek called and seekDoneTime is ' + seekDoneTime);
mediaTestBase.msleep(duration - seekDoneTime);
expect(videoPlayer.state).assertEqual('playing');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
videoPlayer.loop = false;
await videoPlayer.seek(duration, media.SeekMode.SEEK_NEXT_SYNC).then((seekDoneTime) => {
console.info('case seek called and seekDoneTime is ' + seekDoneTime);
mediaTestBase.msleep(duration - seekDoneTime);
expect(videoPlayer.state).assertEqual('stopped');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoPlayer.play().then(() => {
console.info('case play called');
expect(videoPlayer.state).assertEqual('playing');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoPlayer.stop().then(() => {
console.info('case stop called');
expect(videoPlayer.state).assertEqual('stopped');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoPlayer.reset().then(() => {
console.info('case reset called');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
videoPlayer.url = url;
await videoPlayer.setDisplaySurface(surfaceID).then(() => {
console.info('case setDisplaySurface success, surfaceID: ' + surfaceID);
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoPlayer.prepare().then(() => {
console.info('case prepare called');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoPlayer.play().then(() => {
console.info('case play called');
expect(videoPlayer.state).assertEqual('playing');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoPlayer.pause().then(() => {
console.info('case pause called');
expect(videoPlayer.state).assertEqual('paused');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoPlayer.stop().then(() => {
console.info('case stop called');
expect(videoPlayer.state).assertEqual('stopped');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoPlayer.release().then(() => {
console.info('case release called');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
}
\ No newline at end of file
...@@ -27,76 +27,7 @@ ...@@ -27,76 +27,7 @@
"pre-push": [ "pre-push": [
], ],
"push": [ "push": [
"./resource/audio/H264_AAC.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/", "./resource/audio/H264_AAC.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/"
"./resource/audio/h264_none_audio.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/mpeg2_none_audio.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/mpeg4_none_audio.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/none_video_aac.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/none_video_mp3.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/h264_aac_720p_30r.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/h264_mp3_480p_25r.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/h264_mp3_270p_10r.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/h264_aac_320x240_30r.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/h264_mp3_480x320_30r.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/h264_aac_640x480_30r.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/h264_mp3_640x480_25r.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/h264_none_audio_640x480_30r.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/mpeg2_none_audio_640x480_30r.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/mpeg4_none_audio_640x480_30r.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/h264_none_audio.ts ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/mpeg2_none_audio.ts ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/mpeg4_none_audio.ts ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/none_video_aac.ts ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/none_video_mp3.ts ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/h264_aac_720p_30r.ts ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/h264_aac_480p_25r.ts ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/h264_aac_270p_10r.ts ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/h264_mp3_720p_30r.ts ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/h264_mp3_480p_25r.ts ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/h264_mp3_270p_10r.ts ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/mpeg2_aac_720p_30r.ts ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/mpeg2_aac_480p_25r.ts ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/mpeg2_aac_270p_10r.ts ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/mpeg2_mp3_720p_30r.ts ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/mpeg2_mp3_480p_25r.ts ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/mpeg2_mp3_270p_10r.ts ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/mpeg4_aac_720p_30r.ts ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/mpeg4_aac_480p_25r.ts ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/mpeg4_aac_270p_10r.ts ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/mpeg4_mp3_720p_30r.ts ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/mpeg4_mp3_480p_25r.ts ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/mpeg4_mp3_270p_10r.ts ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/h264_none_audio_640x480_30r.ts ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/mpeg2_none_audio_640x480_30r.ts ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/mpeg4_none_audio_640x480_30r.ts ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/h264_aac_640x480_30r.ts ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/h264_mp3_640x480_25r.ts ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/mpeg2_aac_640x480_30r.ts ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/mpeg2_mp3_640x480_25r.ts ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/mpeg4_aac_640x480_30r.ts ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/mpeg4_mp3_640x480_25r.ts ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/vp8_none_audio.webm ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/none_video_vorbis.webm ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/vp8_vorbis_720p_30r.webm ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/vp8_vorbis_480p_25r.webm ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/vp8_vorbis_270p_10r.webm ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/vp8_none_audio_640x480_30r.webm ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/vp8_vorbis_640x480_25r.webm ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/h264_none_audio.mkv ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/mpeg2_none_audio.mkv ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/mpeg4_none_audio.mkv ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/none_video_aac.mkv ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/none_video_mp3.mkv ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/mpeg4_aac_720p_30r.mkv ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/mpeg4_aac_480p_25r.mkv ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/mpeg4_aac_270p_10r.mkv ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/h264_none_audio_640x480_30r.mkv ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/h263_none_audio_640x480_30r.mkv ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/mpeg2_none_audio_640x480_30r.mkv ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/mpeg4_none_audio_640x480_30r.mkv ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/h263_aac_640x480_30r.mkv ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/mpeg4_aac_640x480_30r.mkv ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/",
"./resource/audio/mpeg4_aac_270p_25r.mkv ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/"
] ]
} }
] ]
......
...@@ -17,4 +17,3 @@ require('./VideoPlayerFuncCallbackTest.test.js') ...@@ -17,4 +17,3 @@ require('./VideoPlayerFuncCallbackTest.test.js')
require('./VideoPlayerFuncPromiseTest.test.js') require('./VideoPlayerFuncPromiseTest.test.js')
require('./VideoPlayerAPICallbackTest.test.js') require('./VideoPlayerAPICallbackTest.test.js')
require('./VideoPlayerEnumTest.test.js') require('./VideoPlayerEnumTest.test.js')
require('./VideoPlayerFormatCompatibilityTest.test.js')
\ No newline at end of file
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
*/ */
import media from '@ohos.multimedia.media' import media from '@ohos.multimedia.media'
import {toNewPage, clearRouter} from './VideoPlayerTestBase.js'; import {toNewPage, clearRouter} from '../../../../../VideoPlayerTestBase.js';
import * as mediaTestBase from '../../../../../MediaTestBase.js'; import * as mediaTestBase from '../../../../../MediaTestBase.js';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
...@@ -49,7 +49,9 @@ describe('VideoPlayerAPICallbackTest', function () { ...@@ -49,7 +49,9 @@ describe('VideoPlayerAPICallbackTest', function () {
const DELTA_TIME = 100; const DELTA_TIME = 100;
let surfaceID = ''; let surfaceID = '';
let fileDescriptor = undefined; let fileDescriptor = undefined;
let page = 0; const pagePath1 = 'pages/surfaceTest/surfaceTest';
const pagePath2 = 'pages/surfaceTest2/surfaceTest2';
let pageId = 0;
let fdHead = 'fd://'; let fdHead = 'fd://';
let events = require('events'); let events = require('events');
let eventEmitter = new events.EventEmitter(); let eventEmitter = new events.EventEmitter();
...@@ -62,8 +64,8 @@ describe('VideoPlayerAPICallbackTest', function () { ...@@ -62,8 +64,8 @@ describe('VideoPlayerAPICallbackTest', function () {
await mediaTestBase.getFileDescriptor(VIDEO_SOURCE).then((res) => { await mediaTestBase.getFileDescriptor(VIDEO_SOURCE).then((res) => {
fileDescriptor = res; fileDescriptor = res;
}); });
await toNewPage(page); await toNewPage(pagePath1, pagePath2, pageId);
page = (page + 1) % 2; pageId = (pageId + 1) % 2;
await mediaTestBase.msleepAsync(1000).then( await mediaTestBase.msleepAsync(1000).then(
() => {}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); () => {}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
surfaceID = globalThis.value; surfaceID = globalThis.value;
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
*/ */
import media from '@ohos.multimedia.media' import media from '@ohos.multimedia.media'
import {toNewPage, clearRouter} from './VideoPlayerTestBase.js'; import {toNewPage, clearRouter} from '../../../../../VideoPlayerTestBase.js';
import * as mediaTestBase from '../../../../../MediaTestBase.js'; import * as mediaTestBase from '../../../../../MediaTestBase.js';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
...@@ -52,7 +52,9 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -52,7 +52,9 @@ describe('VideoPlayerFuncCallbackTest', function () {
let surfaceID = ''; let surfaceID = '';
let fdHead = 'fd://'; let fdHead = 'fd://';
let fileDescriptor = undefined; let fileDescriptor = undefined;
let page = 0; const pagePath1 = 'pages/surfaceTest/surfaceTest';
const pagePath2 = 'pages/surfaceTest2/surfaceTest2';
let pageId = 0;
let events = require('events'); let events = require('events');
let eventEmitter = new events.EventEmitter(); let eventEmitter = new events.EventEmitter();
...@@ -64,8 +66,8 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -64,8 +66,8 @@ describe('VideoPlayerFuncCallbackTest', function () {
}) })
beforeEach(async function() { beforeEach(async function() {
await toNewPage(page); await toNewPage(pagePath1, pagePath2, pageId);
page = (page + 1) % 2; pageId = (pageId + 1) % 2;
await mediaTestBase.msleepAsync(1000).then( await mediaTestBase.msleepAsync(1000).then(
() => {}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); () => {}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
surfaceID = globalThis.value; surfaceID = globalThis.value;
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
*/ */
import media from '@ohos.multimedia.media' import media from '@ohos.multimedia.media'
import {toNewPage, clearRouter} from './VideoPlayerTestBase.js'; import {toNewPage, clearRouter} from '../../../../../VideoPlayerTestBase.js';
import * as mediaTestBase from '../../../../../MediaTestBase.js'; import * as mediaTestBase from '../../../../../MediaTestBase.js';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
...@@ -32,7 +32,9 @@ describe('VideoPlayerFuncPromiseTest', function () { ...@@ -32,7 +32,9 @@ describe('VideoPlayerFuncPromiseTest', function () {
let surfaceID = ''; let surfaceID = '';
let fdHead = 'fd://'; let fdHead = 'fd://';
let fileDescriptor = undefined; let fileDescriptor = undefined;
let page = 0; const pagePath1 = 'pages/surfaceTest/surfaceTest';
const pagePath2 = 'pages/surfaceTest2/surfaceTest2';
let pageId = 0;
beforeAll(async function() { beforeAll(async function() {
console.info('beforeAll case'); console.info('beforeAll case');
...@@ -42,8 +44,8 @@ describe('VideoPlayerFuncPromiseTest', function () { ...@@ -42,8 +44,8 @@ describe('VideoPlayerFuncPromiseTest', function () {
}) })
beforeEach(async function() { beforeEach(async function() {
await toNewPage(page); await toNewPage(pagePath1, pagePath2, pageId);
page = (page + 1) % 2; pageId = (pageId + 1) % 2;
await mediaTestBase.msleepAsync(1000).then( await mediaTestBase.msleepAsync(1000).then(
() => {}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); () => {}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
surfaceID = globalThis.value; surfaceID = globalThis.value;
......
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import router from '@system.router'
export async function toNewPage(page) {
let path = '';
if (page == 0) {
path = 'pages/surfaceTest/surfaceTest';
} else {
path = 'pages/surfaceTest2/surfaceTest2';
}
let options = {
uri: path,
}
try {
await router.push(options);
} catch {
console.info('case route failed');
}
}
export async function clearRouter() {
await router.clear();
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册