提交 4335ba88 编写于 作者: Y yygxr

fix camera session and manager test case error

Signed-off-by: Nyygxr <wuhao30@huawei.com>
上级 6ef59106
...@@ -26,40 +26,38 @@ const TAG = "CameraUnitTest: "; ...@@ -26,40 +26,38 @@ const TAG = "CameraUnitTest: ";
// Define global variables // Define global variables
let mCameraManager; let mCameraManager;
let photoSurfaceId; let mPhotoSurfaceId;
let videoSurfaceId;
let mCameraDevicesArray; let mCameraDevicesArray;
let fdPath; let mVideoSurface;
let fileAsset; let mVideoRecorder;
let fdNumber; let mFdPath;
let mFileAsset;
let mFdNumber;
// 创建视频录制的参数 let mVideoProfileCfg = {
let videoProfile = {
audioBitrate: 48000, audioBitrate: 48000,
audioChannels: 2, audioChannels: 2,
audioCodec: 'audio/mp4a-latm', audioCodec: 'audio/mp4a-latm',
audioSampleRate: 48000, audioSampleRate: 48000,
durationTime: 1000,
fileFormat: 'mp4', fileFormat: 'mp4',
videoBitrate: 48000, videoBitrate: 48000,
videoCodec: 'video/mp4v-es', videoCodec: 'video/mp4v-es',
videoFrameWidth: 640, videoFrameWidth: 640,
videoFrameHeight: 480, videoFrameHeight: 480,
videoFrameRate: 30 videoFrameRate: 30
} }
let videoConfig = { let mVideoConfig = {
audioSourceType: 1, audioSourceType: 1,
videoSourceType: 0, videoSourceType: 0,
profile: videoProfile, profile: mVideoProfileCfg,
url: 'file:///data/media/CameraManager.mp4', url: 'file:///data/media/CameraManager.mp4',
orientationHint: 0, orientationHint: 0,
location: { latitude: 30, longitude: 130 }, location: { latitude: 30, longitude: 130 },
maxSize: 100, maxSize: 100,
maxDuration: 500 maxDuration: 500
} }
// 创建录像输出流
let videoRecorder
export default function cameraManagerTest(surfaceId: any) { export default function cameraManagerTest(surfaceId: any) {
...@@ -69,8 +67,8 @@ export default function cameraManagerTest(surfaceId: any) { ...@@ -69,8 +67,8 @@ export default function cameraManagerTest(surfaceId: any) {
console.log(TAG + 'before receiver check') console.log(TAG + 'before receiver check')
if (receiver !== undefined) { if (receiver !== undefined) {
console.log(TAG + 'Receiver is ok') console.log(TAG + 'Receiver is ok')
photoSurfaceId = await receiver.getReceivingSurfaceId() mPhotoSurfaceId = await receiver.getReceivingSurfaceId()
console.log(TAG + 'Received id: ' + JSON.stringify(photoSurfaceId)) console.log(TAG + 'Received id: ' + JSON.stringify(mPhotoSurfaceId))
} else { } else {
console.log(TAG + 'Receiver is not ok') console.log(TAG + 'Receiver is not ok')
} }
...@@ -90,15 +88,15 @@ export default function cameraManagerTest(surfaceId: any) { ...@@ -90,15 +88,15 @@ export default function cameraManagerTest(surfaceId: any) {
selectionArgs: [args], selectionArgs: [args],
} }
let fetchFileResult = await mediaTest.getFileAssets(fetchOp); let fetchFileResult = await mediaTest.getFileAssets(fetchOp);
fileAsset = await fetchFileResult.getAllObject(); mFileAsset = await fetchFileResult.getAllObject();
fdNumber = await fileAsset[0].open('Rw'); mFdNumber = await mFileAsset[0].open('Rw');
fdPath = "fd://" + fdNumber.toString(); mFdPath = "fd://" + mFdNumber.toString();
} }
} }
async function closeFd() { async function closeFd() {
if (fileAsset != null) { if (mFileAsset != null) {
await fileAsset[0].close(fdNumber).then(() => { await mFileAsset[0].close(mFdNumber).then(() => {
console.info('[mediaLibrary] case close fd success'); console.info('[mediaLibrary] case close fd success');
}).catch((err) => { }).catch((err) => {
console.info('[mediaLibrary] case close fd failed'); console.info('[mediaLibrary] case close fd failed');
...@@ -108,24 +106,35 @@ export default function cameraManagerTest(surfaceId: any) { ...@@ -108,24 +106,35 @@ export default function cameraManagerTest(surfaceId: any) {
} }
} }
async function getvideosurface() { async function getVideoReceiveSurface() {
console.log(TAG + 'Entering getVideoReceiveSurface')
await getFd('CameraManager.mp4'); await getFd('CameraManager.mp4');
videoConfig.url = fdPath; mVideoConfig.url = mFdPath;
media.createVideoRecorder((err, recorder) => { media.createVideoRecorder((err, recorder) => {
console.info(TAG + 'createVideoRecorder called') console.info(TAG + 'Entering create video receiver')
videoRecorder = recorder mVideoRecorder = recorder
console.info(TAG + 'videoRecorder is :' + JSON.stringify(videoRecorder)) console.info(TAG + 'videoRecorder is :' + JSON.stringify(mVideoRecorder))
console.info(TAG + 'videoRecorder.prepare called.') console.info(TAG + 'videoRecorder.prepare called.')
videoRecorder.prepare(videoConfig, (err) => { mVideoRecorder.prepare(mVideoConfig, (err) => {
console.info(TAG + 'videoRecorder.prepare success.') console.info(TAG + 'videoRecorder.prepare success.')
}) mVideoRecorder.getInputSurface((err, id) => {
videoRecorder.getInputSurface((err, id) => { console.info(TAG + 'getInputSurface called')
console.info(TAG + 'getInputSurface called') mVideoSurface = id
videoSurfaceId = id console.info(TAG + 'getInputSurface surfaceId: ' + JSON.stringify(mVideoSurface))
console.info(TAG + 'getInputSurface surfaceId: ' + JSON.stringify(videoSurfaceId)) })
}) })
}) })
} console.log(TAG + 'Exit getVideoReceiveSurface')
}
async function releaseVideoReceiveSurface() {
console.log(TAG + 'Entering releaseVideoReceiveSurface')
mVideoRecorder.release((err) => {
console.info(TAG + 'Entering release video receiver')
})
await closeFd();
console.log(TAG + 'Exit releaseVideoReceiveSurface')
}
function sleep(ms) { function sleep(ms) {
console.info(TAG + "Entering sleep -> Promise constructor"); console.info(TAG + "Entering sleep -> Promise constructor");
...@@ -264,7 +273,7 @@ describe('CameraManagerTest', function () { ...@@ -264,7 +273,7 @@ describe('CameraManagerTest', function () {
await applyPermission(); await applyPermission();
await getCameraManagerInstance(); await getCameraManagerInstance();
await getImageReceiverSurfaceId(); await getImageReceiverSurfaceId();
await getvideosurface(); await getVideoReceiveSurface();
console.info('beforeAll case'); console.info('beforeAll case');
}) })
...@@ -278,7 +287,8 @@ describe('CameraManagerTest', function () { ...@@ -278,7 +287,8 @@ describe('CameraManagerTest', function () {
}) })
afterAll(function () { afterAll(function () {
closeFd(); releaseVideoReceiveSurface();
sleep(1000);
console.info('afterAll case'); console.info('afterAll case');
}) })
...@@ -814,7 +824,7 @@ describe('CameraManagerTest', function () { ...@@ -814,7 +824,7 @@ describe('CameraManagerTest', function () {
expect().assertFail(); expect().assertFail();
} }
for (let j = 0; j < photoProfilesArray.length; j++) { for (let j = 0; j < photoProfilesArray.length; j++) {
mCameraManager.createPhotoOutput(photoProfilesArray[j], photoSurfaceId, async (err, data) => { mCameraManager.createPhotoOutput(photoProfilesArray[j], mPhotoSurfaceId, async (err, data) => {
if (isEmpty(data)) { if (isEmpty(data)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_PHOTO_OUTPUT_CALLBACK_0100 data == null || undefined") console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_PHOTO_OUTPUT_CALLBACK_0100 data == null || undefined")
expect().assertFail(); expect().assertFail();
...@@ -854,7 +864,7 @@ describe('CameraManagerTest', function () { ...@@ -854,7 +864,7 @@ describe('CameraManagerTest', function () {
expect().assertFail(); expect().assertFail();
} }
for (let j = 0; j < photoProfilesArray.length; j++) { for (let j = 0; j < photoProfilesArray.length; j++) {
let photoOutputPromise = await mCameraManager.createPhotoOutput(photoProfilesArray[j], photoSurfaceId); let photoOutputPromise = await mCameraManager.createPhotoOutput(photoProfilesArray[j], mPhotoSurfaceId);
if (isEmpty(photoOutputPromise)) { if (isEmpty(photoOutputPromise)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_PHOTO_OUTPUT_PROMISE_0100 photoOutputPromise == null || undefined") console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_PHOTO_OUTPUT_PROMISE_0100 photoOutputPromise == null || undefined")
expect().assertFail(); expect().assertFail();
......
...@@ -576,12 +576,12 @@ export default function cameraSessionTest(surfaceId: any) { ...@@ -576,12 +576,12 @@ export default function cameraSessionTest(surfaceId: any) {
await sleep(100); await sleep(100);
}) })
afterAll(async function () { afterAll(function () {
await releaseInputs(); releaseInputs();
await releaseOutputs(); releaseOutputs();
await releaseVideoReceiveSurface(); releaseVideoReceiveSurface();
releaseCameraSessionInstance(); releaseCameraSessionInstance();
await sleep(100); sleep(1000);
console.info('afterAll case'); console.info('afterAll case');
}) })
......
...@@ -620,7 +620,7 @@ export default function cameraSessionExposureTest(surfaceId: any) { ...@@ -620,7 +620,7 @@ export default function cameraSessionExposureTest(surfaceId: any) {
releaseOutputs(); releaseOutputs();
releaseVideoReceiveSurface(); releaseVideoReceiveSurface();
releaseCameraSessionInstance(); releaseCameraSessionInstance();
sleep(100); sleep(1000);
console.info('afterAll case'); console.info('afterAll case');
}) })
......
...@@ -571,7 +571,7 @@ export default function cameraSessionFlashTest(surfaceId: any) { ...@@ -571,7 +571,7 @@ export default function cameraSessionFlashTest(surfaceId: any) {
releaseOutputs(); releaseOutputs();
releaseVideoReceiveSurface(); releaseVideoReceiveSurface();
releaseCameraSessionInstance(); releaseCameraSessionInstance();
sleep(100); sleep(1000);
console.info('afterAll case'); console.info('afterAll case');
}) })
......
...@@ -616,7 +616,7 @@ export default function cameraSessionFocusTest(surfaceId: any) { ...@@ -616,7 +616,7 @@ export default function cameraSessionFocusTest(surfaceId: any) {
releaseOutputs(); releaseOutputs();
releaseVideoReceiveSurface(); releaseVideoReceiveSurface();
releaseCameraSessionInstance(); releaseCameraSessionInstance();
sleep(100); sleep(1000);
console.info('afterAll case'); console.info('afterAll case');
}) })
......
...@@ -569,7 +569,7 @@ export default function cameraSessionVideoStabilizationTest(surfaceId: any) { ...@@ -569,7 +569,7 @@ export default function cameraSessionVideoStabilizationTest(surfaceId: any) {
releaseOutputs(); releaseOutputs();
releaseVideoReceiveSurface(); releaseVideoReceiveSurface();
releaseCameraSessionInstance(); releaseCameraSessionInstance();
sleep(100); sleep(1000);
console.info('afterAll case'); console.info('afterAll case');
}) })
......
...@@ -574,7 +574,7 @@ export default function cameraSessionZoomRatioTest(surfaceId: any) { ...@@ -574,7 +574,7 @@ export default function cameraSessionZoomRatioTest(surfaceId: any) {
releaseOutputs(); releaseOutputs();
releaseVideoReceiveSurface(); releaseVideoReceiveSurface();
releaseCameraSessionInstance(); releaseCameraSessionInstance();
sleep(100); sleep(1000);
console.info('afterAll case'); console.info('afterAll case');
}) })
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册