提交 1e7497d8 编写于 作者: F fulizhong

add videoScaleType case Signed-off-by: NOBUGGERS<ruanmeng@huawei.com>

Signed-off-by: Nfulizhong <fulizhong@huawei.com>
上级 7e47a338
......@@ -71,6 +71,10 @@ export async function getFdRead(pathName, done) {
return fdReturn;
}
export async function closeFdNumber(fdNumber) {
await fileio.close(fdNumber);
}
// wait synchronously
export function msleep(time) {
for(let t = Date.now();Date.now() - t <= time;);
......@@ -159,7 +163,7 @@ export async function getFd(pathName) {
}
let fetchFileResult = await mediaTest.getFileAssets(fetchOp);
fdObject.fileAsset = await fetchFileResult.getAllObject();
fdObject.fdNumber = await fdObject.fileAsset[0].open('Rw');
fdObject.fdNumber = await fdObject.fileAsset[0].open('rw');
console.info('case getFd number is: ' + fdObject.fdNumber);
}
return fdObject;
......
......@@ -17,7 +17,7 @@
{
"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/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files"
],
"teardown-command":[
]
......@@ -27,30 +27,30 @@
"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/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/"
"./resource/audio/01.mp3 ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files/",
"./resource/audio/02.mp3 ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files/",
"./resource/audio/03.mp3 ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files/",
"./resource/audio/04.mp3 ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files/",
"./resource/audio/47.mp4 ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files/",
"./resource/audio/49.mp4 ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files/",
"./resource/audio/50.mp4 ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files/",
"./resource/audio/51.mp4 ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files/",
"./resource/audio/54.mp4 ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files/",
"./resource/audio/55.m4a ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files/",
"./resource/audio/57.m4a ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files/",
"./resource/audio/58.m4a ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files/",
"./resource/audio/59.m4a ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files/",
"./resource/audio/62.m4a ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files/",
"./resource/audio/64.mp4 ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files/",
"./resource/audio/65.mp4 ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files/",
"./resource/audio/66.mp4 ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files/",
"./resource/audio/67.mp4 ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files/",
"./resource/audio/92.mp4 ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files/",
"./resource/audio/93.mp4 ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files/",
"./resource/audio/94.mp4 ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files/",
"./resource/audio/96.mp4 ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files/",
"./resource/audio/97.mp4 ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files/",
"./resource/audio/98.mp4 ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files/"
]
}
]
......
......@@ -40,7 +40,7 @@
"label": "$string:entry_MainAbility",
"type": "page",
"homeAbility": true,
"launchType": "standard"
"launchType": "singleton"
}
],
"deviceType": [
......
......@@ -42,7 +42,8 @@ describe('PlayerLocalTestAudioAPI', function () {
const VOLUME_VALUE = 0.5;
let fdHead = 'fd://';
let fileDescriptor = undefined;
let fdPath = '';
let fdNumber = 0;
beforeAll(async function() {
console.info('beforeAll case');
})
......@@ -52,10 +53,15 @@ describe('PlayerLocalTestAudioAPI', function () {
await mediaTestBase.getFileDescriptor(AUDIO_SOURCE).then((res) => {
fileDescriptor = res;
});
await mediaTestBase.getFdRead(AUDIO_SOURCE, openFileFailed).then((testNumber) => {
fdNumber = testNumber;
fdPath = fdHead + '' + fdNumber;
})
console.info('beforeEach case');
})
afterEach(async function() {
await mediaTestBase.closeFdNumber(fdNumber);
await mediaTestBase.closeFileDescriptor(AUDIO_SOURCE);
console.info('afterEach case');
})
......@@ -64,6 +70,10 @@ describe('PlayerLocalTestAudioAPI', function () {
console.info('afterAll case');
})
function openFileFailed() {
console.info('case file fail');
}
function initAudioPlayer() {
if (typeof (audioPlayer) != 'undefined') {
audioPlayer.release();
......@@ -85,7 +95,7 @@ describe('PlayerLocalTestAudioAPI', function () {
switch (mySteps[0]) {
case SRC_STATE:
console.info(`case to prepare`);
audioPlayer.src = fdHead + fileDescriptor.fd;
audioPlayer.src = fdPath;
break;
case PLAY_STATE:
console.info(`case to play`);
......@@ -320,7 +330,7 @@ describe('PlayerLocalTestAudioAPI', function () {
let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, PLAY_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.src = fdHead + fileDescriptor.fd;
audioPlayer.src = fdPath;
})
/* *
......@@ -336,7 +346,7 @@ describe('PlayerLocalTestAudioAPI', function () {
let mySteps = new Array(SRC_STATE, PLAY_STATE, STOP_STATE, PLAY_STATE, ERROR_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.src = fdHead + fileDescriptor.fd;
audioPlayer.src = fdPath;
})
/* *
......@@ -352,7 +362,7 @@ describe('PlayerLocalTestAudioAPI', function () {
let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, SEEK_STATE, SEEK_TIME, PLAY_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.src = fdHead + fileDescriptor.fd;
audioPlayer.src = fdPath;
})
/* *
......@@ -368,7 +378,7 @@ describe('PlayerLocalTestAudioAPI', function () {
let mySteps = new Array(SRC_STATE, RESET_STATE, PLAY_STATE, ERROR_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.src = fdHead + fileDescriptor.fd;
audioPlayer.src = fdPath;
})
/* *
......@@ -400,7 +410,7 @@ describe('PlayerLocalTestAudioAPI', function () {
let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.src = fdHead + fileDescriptor.fd;
audioPlayer.src = fdPath;
})
/* *
......@@ -416,7 +426,7 @@ describe('PlayerLocalTestAudioAPI', function () {
let mySteps = new Array(PLAY_STATE, STOP_STATE, PAUSE_STATE, ERROR_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.src = fdHead + fileDescriptor.fd;
audioPlayer.src = fdPath;
})
/* *
......@@ -432,7 +442,7 @@ describe('PlayerLocalTestAudioAPI', function () {
let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, SEEK_TIME, PAUSE_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.src = fdHead + fileDescriptor.fd;
audioPlayer.src = fdPath;
})
/* *
......@@ -448,7 +458,7 @@ describe('PlayerLocalTestAudioAPI', function () {
let mySteps = new Array(SRC_STATE, PLAY_STATE, STOP_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.src = fdHead + fileDescriptor.fd;
audioPlayer.src = fdPath;
})
/* *
......@@ -464,7 +474,7 @@ describe('PlayerLocalTestAudioAPI', function () {
let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, STOP_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.src = fdHead + fileDescriptor.fd;
audioPlayer.src = fdPath;
})
/* *
......@@ -480,7 +490,7 @@ describe('PlayerLocalTestAudioAPI', function () {
let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, SEEK_TIME, STOP_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.src = fdHead + fileDescriptor.fd;
audioPlayer.src = fdPath;
})
/* *
......@@ -496,7 +506,7 @@ describe('PlayerLocalTestAudioAPI', function () {
let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, SEEK_TIME, END_STATE);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.src = fdHead + fileDescriptor.fd;
audioPlayer.src = fdPath;
})
/* *
......@@ -512,7 +522,7 @@ describe('PlayerLocalTestAudioAPI', function () {
let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, SEEK_STATE, SEEK_TIME, END_STATE);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.src = fdHead + fileDescriptor.fd;
audioPlayer.src = fdPath;
})
/* *
......@@ -528,7 +538,7 @@ describe('PlayerLocalTestAudioAPI', function () {
let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, 0, END_STATE);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.src = fdHead + fileDescriptor.fd;
audioPlayer.src = fdPath;
})
/* *
......@@ -544,7 +554,7 @@ describe('PlayerLocalTestAudioAPI', function () {
let mySteps = new Array(SRC_STATE, PLAY_STATE, RESET_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.src = fdHead + fileDescriptor.fd;
audioPlayer.src = fdPath;
})
/* *
......@@ -560,7 +570,7 @@ describe('PlayerLocalTestAudioAPI', function () {
let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, RESET_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.src = fdHead + fileDescriptor.fd;
audioPlayer.src = fdPath;
})
/* *
......@@ -592,7 +602,7 @@ describe('PlayerLocalTestAudioAPI', function () {
var mySteps = new Array(SRC_STATE, PLAY_STATE, VOLUME_STATE, VOLUME_VALUE, END_STATE);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.src = fdHead + fileDescriptor.fd;
audioPlayer.src = fdPath;
})
/* *
......@@ -608,7 +618,7 @@ describe('PlayerLocalTestAudioAPI', function () {
var mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, VOLUME_STATE, VOLUME_VALUE, END_STATE);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.src = fdHead + fileDescriptor.fd;
audioPlayer.src = fdPath;
})
/* *
......@@ -624,7 +634,7 @@ describe('PlayerLocalTestAudioAPI', function () {
let mySteps = new Array(SRC_STATE, PLAY_STATE, RELEASE_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.src = fdHead + fileDescriptor.fd;
audioPlayer.src = fdPath;
})
/* *
......@@ -640,7 +650,7 @@ describe('PlayerLocalTestAudioAPI', function () {
let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, RELEASE_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.src = fdHead + fileDescriptor.fd;
audioPlayer.src = fdPath;
})
/* *
......@@ -656,7 +666,7 @@ describe('PlayerLocalTestAudioAPI', function () {
let mySteps = new Array(SRC_STATE, PLAY_STATE, STOP_STATE, RELEASE_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.src = fdHead + fileDescriptor.fd;
audioPlayer.src = fdPath;
})
/* *
......@@ -672,7 +682,7 @@ describe('PlayerLocalTestAudioAPI', function () {
let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, SEEK_TIME, RELEASE_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.src = fdHead + fileDescriptor.fd;
audioPlayer.src = fdPath;
})
/* *
......@@ -688,7 +698,7 @@ describe('PlayerLocalTestAudioAPI', function () {
let mySteps = new Array(SRC_STATE, PLAY_STATE, RESET_STATE, RELEASE_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.src = fdHead + fileDescriptor.fd;
audioPlayer.src = fdPath;
})
/* *
......
......@@ -14,6 +14,7 @@
*/
import media from '@ohos.multimedia.media'
import audio from '@ohos.multimedia.audio'
import {playAudioSource} from '../../../../../AudioPlayerTestBase.js';
import * as mediaTestBase from '../../../../../MediaTestBase.js';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
......@@ -44,6 +45,8 @@ describe('PlayerLocalTestAudioFUNC', function () {
let bufferFlag = false;
let fdHead = 'fd://';
let fileDescriptor = undefined;
let fdPath = '';
let fdNumber = 0;
let audioTrackKey = new Array('channel_count', 'codec_mime', 'sample_rate', 'track_index',
'track_type');
let audioTrackValue = new Array(1, 'audio/mpeg', 48000, 0, 0);
......@@ -53,6 +56,10 @@ describe('PlayerLocalTestAudioFUNC', function () {
await mediaTestBase.getFileDescriptor(AUDIO_SOURCE).then((res) => {
fileDescriptor = res;
});
await mediaTestBase.getFdRead(AUDIO_SOURCE, openFileFailed).then((testNumber) => {
fdNumber = testNumber;
fdPath = fdHead + '' + fdNumber;
})
console.info('beforeAll case');
})
......@@ -67,9 +74,14 @@ describe('PlayerLocalTestAudioFUNC', function () {
afterAll(async function() {
await mediaTestBase.closeFileDescriptor(AUDIO_SOURCE);
await mediaTestBase.closeFdNumber(fdNumber);
console.info('afterAll case');
})
function openFileFailed() {
console.info('case file fail');
}
function initAudioPlayer() {
if (typeof (audioPlayer) != 'undefined') {
audioPlayer.release();
......@@ -299,12 +311,11 @@ describe('PlayerLocalTestAudioFUNC', function () {
* @tc.level : Level0
*/
it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_SETVOLUME', 0, async function (done) {
mediaTestBase.isFileOpen(fileDescriptor, done);
let mySteps = new Array(SRC_STATE, PLAY_STATE, VOLUME_STATE, 0, VOLUME_STATE, 0.5,
VOLUME_STATE, MAX_VOLUME, RESET_STATE, RELEASE_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.src = fdHead + fileDescriptor.fd;
audioPlayer.src = fdPath;
})
/* *
......@@ -392,7 +403,7 @@ describe('PlayerLocalTestAudioFUNC', function () {
testAudioPlayer.release();
done();
});
testAudioPlayer.src = fdHead + fileDescriptor.fd;
testAudioPlayer.src = fdPath;
})
/* *
......@@ -405,7 +416,7 @@ describe('PlayerLocalTestAudioFUNC', function () {
*/
it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_BASE_0100', 0, async function (done) {
mediaTestBase.isFileOpen(fileDescriptor, done);
playAudioSource(fdHead + fileDescriptor.fd, DURATION_TIME, PLAY_TIME, true, done);
playAudioSource(fdPath, DURATION_TIME, PLAY_TIME, true, done);
})
/* *
......@@ -434,8 +445,8 @@ describe('PlayerLocalTestAudioFUNC', function () {
function waitForDone() {
console.info('case wait for next player');
}
playAudioSource(fdHead + fileDescriptor.fd, DURATION_TIME, PLAY_TIME, true, waitForDone);
playAudioSource(fdPath, DURATION_TIME, PLAY_TIME, true, waitForDone);
mediaTestBase.msleep(1000);
playAudioSource(fdHead + fileDescriptor.fd, DURATION_TIME, PLAY_TIME, true, done);
playAudioSource(fdPath, DURATION_TIME, PLAY_TIME, true, done);
})
})
......@@ -18,14 +18,12 @@ import * as mediaTestBase from '../../../../../MediaTestBase.js';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
describe('PlayerLocalTestAudioFormat', function () {
let audioSource = '01.mp3';
const MAX_VOLUME = 1;
const PLAY_TIME = 3000;
const SEEK_TIME = 10000; // 10s
let isToSeek = false;
let isToDuration = false;
let fileDescriptor = undefined;
let fdNumber = 0;
beforeAll(function() {
console.info('beforeAll case');
})
......@@ -36,23 +34,20 @@ describe('PlayerLocalTestAudioFormat', function () {
console.info('beforeEach case');
})
afterEach(function() {
afterEach(async function() {
await mediaTestBase.closeFdNumber(fdNumber);
console.info('afterEach case');
})
afterAll(async function() {
await mediaTestBase.closeFileDescriptor(audioSource);
afterAll(function() {
console.info('afterAll case');
})
async function playSource(audioFile, done) {
let audioPlayer = media.createAudioPlayer();
audioSource = audioFile;
await mediaTestBase.getFileDescriptor(audioSource).then((res) => {
fileDescriptor = res;
});
mediaTestBase.isFileOpen(fileDescriptor, done);
audioPlayer.src = 'fd://' + fileDescriptor.fd;
await mediaTestBase.getFdRead(audioFile, done).then((testNumber) => {
fdNumber = testNumber;
})
audioPlayer.on('dataLoad', () => {
console.info('case set source success');
expect(audioPlayer.state).assertEqual('paused');
......@@ -122,6 +117,7 @@ describe('PlayerLocalTestAudioFormat', function () {
expect().assertFail();
done();
});
audioPlayer.src = 'fd://' + fdNumber;
}
/* *
......
......@@ -17,7 +17,7 @@
{
"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/el2/100/base/ohos.acts.multimedia.video.videoplayer/haps/entry/files"
],
"teardown-command":[
]
......@@ -27,7 +27,8 @@
"pre-push": [
],
"push": [
"./resource/audio/H264_AAC.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/"
"./resource/audio/H264_AAC.mp4 ->/data/app/el2/100/base/ohos.acts.multimedia.video.videoplayer/haps/entry/files/",
"./resource/audio/01.mp3 ->/data/app/el2/100/base/ohos.acts.multimedia.video.videoplayer/haps/entry/files/"
]
}
]
......
......@@ -40,7 +40,7 @@
"label": "$string:entry_MainAbility",
"type": "page",
"homeAbility": true,
"launchType": "standard"
"launchType": "singleton"
}
],
"deviceType": [
......
......@@ -52,10 +52,16 @@ describe('VideoPlayerAPICallbackTest', function () {
const pagePath2 = 'pages/surfaceTest2/surfaceTest2';
let pageId = 0;
let fdHead = 'fd://';
let fdPath = '';
let fdNumber = 0;
let events = require('events');
let eventEmitter = new events.EventEmitter();
beforeAll(async function() {
await mediaTestBase.getFdRead(VIDEO_SOURCE, openFileFailed).then((testNumber) => {
fdNumber = testNumber;
fdPath = fdHead + '' + fdNumber;
})
console.info('beforeAll case');
})
......@@ -79,9 +85,14 @@ describe('VideoPlayerAPICallbackTest', function () {
})
afterAll(async function() {
await mediaTestBase.closeFdNumber(fdNumber);
console.info('afterAll case');
})
function openFileFailed() {
console.info('case file fail');
}
function toNextStep(videoPlayer, steps, done) {
if (steps[0] == END_EVENT) {
console.info('case success!!');
......@@ -138,7 +149,7 @@ describe('VideoPlayerAPICallbackTest', function () {
});
eventEmitter.on(SETURL_EVENT, (videoPlayer, steps, done) => {
steps.shift();
videoPlayer.url = fdHead + fileDescriptor.fd;
videoPlayer.url = fdPath;
toNextStep(videoPlayer, steps, done);
});
eventEmitter.on(SETSURFACE_EVENT, (videoPlayer, steps, done) => {
......
......@@ -167,4 +167,18 @@ describe('VideoPlayerEnumTest', function () {
expect(media.MediaDescriptionKey.MD_KEY_AUD_SAMPLE_RATE).assertEqual("sample_rate");
done();
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_ENUM_MEDIA_SCALE_TYPE_00_0100
* @tc.name : MediaType
* @tc.desc : MediaType Enumeration test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_VIDEO_PLAYER_ENUM_MEDIA_TYPE_00_0100', 0, async function (done) {
expect(media.VideoScaleType.VIDEO_SCALE_TYPE_FIT).assertEqual(0);
expect(media.VideoScaleType.VIDEO_SCALE_TYPE_FIT_CROP).assertEqual(1);
done();
})
})
\ No newline at end of file
......@@ -54,6 +54,8 @@ describe('VideoPlayerFuncCallbackTest', function () {
const pagePath1 = 'pages/surfaceTest/surfaceTest';
const pagePath2 = 'pages/surfaceTest2/surfaceTest2';
let pageId = 0;
let fdPath = '';
let fdNumber = 0;
let events = require('events');
let eventEmitter = new events.EventEmitter();
......@@ -62,6 +64,10 @@ describe('VideoPlayerFuncCallbackTest', function () {
await mediaTestBase.getFileDescriptor(VIDEO_SOURCE).then((res) => {
fileDescriptor = res;
});
await mediaTestBase.getFdRead(VIDEO_SOURCE, openFileFailed).then((testNumber) => {
fdNumber = testNumber;
fdPath = fdHead + '' + fdNumber;
})
})
beforeEach(async function() {
......@@ -81,9 +87,14 @@ describe('VideoPlayerFuncCallbackTest', function () {
afterAll(async function() {
await mediaTestBase.closeFileDescriptor(VIDEO_SOURCE);
await mediaTestBase.closeFdNumber(fdNumber);
console.info('afterAll case');
})
function openFileFailed() {
console.info('case file fail');
}
function toNextStep(videoPlayer, steps, done) {
if (steps[0] == END_EVENT) {
console.info('case success!!');
......@@ -469,8 +480,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_SETSOURCE', 0, async function (done) {
mediaTestBase.isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let fdPath = '';
let mySteps = new Array(CREATE_EVENT, SETSOURCE_EVENT, fdPath, ERROR_EVENT, RELEASE_EVENT, END_EVENT);
let mySteps = new Array(CREATE_EVENT, SETSOURCE_EVENT, '', ERROR_EVENT, RELEASE_EVENT, END_EVENT);
eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done);
})
......@@ -485,7 +495,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_SETVOLUME', 0, async function (done) {
mediaTestBase.isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETFDSOURCE_EVENT, fileDescriptor, SETSURFACE_EVENT,
let mySteps = new Array(CREATE_EVENT, SETSOURCE_EVENT, fdPath, SETSURFACE_EVENT,
PREPARE_EVENT, PLAY_EVENT, SETVOLUME_EVENT, 0, SETVOLUME_EVENT, 0.5, SETVOLUME_EVENT, 1,
RELEASE_EVENT, END_EVENT);
eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done);
......@@ -522,7 +532,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_CALLBACK', 0, async function (done) {
mediaTestBase.isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let frameCount = -1;
let frameCount = false;
let completedCount = 0;
let widthValue = -1;
let heightValue = -1;
......@@ -547,6 +557,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
expect(widthValue).assertEqual(WIDTH_VALUE);
expect(heightValue).assertEqual(HEIGHT_VALUE);
expect(completedCount).assertEqual(1);
expect(frameCount).assertEqual(true);
videoPlayer.release((err) => {
if (typeof (err) == 'undefined') {
console.info('case release success!!');
......@@ -564,6 +575,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
videoPlayer.on('startRenderFrame', () => {
console.info('case startRenderFrame success');
frameCount = true;
});
videoPlayer.on('videoSizeChanged', (width, height) => {
......
......@@ -14,11 +14,13 @@
*/
import media from '@ohos.multimedia.media'
import audio from '@ohos.multimedia.audio'
import * as mediaTestBase from '../../../../../MediaTestBase.js';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
describe('VideoPlayerFuncPromiseTest', function () {
const VIDEO_SOURCE = 'H264_AAC.mp4';
const AUDIO_SOURCE = '01.mp3';
const PLAY_TIME = 3000;
const SEEK_TIME = 5000;
const WIDTH_VALUE = 720;
......@@ -34,12 +36,18 @@ describe('VideoPlayerFuncPromiseTest', function () {
const pagePath1 = 'pages/surfaceTest/surfaceTest';
const pagePath2 = 'pages/surfaceTest2/surfaceTest2';
let pageId = 0;
let fdPath = '';
let fdNumber = 0;
beforeAll(async function() {
console.info('beforeAll case');
await mediaTestBase.getFileDescriptor(VIDEO_SOURCE).then((res) => {
fileDescriptor = res;
});
await mediaTestBase.getFdRead(VIDEO_SOURCE, openFileFailed).then((testNumber) => {
fdNumber = testNumber;
fdPath = fdHead + '' + fdNumber;
})
})
beforeEach(async function() {
......@@ -59,9 +67,14 @@ describe('VideoPlayerFuncPromiseTest', function () {
afterAll(async function() {
await mediaTestBase.closeFileDescriptor(VIDEO_SOURCE);
await mediaTestBase.closeFdNumber(fdNumber);
console.info('afterAll case');
})
function openFileFailed() {
console.info('case file fail');
}
function checkSpeedTime(videoPlayer, speedValue, startTime) {
let newTime = videoPlayer.currentTime;
if (videoPlayer.state == 'playing') {
......@@ -140,7 +153,7 @@ describe('VideoPlayerFuncPromiseTest', function () {
}
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
videoPlayer.url = fdHead + fileDescriptor.fd;
videoPlayer.url = fdPath;
await videoPlayer.setDisplaySurface(surfaceID).then(() => {
expect(videoPlayer.state).assertEqual('idle');
console.info('case setDisplaySurface success');
......@@ -197,7 +210,7 @@ describe('VideoPlayerFuncPromiseTest', function () {
}
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
videoPlayer.url = fdHead + fileDescriptor.fd;
videoPlayer.url = fdPath;
await videoPlayer.setDisplaySurface(surfaceID).then(() => {
expect(videoPlayer.state).assertEqual('idle');
console.info('case setDisplaySurface success');
......@@ -282,7 +295,7 @@ describe('VideoPlayerFuncPromiseTest', function () {
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_Callback', 0, async function (done) {
mediaTestBase.isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let frameCount = -1;
let frameCount = false;
let completedCount = 0;
let widthValue = -1;
let heightValue = -1;
......@@ -304,7 +317,7 @@ describe('VideoPlayerFuncPromiseTest', function () {
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
expect(widthValue).assertEqual(WIDTH_VALUE);
expect(heightValue).assertEqual(HEIGHT_VALUE);
//expect(frameCount).assertEqual(1);
expect(frameCount).assertEqual(true);
expect(completedCount).assertEqual(1);
done();
});
......@@ -316,7 +329,7 @@ describe('VideoPlayerFuncPromiseTest', function () {
videoPlayer.on('startRenderFrame', () => {
console.info('case startRenderFrame success');
//frameCount++;
frameCount = true;
});
videoPlayer.on('videoSizeChanged', (width, height) => {
......@@ -325,7 +338,7 @@ describe('VideoPlayerFuncPromiseTest', function () {
heightValue = height;
});
videoPlayer.url = fdHead + fileDescriptor.fd;
videoPlayer.url = fdPath;
await videoPlayer.setDisplaySurface(surfaceID).then(() => {
expect(videoPlayer.state).assertEqual('idle');
console.info('case setDisplaySurface success');
......@@ -390,7 +403,7 @@ describe('VideoPlayerFuncPromiseTest', function () {
console.info('case bufferingUpdate bufferCount value is ' + bufferCount);
});
videoPlayer.url = fdHead + fileDescriptor.fd;
videoPlayer.fdSrc = fileDescriptor;
await videoPlayer.setDisplaySurface(surfaceID).then(() => {
expect(videoPlayer.state).assertEqual('idle');
console.info('case setDisplaySurface success');
......@@ -457,7 +470,7 @@ describe('VideoPlayerFuncPromiseTest', function () {
done();
});
videoPlayer.url = fdHead + fileDescriptor.fd;
videoPlayer.url = fdPath;
await videoPlayer.setDisplaySurface(surfaceID).then(() => {
console.info('case setDisplaySurface success');
expect(videoPlayer.state).assertEqual('idle');
......@@ -501,7 +514,7 @@ describe('VideoPlayerFuncPromiseTest', function () {
expect(videoPlayer.state).assertEqual('idle');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
videoPlayer.url = fdHead + fileDescriptor.fd;
videoPlayer.url = fdPath;
await videoPlayer.prepare().then(() => {
console.info('case prepare called!!');
expect(videoPlayer.state).assertEqual('prepared');
......@@ -538,4 +551,260 @@ describe('VideoPlayerFuncPromiseTest', function () {
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
videoPlayer.loop = false;
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_VIDEOSCALETYPE_0100
* @tc.name : 001.test video player videoScaleTpe (promise)
* @tc.desc : Video playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_VIDEOSCALETYPE_0100', 0, async function (done) {
mediaTestBase.isFileOpen(fileDescriptor, done);
let videoPlayer = null;
await media.createVideoPlayer().then((video) => {
if (typeof (video) != 'undefined') {
console.info('case createVideoPlayer success');
videoPlayer = video;
expect(videoPlayer.state).assertEqual('idle');
} else {
console.info('case createVideoPlayer is failed');
expect().assertFail();
}
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
videoPlayer.on('error', (error) => {
expect().assertFail();
console.info('case error happened :' + error.message);
});
videoPlayer.on('playbackCompleted', async () => {
console.info('case playbackCompleted success');
await videoPlayer.release().then(() => {
console.info('case release called!!');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
done();
});
videoPlayer.url = fdPath;
console.info('case set videoScaleType : 1');
videoPlayer.videoScaleType = media.VideoScaleType.VIDEO_SCALE_TYPE_FIT_CROP;
await videoPlayer.setDisplaySurface(surfaceID).then(() => {
console.info('case setDisplaySurface success');
expect(videoPlayer.state).assertEqual('idle');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoPlayer.prepare().then(() => {
console.info('case prepare called!!');
expect(videoPlayer.state).assertEqual('prepared');
expect(videoPlayer.duration).assertEqual(DURATION_TIME);
expect(videoPlayer.width).assertEqual(WIDTH_VALUE);
expect(videoPlayer.height).assertEqual(HEIGHT_VALUE);
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
expect(videoPlayer.videoScaleType).assertEqual(media.VideoScaleType.VIDEO_SCALE_TYPE_FIT_CROP);
let startTime = videoPlayer.currentTime;
await videoPlayer.play().then(() => {
console.info('case play called!!');
mediaTestBase.msleep(PLAY_TIME);
expect(videoPlayer.state).assertEqual('playing');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
let endTime = videoPlayer.currentTime;
expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME);
console.info('case set videoScaleType : 0');
videoPlayer.videoScaleType = media.VideoScaleType.VIDEO_SCALE_TYPE_FIT;
await videoPlayer.pause().then(() => {
expect(videoPlayer.state).assertEqual('paused');
console.info('case pause called!!');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
expect(videoPlayer.videoScaleType).assertEqual(media.VideoScaleType.VIDEO_SCALE_TYPE_FIT);
await videoPlayer.play().then(() => {
console.info('case play called!!');
mediaTestBase.msleep(PLAY_TIME);
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);
console.info('case set videoScaleType : 1');
videoPlayer.videoScaleType = media.VideoScaleType.VIDEO_SCALE_TYPE_FIT_CROP;
await videoPlayer.reset().then(() => {
console.info('case reset called!!');
expect(videoPlayer.state).assertEqual('idle');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
videoPlayer.url = fdPath;
console.info('case set videoScaleType : 1');
videoPlayer.videoScaleType = media.VideoScaleType.VIDEO_SCALE_TYPE_FIT_CROP;
await videoPlayer.prepare().then(() => {
console.info('case prepare called!!');
expect(videoPlayer.state).assertEqual('prepared');
expect(videoPlayer.duration).assertEqual(DURATION_TIME);
expect(videoPlayer.width).assertEqual(WIDTH_VALUE);
expect(videoPlayer.height).assertEqual(HEIGHT_VALUE);
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
expect(videoPlayer.videoScaleType).assertEqual(media.VideoScaleType.VIDEO_SCALE_TYPE_FIT_CROP);
videoPlayer.loop = true;
startTime = videoPlayer.currentTime;
await videoPlayer.play().then(() => {
console.info('case play called!!');
mediaTestBase.msleep(PLAY_TIME);
expect(videoPlayer.state).assertEqual('playing');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
endTime = videoPlayer.currentTime;
expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME);
console.info('case set videoScaleType : 0');
videoPlayer.videoScaleType = media.VideoScaleType.VIDEO_SCALE_TYPE_FIT;
await videoPlayer.seek(videoPlayer.duration / 2).then((seekDoneTime) => {
expect(videoPlayer.state).assertEqual('playing');
expect(videoPlayer.videoScaleType).assertEqual(media.VideoScaleType.VIDEO_SCALE_TYPE_FIT);
mediaTestBase.msleep(PLAY_TIME);
console.info('case seek called and seekDoneTime is' + seekDoneTime);
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
console.info('case set videoScaleType : 1');
videoPlayer.videoScaleType = media.VideoScaleType.VIDEO_SCALE_TYPE_FIT_CROP;
await videoPlayer.seek(0).then((seekDoneTime) => {
expect(videoPlayer.state).assertEqual('playing');
expect(videoPlayer.videoScaleType).assertEqual(media.VideoScaleType.VIDEO_SCALE_TYPE_FIT_CROP);
mediaTestBase.msleep(PLAY_TIME);
console.info('case seek called and seekDoneTime is' + seekDoneTime);
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
console.info('case set videoScaleType : 0');
videoPlayer.videoScaleType = media.VideoScaleType.VIDEO_SCALE_TYPE_FIT;
await videoPlayer.seek(videoPlayer.duration).then((seekDoneTime) => {
expect(videoPlayer.state).assertEqual('playing');
expect(videoPlayer.videoScaleType).assertEqual(media.VideoScaleType.VIDEO_SCALE_TYPE_FIT);
mediaTestBase.msleep(PLAY_TIME);
console.info('case seek called and seekDoneTime is' + seekDoneTime);
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
videoPlayer.loop = false;
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_VIDEOSCALETYPE_0200
* @tc.name : 002.set videoScaleTpe 100 times in playing (promise)
* @tc.desc : Video playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_VIDEOSCALETYPE_0200', 0, async function (done) {
mediaTestBase.isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let bufferCount = false;
let count = 0;
await media.createVideoPlayer().then((video) => {
if (typeof (video) != 'undefined') {
videoPlayer = video;
expect(videoPlayer.state).assertEqual('idle');
} else {
console.info('case createVideoPlayer is failed');
expect().assertFail();
}
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
videoPlayer.on('playbackCompleted', async () => {
console.info('case playbackCompleted success');
await videoPlayer.play().then(() => {
expect(videoPlayer.loop).assertEqual(false);
console.info('case play called!!');
mediaTestBase.msleep(PLAY_TIME);
expect(videoPlayer.state).assertEqual('playing');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoPlayer.release().then(() => {
console.info('case release called!!');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
expect(bufferCount).assertEqual(true);
done();
});
videoPlayer.on('bufferingUpdate', (infoType, value) => {
console.info('case bufferingUpdate success infoType is ' + infoType);
console.info('case bufferingUpdate success value is ' + value);
bufferCount = true;
});
videoPlayer.url = fdPath;
await videoPlayer.setDisplaySurface(surfaceID).then(() => {
expect(videoPlayer.state).assertEqual('idle');
console.info('case setDisplaySurface success');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoPlayer.prepare().then(() => {
videoPlayer.loop = true;
expect(videoPlayer.state).assertEqual('prepared');
expect(videoPlayer.duration).assertEqual(DURATION_TIME);
expect(videoPlayer.width).assertEqual(WIDTH_VALUE);
expect(videoPlayer.height).assertEqual(HEIGHT_VALUE);
console.info('case prepare called!!');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
let startTime = videoPlayer.currentTime;
await videoPlayer.play().then(() => {
expect(videoPlayer.loop).assertEqual(true);
console.info('case play called!!');
mediaTestBase.msleep(PLAY_TIME);
expect(videoPlayer.state).assertEqual('playing');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
let endTime = videoPlayer.currentTime;
expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME);
for (let i = 0; i < 20; i++) {
if (count == 0) {
console.info('case set videoScaleType : 1');
videoPlayer.videoScaleType = media.VideoScaleType.VIDEO_SCALE_TYPE_FIT_CROP;
count = 1;
} else {
console.info('case set videoScaleType : 0');
videoPlayer.videoScaleType = media.VideoScaleType.VIDEO_SCALE_TYPE_FIT;
count = 0;
}
mediaTestBase.msleep(500);
}
videoPlayer.loop = false;
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_VIDEOSCALETYPE_0300
* @tc.name : 003.set error value to videoScaleTpe (promise)
* @tc.desc : Video playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_VIDEOSCALETYPE_0300', 0, async function (done) {
mediaTestBase.isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let errorCount = 0;
await media.createVideoPlayer().then((video) => {
if (typeof (video) != 'undefined') {
videoPlayer = video;
expect(videoPlayer.state).assertEqual('idle');
} else {
console.info('case createVideoPlayer is failed');
expect().assertFail();
}
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
videoPlayer.on('error', async (error) => {
errorCount++;
console.info('case error happened :' + error.message);
if (errorCount == 3) {
await videoPlayer.release().then(() => {
console.info('case release called!!');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
done();
}
});
videoPlayer.videoScaleType = media.VideoScaleType.VIDEO_SCALE_TYPE_FIT;
videoPlayer.url = fdPath;
videoPlayer.videoScaleType = 2;
videoPlayer.videoScaleType = -1;
})
})
......@@ -40,7 +40,7 @@
"label": "$string:entry_MainAbility",
"type": "page",
"homeAbility": true,
"launchType": "standard"
"launchType": "singleton"
}
],
"deviceType": [
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册