提交 6f1d1cad 编写于 作者: S SongChunPeng

fix async

Signed-off-by: NSongChunPeng <songchunpeng@huawei.com>
上级 1e02ff3e
...@@ -96,12 +96,12 @@ export default function cameraEnumTest() { ...@@ -96,12 +96,12 @@ export default function cameraEnumTest() {
*/ */
it('SUB_MULTIMEDIA_CAMERA_ENUM_CAMERATYPE_0100', 2, async function (done) { it('SUB_MULTIMEDIA_CAMERA_ENUM_CAMERATYPE_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ENUM_CAMERATYPE_0100--------------"); console.info("--------------SUB_MULTIMEDIA_CAMERA_ENUM_CAMERATYPE_0100--------------");
expect(camera.CameraType.CAMERA_TYPE_UNSPECIFIED == 0).assertTrue(); console.info("CameraType: "+ JSON.stringify(camera.CameraType));
expect(camera.CameraType.CAMERA_TYPE_DEFAULT == 0).assertTrue();
expect(camera.CameraType.CAMERA_TYPE_WIDE_ANGLE == 1).assertTrue(); expect(camera.CameraType.CAMERA_TYPE_WIDE_ANGLE == 1).assertTrue();
expect(camera.CameraType.CAMERA_TYPE_ULTRA_WIDE == 2).assertTrue(); expect(camera.CameraType.CAMERA_TYPE_ULTRA_WIDE == 2).assertTrue();
expect(camera.CameraType.CAMERA_TYPE_TELEPHOTO == 3).assertTrue(); expect(camera.CameraType.CAMERA_TYPE_TELEPHOTO == 3).assertTrue();
expect(camera.CameraType.CAMERA_TYPE_TRUE_DEPTH == 4).assertTrue(); expect(camera.CameraType.CAMERA_TYPE_TRUE_DEPTH == 4).assertTrue();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ENUM_CAMERATYPE_0100 ends here");
done(); done();
}) })
...@@ -125,28 +125,6 @@ export default function cameraEnumTest() { ...@@ -125,28 +125,6 @@ export default function cameraEnumTest() {
}) })
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ENUM_CAMERAINPUTERRORCODE_0100
* @tc.name : Camera CameraInputErrorCode Eunm
* @tc.desc : Camera CameraInputErrorCode Eunm
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_MULTIMEDIA_CAMERA_ENUM_CAMERAINPUTERRORCODE_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ENUM_CAMERAINPUTERRORCODE_0100--------------");
expect(camera.CameraInputErrorCode.ERROR_UNKNOWN == -1).assertTrue();
expect(camera.CameraInputErrorCode.ERROR_NO_PERMISSION == 0).assertTrue();
expect(camera.CameraInputErrorCode.ERROR_DEVICE_PREEMPTED == 1).assertTrue();
expect(camera.CameraInputErrorCode.ERROR_DEVICE_DISCONNECTED == 2).assertTrue();
expect(camera.CameraInputErrorCode.ERROR_DEVICE_IN_USE == 3).assertTrue();
expect(camera.CameraInputErrorCode.ERROR_DRIVER_ERROR == 4).assertTrue();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ENUM_CAMERAINPUTERRORCODE_0100 ends here");
done();
})
/** /**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ENUM_CAMERAFORMAT_0100 * @tc.number : SUB_MULTIMEDIA_CAMERA_ENUM_CAMERAFORMAT_0100
* @tc.name : Camera CameraFormat Eunm * @tc.name : Camera CameraFormat Eunm
...@@ -260,45 +238,6 @@ export default function cameraEnumTest() { ...@@ -260,45 +238,6 @@ export default function cameraEnumTest() {
}) })
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ENUM_CAPTURESESSIONERRORCODE_0100
* @tc.name : Camera CaptureSessionErrorCode Eunm
* @tc.desc : Camera CaptureSessionErrorCode Eunm
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_MULTIMEDIA_CAMERA_ENUM_CAPTURESESSIONERRORCODE_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ENUM_CAPTURESESSIONERRORCODE_0100--------------");
expect(camera.CaptureSessionErrorCode.ERROR_UNKNOWN == -1).assertTrue();
expect(camera.CaptureSessionErrorCode.ERROR_INSUFFICIENT_RESOURCES == 0).assertTrue();
expect(camera.CaptureSessionErrorCode.ERROR_TIMEOUT == 1).assertTrue();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ENUM_CAPTURESESSIONERRORCODE_0100 ends here");
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ENUM_PREVIEWOUTPUTERRORCODE_0100
* @tc.name : Camera PreviewOutputErrorCode Eunm
* @tc.desc : Camera PreviewOutputErrorCode Eunm
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_MULTIMEDIA_CAMERA_ENUM_PREVIEWOUTPUTERRORCODE_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ENUM_PREVIEWOUTPUTERRORCODE_0100--------------");
expect(camera.PreviewOutputErrorCode.ERROR_UNKNOWN == -1).assertTrue();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ENUM_PREVIEWOUTPUTERRORCODE_0100 ends here");
done();
})
/** /**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ENUM_IMAGEROTATION_0100 * @tc.number : SUB_MULTIMEDIA_CAMERA_ENUM_IMAGEROTATION_0100
* @tc.name : Camera ImageRotation Eunm * @tc.name : Camera ImageRotation Eunm
...@@ -337,48 +276,6 @@ export default function cameraEnumTest() { ...@@ -337,48 +276,6 @@ export default function cameraEnumTest() {
}) })
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ENUM_PHOTOOUTPUTERRORCODE_0100
* @tc.name : Camera PhotoOutputErrorCode Eunm
* @tc.desc : Camera PhotoOutputErrorCode Eunm
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_MULTIMEDIA_CAMERA_ENUM_PHOTOOUTPUTERRORCODE_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ENUM_PHOTOOUTPUTERRORCODE_0100--------------");
expect(camera.PhotoOutputErrorCode.ERROR_UNKNOWN == -1).assertTrue();
expect(camera.PhotoOutputErrorCode.ERROR_DRIVER_ERROR == 0).assertTrue();
expect(camera.PhotoOutputErrorCode.ERROR_INSUFFICIENT_RESOURCES == 1).assertTrue();
expect(camera.PhotoOutputErrorCode.ERROR_TIMEOUT == 2).assertTrue();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ENUM_PHOTOOUTPUTERRORCODE_0100 ends here");
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ENUM_VIDEOOUTPUTERRORCODE_0100
* @tc.name : Camera VideoOutputErrorCode Eunm
* @tc.desc : Camera VideoOutputErrorCode Eunm
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_MULTIMEDIA_CAMERA_ENUM_VIDEOOUTPUTERRORCODE_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ENUM_VIDEOOUTPUTERRORCODE_0100--------------");
expect(camera.VideoOutputErrorCode.ERROR_UNKNOWN == -1).assertTrue();
expect(camera.VideoOutputErrorCode.ERROR_DRIVER_ERROR == 0).assertTrue();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ENUM_VIDEOOUTPUTERRORCODE_0100 ends here");
done();
})
/** /**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ENUM_METADATAOBJECTTYPE_0100 * @tc.number : SUB_MULTIMEDIA_CAMERA_ENUM_METADATAOBJECTTYPE_0100
* @tc.name : Camera MetadataObjectType Eunm * @tc.name : Camera MetadataObjectType Eunm
...@@ -396,21 +293,27 @@ export default function cameraEnumTest() { ...@@ -396,21 +293,27 @@ export default function cameraEnumTest() {
/** /**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ENUM_METADATAOUTPUTERRORCODE_0100 * @tc.number : SUB_MULTIMEDIA_CAMERA_ENUM_CAMERAERRORCODE_0100
* @tc.name : Camera MetadataOutputErrorCode Eunm * @tc.name : Camera CameraErrorCode Eunm
* @tc.desc : Camera MetadataOutputErrorCode Eunm * @tc.desc : Camera CameraErrorCode Eunm
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 2 * @tc.level : Level 2
*/ */
it('SUB_MULTIMEDIA_CAMERA_ENUM_METADATAOUTPUTERRORCODE_0100', 2, async function (done) { it('SUB_MULTIMEDIA_CAMERA_ENUM_CAMERAERRORCODE_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ENUM_METADATAOUTPUTERRORCODE_0100--------------"); console.info("--------------SUB_MULTIMEDIA_CAMERA_ENUM_CAMERAERRORCODE_0100--------------");
expect(camera.MetadataOutputErrorCode.ERROR_UNKNOWN == -1).assertTrue(); expect(camera.CameraErrorCode.INVALID_ARGUMENT == 7400101).assertTrue();
expect(camera.MetadataOutputErrorCode.ERROR_INSUFFICIENT_RESOURCES == 0).assertTrue(); expect(camera.CameraErrorCode.OPERATION_NOT_ALLOWED == 7400102).assertTrue();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ENUM_METADATAOUTPUTERRORCODE_0100 ends here"); expect(camera.CameraErrorCode.SESSION_NOT_CONFIG == 7400103).assertTrue();
expect(camera.CameraErrorCode.SESSION_NOT_RUNNING == 7400104).assertTrue();
expect(camera.CameraErrorCode.SESSION_CONFIG_LOCKED == 7400105).assertTrue();
expect(camera.CameraErrorCode.DEVICE_SETTING_LOCKED == 7400106).assertTrue();
expect(camera.CameraErrorCode.CONFILICT_CAMERA == 7400107).assertTrue();
expect(camera.CameraErrorCode.DEVICE_DISABLED == 7400108).assertTrue();
expect(camera.CameraErrorCode.SERVICE_FATAL_ERROR == 7400201).assertTrue();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ENUM_CAMERAERRORCODE_0100 ends here");
done(); done();
}) })
}) })
} }
\ No newline at end of file
...@@ -69,10 +69,10 @@ export default function CameraInputTest() { ...@@ -69,10 +69,10 @@ export default function CameraInputTest() {
} }
} }
async function getCameraManagerInstance() { function getCameraManagerInstance() {
console.info('Enter getCameraManagerInstance'); console.info('Enter getCameraManagerInstance');
mCameraManager = await cameraObj.getCameraManager(null); mCameraManager = cameraObj.getCameraManager(null);
if (isEmpty(mCameraManager)) { if (isEmpty(mCameraManager)) {
console.info(TAG + "getCameraManager FAILED"); console.info(TAG + "getCameraManager FAILED");
return false; return false;
...@@ -83,10 +83,10 @@ export default function CameraInputTest() { ...@@ -83,10 +83,10 @@ export default function CameraInputTest() {
return true; return true;
} }
async function getCameraSupportDevicesArray() { function getCameraSupportDevicesArray() {
console.info('Enter getCameraSupportDevicesArray'); console.info('Enter getCameraSupportDevicesArray');
mCameraDevicesArray = await mCameraManager.getSupportedCameras(); mCameraDevicesArray = mCameraManager.getSupportedCameras();
/* /*
mCameraManager.getSupportedCameras(async (err, data) => { mCameraManager.getSupportedCameras(async (err, data) => {
console.info(TAG + "Entering getCameraSupportDevicesArray callback"); console.info(TAG + "Entering getCameraSupportDevicesArray callback");
...@@ -118,19 +118,12 @@ export default function CameraInputTest() { ...@@ -118,19 +118,12 @@ export default function CameraInputTest() {
return true; return true;
} }
async function beginCameraSessionConfig() { function beginCameraSessionConfig() {
console.info('Enter beginCameraSessionConfig'); console.info('Enter beginCameraSessionConfig');
mCameraSession.beginConfig(async (err) => { console.info(TAG + "Entering beginConfig start");
if (!err) { mCameraSession.beginConfig();
console.info(TAG + "Entering beginConfig PASSED"); console.info(TAG + "Entering beginConfig end");
} else {
console.info(TAG + "Entering beginConfig FAILED : " + err.message);
}
})
await sleep(30);
console.info('Exit beginCameraSessionConfig'); console.info('Exit beginCameraSessionConfig');
return true; return true;
...@@ -154,11 +147,11 @@ export default function CameraInputTest() { ...@@ -154,11 +147,11 @@ export default function CameraInputTest() {
return true; return true;
} }
async function createCameraSessionInstance() { function createCameraSessionInstance() {
console.info('Enter createCameraSessionInstance'); console.info('Enter createCameraSessionInstance');
try { try {
mCameraSession = await mCameraManager.createCaptureSession(); mCameraSession = mCameraManager.createCaptureSession();
} }
catch { catch {
console.info('createCaptureSession FAILED'); console.info('createCaptureSession FAILED');
...@@ -169,7 +162,7 @@ export default function CameraInputTest() { ...@@ -169,7 +162,7 @@ export default function CameraInputTest() {
return false; return false;
} }
await beginCameraSessionConfig(); beginCameraSessionConfig();
console.info('Exit createCameraSessionInstance'); console.info('Exit createCameraSessionInstance');
...@@ -188,29 +181,16 @@ export default function CameraInputTest() { ...@@ -188,29 +181,16 @@ export default function CameraInputTest() {
return false; return false;
} }
mCameraInput = null; mCameraInput = mCameraManager.createCameraInput(mCameraDevicesArray[idx]);
await mCameraManager.createCameraInput(mCameraDevicesArray[idx]).then((result) => {
console.info('createCameraInput success');
mCameraInput = result;
}).catch((err) => {
console.info('createCameraInput failed, err = ' + err.message);
});
if (isEmpty(mCameraInput)) { if (isEmpty(mCameraInput)) {
console.info(TAG + "createCameraInput FAILED"); console.info(TAG + "createCameraInput FAILED");
return false; return false;
} }
mCameraInput.open(async (err) => { await mCameraInput.open();
console.info(TAG + "Entering mCameraInput open callback");
if (!err) {
console.info(TAG + "Entering mCameraInput open PASSED ");
} else {
console.info(TAG + "Entering mCameraInput open FAILED : " + err.message);
}
})
await sleep(100); sleep(100);
console.info(idx + 'th CameraInput is: ' + mCameraInput); console.info(idx + 'th CameraInput is: ' + mCameraInput);
...@@ -224,7 +204,6 @@ export default function CameraInputTest() { ...@@ -224,7 +204,6 @@ export default function CameraInputTest() {
if (!isEmpty(mCameraInput)) { if (!isEmpty(mCameraInput)) {
await mCameraInput.close(); await mCameraInput.close();
await mCameraInput.release();
} }
console.info('Exit releaseInput'); console.info('Exit releaseInput');
...@@ -232,23 +211,16 @@ export default function CameraInputTest() { ...@@ -232,23 +211,16 @@ export default function CameraInputTest() {
return true; return true;
} }
async function createOutput(idx:any) { function createOutput(idx:any) {
console.info('Enter createOutput'); console.info('Enter createOutput');
let cameraOutputCap = null; let cameraOutputCap = mCameraManager.getSupportedOutputCapability(mCameraDevicesArray[idx]);
await mCameraManager.getSupportedOutputCapability(mCameraDevicesArray[idx]).then((result) => {
console.info('getSupportedOutputCapability success');
cameraOutputCap = result;
}).catch((err) => {
console.info('getSupportedOutputCapability failed, err = ' + err.message);
mPreviewOutput = null;
});
if (!isEmpty(cameraOutputCap)) { if (!isEmpty(cameraOutputCap)) {
if (!isEmpty(cameraOutputCap.previewProfiles)) { if (!isEmpty(cameraOutputCap.previewProfiles)) {
console.info(TAG + "cameraOutputCap.previewProfiles.length: " + cameraOutputCap.previewProfiles.length); console.info(TAG + "cameraOutputCap.previewProfiles.length: " + cameraOutputCap.previewProfiles.length);
for (let i = 0; i < cameraOutputCap.previewProfiles.length; i++) { for (let i = 0; i < cameraOutputCap.previewProfiles.length; i++) {
mPreviewOutput = await mCameraManager.createPreviewOutput(cameraOutputCap.previewProfiles[i], globalThis.surfaceId); mPreviewOutput = mCameraManager.createPreviewOutput(cameraOutputCap.previewProfiles[i], globalThis.surfaceId);
if (!isEmpty(mPreviewOutput)) { if (!isEmpty(mPreviewOutput)) {
break; break;
} }
...@@ -271,7 +243,6 @@ export default function CameraInputTest() { ...@@ -271,7 +243,6 @@ export default function CameraInputTest() {
console.info('Enter releaseOutput'); console.info('Enter releaseOutput');
if (!isEmpty(mPreviewOutput)) { if (!isEmpty(mPreviewOutput)) {
await mPreviewOutput.stop();
await mPreviewOutput.release(); await mPreviewOutput.release();
} }
...@@ -284,18 +255,18 @@ export default function CameraInputTest() { ...@@ -284,18 +255,18 @@ export default function CameraInputTest() {
console.info(TAG + "Enter startCameraSession"); console.info(TAG + "Enter startCameraSession");
await createInput(idx); await createInput(idx);
await createOutput(idx); createOutput(idx);
await sleep(1); await sleep(1);
if (!isEmpty(mCameraInput)) { if (!isEmpty(mCameraInput)) {
console.info(TAG + "Start to addInput"); console.info(TAG + "Start to addInput");
await mCameraSession.addInput(mCameraInput); mCameraSession.addInput(mCameraInput);
} }
if (!isEmpty(mPreviewOutput)) { if (!isEmpty(mPreviewOutput)) {
console.info(TAG + "Start to addOutput mPreviewOutput"); console.info(TAG + "Start to addOutput mPreviewOutput");
await mCameraSession.addOutput(mPreviewOutput); mCameraSession.addOutput(mPreviewOutput);
} }
await sleep(1); await sleep(1);
...@@ -312,12 +283,12 @@ export default function CameraInputTest() { ...@@ -312,12 +283,12 @@ export default function CameraInputTest() {
if (!isEmpty(mCameraInput)) { if (!isEmpty(mCameraInput)) {
console.info(TAG + "Start to removeInput input"); console.info(TAG + "Start to removeInput input");
await mCameraSession.removeInput(mCameraInput); mCameraSession.removeInput(mCameraInput);
} }
if (!isEmpty(mPreviewOutput)) { if (!isEmpty(mPreviewOutput)) {
console.info(TAG + "Start to removeOutput mPreviewOutput"); console.info(TAG + "Start to removeOutput mPreviewOutput");
await mCameraSession.removeOutput(mPreviewOutput); mCameraSession.removeOutput(mPreviewOutput);
} }
await releaseInput(); await releaseInput();
...@@ -334,9 +305,9 @@ export default function CameraInputTest() { ...@@ -334,9 +305,9 @@ export default function CameraInputTest() {
await getPermission(); await getPermission();
sleep(1000); sleep(1000);
await driveFn(); await driveFn();
await getCameraManagerInstance(); getCameraManagerInstance();
await getCameraSupportDevicesArray(); getCameraSupportDevicesArray();
await createCameraSessionInstance(); createCameraSessionInstance();
console.info('beforeAll case'); console.info('beforeAll case');
}); });
beforeEach(function () { beforeEach(function () {
...@@ -410,32 +381,32 @@ export default function CameraInputTest() { ...@@ -410,32 +381,32 @@ export default function CameraInputTest() {
}); });
/** /**
* @tc.number : SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_RELEASE_CALLBACK_0100 * @tc.number : SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_CALLBACK_0100
* @tc.name : open/close/release Camera with cameraInput callback api * @tc.name : open/close Camera with cameraInput callback api
* @tc.desc : open/close/release Camera with cameraInput callback api * @tc.desc : open/close Camera with cameraInput callback api
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_RELEASE_CALLBACK_0100', 0, async function (done) { it('SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_CALLBACK_0100', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_RELEASE_CALLBACK_0100--------------"); console.info("--------------SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_CALLBACK_0100--------------");
if (isEmpty(mCameraManager)) { if (isEmpty(mCameraManager)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_RELEASE_CALLBACK_0100 cameraManager == null || undefined"); console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_CALLBACK_0100 cameraManager == null || undefined");
expect().assertFail(); expect().assertFail();
} else { } else {
let camerasArray = mCameraDevicesArray; let camerasArray = mCameraDevicesArray;
for (let i = 0; i < camerasArray.length; i++) { for (let i = 0; i < camerasArray.length; i++) {
let successFlag = false; let successFlag = false;
console.info(TAG + "Entering createCameraInput with camera: " + camerasArray[i].cameraId); console.info(TAG + "Entering createCameraInput with camera: " + camerasArray[i].cameraId);
await mCameraManager.createCameraInput(camerasArray[i]).then(async (cameraInput) => { let cameraInput = mCameraManager.createCameraInput(camerasArray[i]);
expect(isEmpty(cameraInput)).assertFalse(); expect(isEmpty(cameraInput)).assertFalse();
await cameraInput.open(async (err) => { await cameraInput.open(async (err) => {
if (!err) { if (!err) {
successFlag = true; successFlag = true;
console.info(TAG + " SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_RELEASE_CALLBACK_0100 PASSED open with CameraID :" + camerasArray[i].cameraId); console.info(TAG + " SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_CALLBACK_0100 PASSED open with CameraID :" + camerasArray[i].cameraId);
} else { } else {
successFlag = false; successFlag = false;
console.info(TAG + " SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_RELEASE_CALLBACK_0100 open FAILED: " + err.message); console.info(TAG + " SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_CALLBACK_0100 open FAILED: " + err.message);
} }
}); });
await sleep(400); await sleep(400);
...@@ -443,97 +414,67 @@ export default function CameraInputTest() { ...@@ -443,97 +414,67 @@ export default function CameraInputTest() {
await cameraInput.close(async (err) => { await cameraInput.close(async (err) => {
if (!err) { if (!err) {
successFlag = true; successFlag = true;
console.info(TAG + " SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_RELEASE_CALLBACK_0100 PASSED close with CameraID :" + camerasArray[i].cameraId); console.info(TAG + " SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_CALLBACK_0100 PASSED close with CameraID :" + camerasArray[i].cameraId);
} else {
successFlag = false;
console.info(TAG + " SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_RELEASE_CALLBACK_0100 close FAILED: " + err.message);
}
});
await sleep(100);
successFlag = false;
await cameraInput.release(async (err) => {
if (!err) {
successFlag = true;
console.info(TAG + " SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_RELEASE_CALLBACK_0100 PASSED release with CameraID :" + camerasArray[i].cameraId);
} else { } else {
successFlag = false; successFlag = false;
console.info(TAG + " SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_RELEASE_CALLBACK_0100 release FAILED: " + err.message); console.info(TAG + " SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_CALLBACK_0100 close FAILED: " + err.message);
} }
}); });
await sleep(100); await sleep(100);
expect(successFlag).assertEqual(true); expect(successFlag).assertEqual(true);
}).catch((err) => {
expect().assertFail();
console.info(TAG + " Failed To create cameraInput cameraId: " + camerasArray[i].cameraId + +JSON.stringify(err));
});
} }
} }
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_RELEASE_CALLBACK_0100 ends here"); console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_CALLBACK_0100 ends here");
await sleep(1000); await sleep(1000);
done(); done();
}); });
/** /**
* @tc.number : SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_RELEASE_PROMISE_0100 * @tc.number : SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_PROMISE_0100
* @tc.name : open/close/release Camera with cameraInput promise api * @tc.name : open/close Camera with cameraInput promise api
* @tc.desc : open/close/release Camera with cameraInput promise api * @tc.desc : open/close Camera with cameraInput promise api
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_RELEASE_PROMISE_0100', 0, async function (done) { it('SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_PROMISE_0100', 0, async function (done) {
let functionTag = "SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_RELEASE_PROMISE_0100"; let functionTag = "SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_PROMISE_0100";
console.info(functionTag); console.info(functionTag);
if (isEmpty(mCameraManager)) { if (isEmpty(mCameraManager)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_RELEASE_PROMISE_0100 cameraManager == null || undefined"); console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_PROMISE_0100 cameraManager == null || undefined");
expect().assertFail(); expect().assertFail();
} else { } else {
let camerasArray = mCameraDevicesArray; let camerasArray = mCameraDevicesArray;
for (let i = 0; i < camerasArray.length; i++) { for (let i = 0; i < camerasArray.length; i++) {
let successFlag = false; let successFlag = false;
console.info(TAG + functionTag + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_RELEASE_PROMISE_0100 createCameraInput with camera: " + camerasArray[i].cameraId); console.info(TAG + functionTag + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_PROMISE_0100 createCameraInput with camera: " + camerasArray[i].cameraId);
mCameraManager.createCameraInput(camerasArray[i], async (err, cameraInput) => { let cameraInput = mCameraManager.createCameraInput(camerasArray[i]);
if (!err) {
expect(isEmpty(cameraInput)).assertFalse(); expect(isEmpty(cameraInput)).assertFalse();
console.info(TAG + functionTag + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_RELEASE_PROMISE_0100 cameraInput open with camera: " + camerasArray[i].cameraId); console.info(TAG + functionTag + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_PROMISE_0100 cameraInput open with camera: " + camerasArray[i].cameraId);
await cameraInput.open().then(async () => { await cameraInput.open().then(async () => {
successFlag = true; successFlag = true;
console.info(TAG + functionTag + " SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_RELEASE_PROMISE_0100 PASSED open with CameraID :" + camerasArray[i].cameraId); console.info(TAG + functionTag + " SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_PROMISE_0100 PASSED open with CameraID :" + camerasArray[i].cameraId);
}).catch((err) => { }).catch((err) => {
successFlag = false; successFlag = false;
console.info(TAG + functionTag + " SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_RELEASE_PROMISE_0100 open FAILED: " + err.message); console.info(TAG + functionTag + " SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_PROMISE_0100 open FAILED: " + err.message);
}); });
await sleep(400); await sleep(400);
successFlag = false; successFlag = false;
await cameraInput.close().then(async () => { await cameraInput.close().then(async () => {
successFlag = true; successFlag = true;
console.info(TAG + functionTag + " SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_RELEASE_PROMISE_0100 PASSED close with CameraID :" + camerasArray[i].cameraId); console.info(TAG + functionTag + " SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_PROMISE_0100 PASSED close with CameraID :" + camerasArray[i].cameraId);
}).catch((err) => {
successFlag = false;
console.info(TAG + functionTag + " SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_RELEASE_PROMISE_0100 close FAILED: " + err.message);
});
await sleep(100);
successFlag = false;
await cameraInput.release().then(async () => {
successFlag = true;
console.info(TAG + functionTag + " SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_RELEASE_PROMISE_0100 PASSED release with CameraID :" + camerasArray[i].cameraId);
}).catch((err) => { }).catch((err) => {
successFlag = false; successFlag = false;
console.info(TAG + functionTag + " SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_RELEASE_PROMISE_0100 release FAILED: " + err.message); console.info(TAG + functionTag + " SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_PROMISE_0100 close FAILED: " + err.message);
}); });
await sleep(100); await sleep(100);
expect(successFlag).assertEqual(true); expect(successFlag).assertEqual(true);
} else {
expect().assertFail();
console.info(TAG + functionTag + " FAILED: " + err.message);
}
});
await sleep(600); await sleep(600);
} }
//await sleep(400 * camerasArray.length); //await sleep(400 * camerasArray.length);
} }
console.info(TAG + functionTag + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_RELEASE_PROMISE_0100 ends here"); console.info(TAG + functionTag + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_PROMISE_0100 ends here");
done(); done();
}); });
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册