提交 2a98d17e 编写于 作者: F fulizhong

modify testcases Signed-off-by: FULIZHONG<fulizhong1@huawei.com>

Signed-off-by: Nfulizhong <fulizhong@huawei.com>
上级 984837be
......@@ -45,6 +45,7 @@ group("multimedia") {
"media/media_js_standard/audioRecorder:audio_recorder_js_hap",
"media/media_js_standard/recorderFormat:recorder_format_js_hap",
"media/media_js_standard/videoPlayer:video_player_js_hap",
"media/media_js_standard/videoRecorder:video_recorder_js_hap",
"medialibrary/mediaLibrary_album:mediaLibrary_album_hap",
"medialibrary/mediaLibrary_base:mediaLibrary_base_hap",
"medialibrary/mediaLibrary_favorite:mediaLibrary_favorite_hap",
......
......@@ -27,48 +27,72 @@ const BITRATE_DELTA_TIME = 20000;
const PLAY_TIME = 1000;
export async function initCaptureSession(videoOutPut, cameraManager, cameras, cameraID) {
let cameraInput = await cameraManager.createCameraInput(cameras[cameraID].cameraId);
export async function initCaptureSession(videoOutPut, cameraManager, cameraDevice, previewOutput) {
let cameraInput = await cameraManager.createCameraInput(cameraDevice);
if (cameraInput != null) {
console.info('[camera] case createCameraInput success');
} else {
console.info('[camera] case createCameraInput failed');
return;
}
let captureSession = await camera.createCaptureSession(null);
await cameraInput.open((err) => {
if(err){
console.info('[camera] cameraInput open Failed');
return
}
console.info('[camera] cameraInput open success');
})
let captureSession = await cameraManager.createCaptureSession();
await captureSession.beginConfig();
await captureSession.addInput(cameraInput);
await captureSession.addOutput(previewOutput);
await captureSession.addOutput(videoOutPut);
await captureSession.commitConfig();
await captureSession.start();
return captureSession;
}
export async function stopCaptureSession(captureSession) {
await captureSession.release();
await captureSession.stop().then(() => {
console.info('[camera] case captureSession stop success');
});
await captureSession.release().then(() => {
console.info('[camera] case captureSession release success');
});
}
export function getTrackArray(videoType, recorderConfigFile) {
export function getTrackArray(videoType, recorderConfigFile, sourceType) {
if (videoType == AUDIO_VIDEO_TYPE) {
let audioTrack = new Array(recorderConfigFile.audioBitrate, recorderConfigFile.audioChannels,
'audio/mpeg', recorderConfigFile.audioSampleRate);
let videoTrack = null;
if (recorderConfigFile.videoCodec == 'video/avc') {
if (sourceType == media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_ES) {
videoTrack = new Array('video/x-h264', recorderConfigFile.videoFrameHeight,
recorderConfigFile.videoFrameWidth);
} else {
videoTrack = new Array('video/mpeg', recorderConfigFile.videoFrameHeight,
recorderConfigFile.videoFrameWidth);
if (recorderConfigFile.videoCodec == 'video/avc') {
videoTrack = new Array('video/x-h264', recorderConfigFile.videoFrameHeight,
recorderConfigFile.videoFrameWidth);
} else {
videoTrack = new Array('video/mpeg', recorderConfigFile.videoFrameHeight,
recorderConfigFile.videoFrameWidth);
}
}
let trackArray = new Array(videoTrack, audioTrack);
return trackArray;
} else if (videoType == ONLYVIDEO_TYPE) {
let videoTrack = null;
if (recorderConfigFile.videoCodec == 'video/avc') {
if (sourceType == media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_ES) {
videoTrack = new Array('video/x-h264', recorderConfigFile.videoFrameHeight,
recorderConfigFile.videoFrameWidth);
} else {
videoTrack = new Array('video/mpeg', recorderConfigFile.videoFrameHeight,
recorderConfigFile.videoFrameWidth);
if (recorderConfigFile.videoCodec == 'video/avc') {
videoTrack = new Array('video/x-h264', recorderConfigFile.videoFrameHeight,
recorderConfigFile.videoFrameWidth);
} else {
videoTrack = new Array('video/mpeg', recorderConfigFile.videoFrameHeight,
recorderConfigFile.videoFrameWidth);
}
}
let trackArray = new Array(videoTrack);
return trackArray;
......@@ -115,6 +139,12 @@ export async function checkVideos(playFdPath, duration, trackArray, playerSurfac
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
console.info('[checkVideos] case checkVideos fdPath is :' + playFdPath);
videoPlayer.on('error', (error) => {
console.info(`case error called,errMessage is ${error.message}`);
expect().assertFail();
return;
});
videoPlayer.url = playFdPath;
let tarckType = undefined;
if (playerSurfaceId != null) {
......@@ -141,20 +171,6 @@ export async function checkVideos(playFdPath, duration, trackArray, playerSurfac
expect().assertFail();
}
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
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(Math.abs(endTime - startTime - PLAY_TIME)).assertLess(DELTA_TIME);
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!!');
......
......@@ -43,6 +43,13 @@ describe('VideoRecorderAPICallbackTest', function () {
let fdPath;
let fdObject;
let cameraID = 0;
let playerSurfaceId = '';
let pageId = 0;
let videoProfiles;
let previewProfiles;
let previewOutput;
const pagePath1 = 'pages/surfaceTest/surfaceTest';
const pagePath2 = 'pages/surfaceTest2/surfaceTest2';
let events = require('events');
let eventEmitter = new events.EventEmitter();
......@@ -79,19 +86,42 @@ describe('VideoRecorderAPICallbackTest', function () {
console.info('[camera] case getCameraManager failed');
return;
}
cameras = await cameraManager.getCameras();
await cameraManager.getSupportedCameras().then((cameraDevices)=> {
cameras = cameraDevices;
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
if (cameras != null) {
console.info('[camera] case getCameras success');
} else {
console.info('[camera] case getCameras failed');
}
await cameraManager.getSupportedOutputCapability(cameras[0]).then((cameraoutputcapability) => {
console.info('[camera] case getSupportedOutputCapability success');
videoProfiles = cameraoutputcapability.videoProfiles;
videoProfiles[0].size.height = 480;
videoProfiles[0].size.width = 640;
previewProfiles = cameraoutputcapability.previewProfiles;
previewProfiles[0].size.height = 480;
previewProfiles[0].size.width = 640;
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback)
if (previewProfiles[0].format == camera.CameraFormat.CAMERA_FORMAT_YUV_420_SP) {
console.info('[camera] case format is VIDEO_SOURCE_TYPE_SURFACE_YUV');
videoConfig.videoSourceType = media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_YUV;
} else {
console.info('[camera] case format is VIDEO_SOURCE_TYPE_SURFACE_ES');
videoConfig.videoSourceType = media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_ES;
}
fdObject = await mediaTestBase.getFd('recorder_callback_api.mp4');
fdPath = "fd://" + fdObject.fdNumber.toString();
videoConfig.url = fdPath;
console.info('beforeAll case');
})
beforeEach(function () {
beforeEach(async function () {
await mediaTestBase.toNewPage(pagePath1, pagePath2, pageId);
pageId = (pageId + 1) % 2;
await mediaTestBase.msleepAsync(1000).then(
() => {}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
playerSurfaceId = globalThis.value;
surfaceID = null;
console.info('beforeEach case');
})
......@@ -101,7 +131,7 @@ describe('VideoRecorderAPICallbackTest', function () {
})
afterAll(async function () {
await mediaTestBase.closeFd();
await mediaTestBase.closeFd(fdObject.fileAsset, fdObject.fdNumber);
console.info('afterAll case');
})
......@@ -123,13 +153,15 @@ describe('VideoRecorderAPICallbackTest', function () {
eventEmitter.on(START_STREEAM, async (videoRecorder, steps, done) => {
steps.shift();
videoOutput = await camera.createVideoOutput(surfaceID);
videoOutput = await cameraManager.createVideoOutput(videoProfiles[0], surfaceID);
if (videoOutput == null) {
console.info('[camera] case createVideoOutput failed');
} else {
console.info('[camera] case createVideoOutput success');
}
captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager, cameras, cameraID);
previewOutput = await cameraManager.createPreviewOutput(previewProfiles[0], playerSurfaceId)
captureSession = await videoRecorderBase.initCaptureSession(videoOutput, cameraManager,
cameras[0], previewOutput);
await videoOutput.start().then(() => {
console.info('[camera] case videoOutput start success');
});
......@@ -141,10 +173,6 @@ describe('VideoRecorderAPICallbackTest', function () {
await videoOutput.stop().then(() => {
console.info('[camera] case videoOutput stop success');
});
await videoOutput.release().then(() => {
console.info('[camera] case videoOutput release success');
});
videoOutput = undefined;
await videoRecorderBase.stopCaptureSession(captureSession);
toNextStep(videoRecorder, steps, done);
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册