diff --git a/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/Camera.test.ets b/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/Camera.test.ets index 7b12db6095dfb5b40003306b54020e4bd555a53e..71881c92cfc51444302b95876ec2bffa9bd978ca 100755 --- a/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/Camera.test.ets +++ b/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/Camera.test.ets @@ -23,6 +23,7 @@ import cameraSessionVideoStabilizationTest from './CameraSessionVideoStabilizati import cameraSessionBaseTest from './CameraSessionBaseTest.test.ets' import cameraInputTest from './CameraInputTest.test.ets' import cameraManagerTest from './CameraManagerTest.test.ets' +import cameraEnumTest from './CameraEnumTest.test.ets' let TAG = 'CameraModuleTest: ' @@ -39,4 +40,5 @@ export default function cameraKit(surfaceId: any) { cameraSessionVideoStabilizationTest(surfaceId) cameraSessionBaseTest(surfaceId) cameraManagerTest(surfaceId) + cameraEnumTest(surfaceId) } \ No newline at end of file diff --git a/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraEnumTest.test.ets b/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraEnumTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..81c136e93f39c2f0c62c8919f63bb33b9625c61f --- /dev/null +++ b/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraEnumTest.test.ets @@ -0,0 +1,416 @@ +/* + * 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 camera from '@ohos.multimedia.camera'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; + +const TAG = "CameraEnumTest: "; + +export default function cameraEnumTest(surfaceId: any) { + + function isEmpty(data) { + if (data == null || data == undefined) { + return true; + } + return false; + } + + describe('CameraEnumTest', function () { + console.info(TAG + '----------CameraEnumTest--------------'); + + beforeAll(async function () { + console.info('beforeAll case'); + }) + + beforeEach(function () { + console.info('beforeEach case'); + }) + + afterEach(async function () { + console.info('afterEach case'); + }) + + afterAll(function () { + console.info('afterAll case'); + }) + + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_ENUM_CAMERASTATUS_0100 + * @tc.name : Camera CameraStatus Eunm + * @tc.desc : Camera CameraStatus Eunm + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_CAMERA_ENUM_CAMERASTATUS_0100', 2, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_ENUM_CAMERASTATUS_0100--------------"); + expect(camera.CameraStatus.CAMERA_STATUS_APPEAR == 0).assertTrue(); + expect(camera.CameraStatus.CAMERA_STATUS_DISAPPEAR == 1).assertTrue(); + expect(camera.CameraStatus.CAMERA_STATUS_AVAILABLE == 2).assertTrue(); + expect(camera.CameraStatus.CAMERA_STATUS_UNAVAILABLE == 3).assertTrue(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ENUM_CAMERASTATUS_0100 ends here"); + done(); + }) + + + + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_ENUM_CAMERAPOSITION_0100 + * @tc.name : Camera CameraPosition Eunm + * @tc.desc : Camera CameraPosition Eunm + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_CAMERA_ENUM_CAMERAPOSITION_0100', 2, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_ENUM_CAMERAPOSITION_0100--------------"); + expect(camera.CameraPosition.CAMERA_POSITION_UNSPECIFIED == 0).assertTrue(); + expect(camera.CameraPosition.CAMERA_POSITION_BACK == 1).assertTrue(); + expect(camera.CameraPosition.CAMERA_POSITION_FRONT == 2).assertTrue(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ENUM_CAMERAPOSITION_0100 ends here"); + done(); + }) + + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_ENUM_CAMERATYPE_0100 + * @tc.name : Camera CameraType Eunm + * @tc.desc : Camera CameraType Eunm + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_CAMERA_ENUM_CAMERATYPE_0100', 2, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_ENUM_CAMERATYPE_0100--------------"); + expect(camera.CameraType.CAMERA_TYPE_UNSPECIFIED == 0).assertTrue(); + expect(camera.CameraType.CAMERA_TYPE_WIDE_ANGLE == 1).assertTrue(); + expect(camera.CameraType.CAMERA_TYPE_ULTRA_WIDE == 2).assertTrue(); + expect(camera.CameraType.CAMERA_TYPE_TELEPHOTO == 3).assertTrue(); + expect(camera.CameraType.CAMERA_TYPE_TRUE_DEPTH == 4).assertTrue(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ENUM_CAMERATYPE_0100 ends here"); + done(); + }) + + + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_ENUM_CONNECTIONTYPE_0100 + * @tc.name : Camera ConnectionType Eunm + * @tc.desc : Camera ConnectionType Eunm + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_CAMERA_ENUM_CONNECTIONTYPE_0100', 2, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_ENUM_CONNECTIONTYPE_0100--------------"); + expect(camera.ConnectionType.CAMERA_CONNECTION_BUILT_IN == 0).assertTrue(); + expect(camera.ConnectionType.CAMERA_CONNECTION_USB_PLUGIN == 1).assertTrue(); + expect(camera.ConnectionType.CAMERA_CONNECTION_REMOTE == 2).assertTrue(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ENUM_CONNECTIONTYPE_0100 ends here"); + done(); + }) + + + + /** + * @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.name : Camera CameraFormat Eunm + * @tc.desc : Camera CameraFormat Eunm + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_CAMERA_ENUM_CAMERAFORMAT_0100', 2, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_ENUM_CAMERAFORMAT_0100--------------"); + expect(camera.CameraFormat.CAMERA_FORMAT_RGBA_8888 == 3).assertTrue(); + expect(camera.CameraFormat.CAMERA_FORMAT_YUV_420_SP == 1003).assertTrue(); + expect(camera.CameraFormat.CAMERA_FORMAT_JPEG == 2000).assertTrue(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ENUM_CAMERAFORMAT_0100 ends here"); + done(); + }) + + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_ENUM_FLASHMODE_0100 + * @tc.name : Camera FlashMode Eunm + * @tc.desc : Camera FlashMode Eunm + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_CAMERA_ENUM_FLASHMODE_0100', 2, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_ENUM_FLASHMODE_0100--------------"); + expect(camera.FlashMode.FLASH_MODE_CLOSE == 0).assertTrue(); + expect(camera.FlashMode.FLASH_MODE_OPEN == 1).assertTrue(); + expect(camera.FlashMode.FLASH_MODE_AUTO == 2).assertTrue(); + expect(camera.FlashMode.FLASH_MODE_ALWAYS_OPEN == 3).assertTrue(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ENUM_FLASHMODE_0100 ends here"); + done(); + }) + + + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_ENUM_EXPOSUREMODE_0100 + * @tc.name : Camera ExposureMode Eunm + * @tc.desc : CameraExposureMode Eunm + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_CAMERA_ENUM_EXPOSUREMODE_0100', 2, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_ENUM_EXPOSUREMODE_0100--------------"); + expect(camera.ExposureMode.EXPOSURE_MODE_LOCKED == 0).assertTrue(); + expect(camera.ExposureMode.EXPOSURE_MODE_AUTO == 1).assertTrue(); + expect(camera.ExposureMode.EXPOSURE_MODE_CONTINUOUS_AUTO == 2).assertTrue(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ENUM_EXPOSUREMODE_0100 ends here"); + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_ENUM_FOCUSMODE_0100 + * @tc.name : Camera FocusMode Eunm + * @tc.desc : Camera FocusMode Eunm + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_CAMERA_ENUM_FOCUSMODE_0100', 2, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_ENUM_FOCUSMODE_0100--------------"); + expect(camera.FocusMode.FOCUS_MODE_MANUAL == 0).assertTrue(); + expect(camera.FocusMode.FOCUS_MODE_CONTINUOUS_AUTO == 1).assertTrue(); + expect(camera.FocusMode.FOCUS_MODE_AUTO == 2).assertTrue(); + expect(camera.FocusMode.FOCUS_MODE_LOCKED == 3).assertTrue(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ENUM_FOCUSMODE_0100 ends here"); + done(); + }) + + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_ENUM_FOCUSSTATE_0100 + * @tc.name : Camera FocusState Eunm + * @tc.desc : Camera FocusState Eunm + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_CAMERA_ENUM_FOCUSSTATE_0100', 2, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_ENUM_FOCUSSTATE_0100--------------"); + expect(camera.FocusState.FOCUS_STATE_SCAN == 0).assertTrue(); + expect(camera.FocusState.FOCUS_STATE_FOCUSED == 1).assertTrue(); + expect(camera.FocusState.FOCUS_STATE_UNFOCUSED == 2).assertTrue(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ENUM_FOCUSSTATE_0100 ends here"); + done(); + }) + + + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_ENUM_VIDEOSTABILIZATIONMODE_0100 + * @tc.name : Camera VideoStabilizationMode Eunm + * @tc.desc : Camera VideoStabilizationMode Eunm + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_CAMERA_ENUM_VIDEOSTABILIZATIONMODE_0100', 2, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_ENUM_VIDEOSTABILIZATIONMODE_0100--------------"); + expect(camera.VideoStabilizationMode.OFF == 0).assertTrue(); + expect(camera.VideoStabilizationMode.LOW == 1).assertTrue(); + expect(camera.VideoStabilizationMode.MIDDLE == 2).assertTrue(); + expect(camera.VideoStabilizationMode.HIGH == 3).assertTrue(); + expect(camera.VideoStabilizationMode.AUTO == 4).assertTrue(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ENUM_VIDEOSTABILIZATIONMODE_0100 ends here"); + done(); + }) + + + + + /** + * @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.name : Camera ImageRotation Eunm + * @tc.desc : Camera ImageRotation Eunm + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_CAMERA_ENUM_IMAGEROTATION_0100', 2, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_ENUM_IMAGEROTATION_0100--------------"); + expect(camera.ImageRotation.ROTATION_0 == 0).assertTrue(); + expect(camera.ImageRotation.ROTATION_90 == 90).assertTrue(); + expect(camera.ImageRotation.ROTATION_180 == 180).assertTrue(); + expect(camera.ImageRotation.ROTATION_270 == 270).assertTrue(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ENUM_IMAGEROTATION_0100 ends here"); + done(); + }) + + + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_ENUM_QUALITYLEVEL_0100 + * @tc.name : Camera QualityLevel Eunm + * @tc.desc : Camera QualityLevel Eunm + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_CAMERA_ENUM_QUALITYLEVEL_0100', 2, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_ENUM_QUALITYLEVEL_0100--------------"); + expect(camera.QualityLevel.QUALITY_LEVEL_HIGH == 0).assertTrue(); + expect(camera.QualityLevel.QUALITY_LEVEL_MEDIUM == 1).assertTrue(); + expect(camera.QualityLevel.QUALITY_LEVEL_LOW == 2).assertTrue(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ENUM_QUALITYLEVEL_0100 ends here"); + done(); + }) + + + + + /** + * @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.name : Camera MetadataObjectType Eunm + * @tc.desc : Camera MetadataObjectType Eunm + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_CAMERA_ENUM_METADATAOBJECTTYPE_0100', 2, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_ENUM_METADATAOBJECTTYPE_0100--------------"); + expect(camera.MetadataObjectType.FACE_DETECTION == 0).assertTrue(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ENUM_METADATAOBJECTTYPE_0100 ends here"); + done(); + }) + + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_ENUM_METADATAOUTPUTERRORCODE_0100 + * @tc.name : Camera MetadataOutputErrorCode Eunm + * @tc.desc : Camera MetadataOutputErrorCode Eunm + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_CAMERA_ENUM_METADATAOUTPUTERRORCODE_0100', 2, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_ENUM_METADATAOUTPUTERRORCODE_0100--------------"); + expect(camera.MetadataOutputErrorCode.ERROR_UNKNOWN == -1).assertTrue(); + expect(camera.MetadataOutputErrorCode.ERROR_INSUFFICIENT_RESOURCES == 0).assertTrue(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ENUM_METADATAOUTPUTERRORCODE_0100 ends here"); + done(); + }) + + + }) +} \ No newline at end of file diff --git a/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraInputTest.test.ets b/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraInputTest.test.ets index b3d17c29fa6cbf30b49e46cb27819bfbc06db4ae..65261c37a45df91f9490c16d261006df77d0adfa 100755 --- a/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraInputTest.test.ets +++ b/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraInputTest.test.ets @@ -23,49 +23,27 @@ const TAG = "CameraInputTest: "; // Define global variables let mCameraManager; -let surfaceId1; let mCameraDevicesArray; +let mCameraSession; + +let mCameraNum; + +let mCameraInput; +let mPreviewOutput; export default function CameraInputTest(surfaceId) { - async function getImageReceiverSurfaceId() { - console.log(TAG + 'Entering create Image receiver'); - let receiver = image.createImageReceiver(640, 480, 4, 8); - console.log(TAG + 'before receiver check'); - if (receiver !== undefined) { - console.log(TAG + 'Receiver is ok'); - surfaceId1 = await receiver.getReceivingSurfaceId(); - console.log(TAG + 'Received id: ' + JSON.stringify(surfaceId1)); - } else { - console.log(TAG + 'Receiver is not ok'); - } + function sleep(ms) { + console.info(TAG + "Entering sleep -> Promise constructor"); + return new Promise(resolve => setTimeout(resolve, ms)); } - const sleep = (delay) => new Promise(resolve => setTimeout(resolve, delay)); + function isEmpty(data) { if (data == null || data == undefined) { return true; } return false; } - async function getCameraInputTestInstance() { - mCameraManager = await cameraObj.getCameraManager(null); - if (isEmpty(mCameraManager)) { - console.info(TAG + "getCameraManager FAILED"); - return false; - } - return true; - } - async function getSupportedCamerasArray() { - if (isEmpty(mCameraManager)) { - console.info(TAG + "getCameraManager FAILED"); - } else { - mCameraDevicesArray = await mCameraManager.getSupportedCameras(); - console.info(TAG + "getSupportedCamerasArray start " + mCameraDevicesArray.length); - if (mCameraDevicesArray != null && mCameraDevicesArray.length > 0) { - console.info(TAG + "mCameraDevicesArray is not null"); - } - } - console.info(TAG + "getSupportedCamerasArray end"); - } + async function applyPermission() { let appInfo = await bundle.getApplicationInfo('com.open.harmony.multimedia.cameratest', 0, 100); let atManager = abilityAccessCtrl.createAtManager(); @@ -77,6 +55,9 @@ export default function CameraInputTest(surfaceId) { let permissionName3 = 'ohos.permission.MEDIA_LOCATION'; let permissionName4 = 'ohos.permission.READ_MEDIA'; let permissionName5 = 'ohos.permission.WRITE_MEDIA'; + let permissionName6 = 'ohos.permission.START_ABILIIES_FROM_BACKGROUND'; + let permissionName7 = 'ohos.permission.START_INVISIBLE_ABILITY'; + let permissionName8 = 'ohos.permission.ABILITY_BACKGROUND_COMMUNICATION'; await atManager.grantUserGrantedPermission(tokenID, permissionName1, 1).then((result) => { console.info('[permission] case grantUserGrantedPermission success :' + result); }).catch((err) => { @@ -102,174 +83,571 @@ export default function CameraInputTest(surfaceId) { }).catch((err) => { console.info('[permission] case grantUserGrantedPermission failed :' + err); }); + await atManager.grantUserGrantedPermission(tokenID, permissionName6, 1).then((result) => { + console.info('[permission] case grantUserGrantedPermission success :' + result); + }).catch((err) => { + console.info('[permission] case grantUserGrantedPermission failed :' + err); + }); + await atManager.grantUserGrantedPermission(tokenID, permissionName7, 1).then((result) => { + console.info('[permission] case grantUserGrantedPermission success :' + result); + }).catch((err) => { + console.info('[permission] case grantUserGrantedPermission failed :' + err); + }); + await atManager.grantUserGrantedPermission(tokenID, permissionName8, 1).then((result) => { + console.info('[permission] case grantUserGrantedPermission success :' + result); + }).catch((err) => { + console.info('[permission] case grantUserGrantedPermission failed :' + err); + }); } else { console.info('[permission] case apply permission failed, createAtManager failed'); } } + + async function getCameraManagerInstance() { + console.info('Enter getCameraManagerInstance'); -describe('CameraInputTest', function () { - console.info(TAG + '----------CameraInputTest--------------'); - beforeAll(async function () { - await applyPermission(); - await getCameraInputTestInstance(); - await getSupportedCamerasArray(); - console.info('beforeAll case'); - }); - beforeEach(function () { - sleep(1000); - console.info('beforeEach case'); - }); - afterEach(async function () { - console.info('afterEach case'); - }); - afterAll(function () { - console.info('afterAll case'); - }); - - /** - * @tc.number : SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_ERROR_0100 - * @tc.name : callback Camera with cameraInput on api - * @tc.desc : callback Camera with cameraInput on api - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_ERROR_0100', 0, async function (done) { - console.info("--------------SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_ERROR_0100--------------"); + mCameraManager = await cameraObj.getCameraManager(null); if (isEmpty(mCameraManager)) { - console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_ERROR_0100 cameraManager == null || undefined"); - expect().assertFail(); - } else { - let camerasArray = mCameraDevicesArray; - for (let i = 0; i < camerasArray.length; i++) { - let successFlag = true; - console.info(TAG + "Entering createCameraInput with camera: " + camerasArray[i].cameraId); - await mCameraManager.createCameraInput(camerasArray[i]).then(async (cameraInput) => { - await cameraInput.on("error", (cameraInputError) => { - console.log(`Camera input error code: ${cameraInputError.code}`); - }); - 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 + "getCameraManager FAILED"); + return false; + } + + console.info('Exit getCameraManagerInstance'); + + return true; + } + + async function getCameraSupportDevicesArray() { + console.info('Enter getCameraSupportDevicesArray'); + + mCameraDevicesArray = await mCameraManager.getSupportedCameras(); + /* + mCameraManager.getSupportedCameras(async (err, data) => { + console.info(TAG + "Entering getCameraSupportDevicesArray callback"); + if (!err) { + if (data != null || data != undefined) { + mCameraDevicesArray = data; + console.info(TAG + "Entering getCameraSupportDevicesArray PASSED with CameraDevicesArray is: " + data); + } else { + console.info(TAG + "Entering getCameraSupportDevicesArray FAILED with CameraDevicesArray is: " + data); + } + } else { + console.info(TAG + "Entering getCameraSupportDevicesArray FAILED : " + err.message); } + }) + await sleep(3000); + */ + if (isEmpty(mCameraDevicesArray)) { + console.info(TAG + "getSupportedCameras FAILED"); + return false; } - console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_ERROR_0100 ends here"); - await sleep(1000); - done(); - }); - /** - * @tc.number : SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_RELEASE_CALLBACK_0100 - * @tc.name : open/close/release Camera with cameraInput callback api - * @tc.desc : open/close/release Camera with cameraInput callback api - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_RELEASE_CALLBACK_0100', 0, async function (done) { - console.info("--------------SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_RELEASE_CALLBACK_0100--------------"); - if (isEmpty(mCameraManager)) { - console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_RELEASE_CALLBACK_0100 cameraManager == null || undefined"); - expect().assertFail(); - } else { - let camerasArray = mCameraDevicesArray; - for (let i = 0; i < camerasArray.length; i++) { - let successFlag = true; - console.info(TAG + "Entering createCameraInput with camera: " + camerasArray[i].cameraId); - await mCameraManager.createCameraInput(camerasArray[i]).then(async (cameraInput) => { - expect(isEmpty(cameraInput)).assertFalse(); - await cameraInput.open(async (err) => { + + //mCameraNum = 1; + mCameraNum = mCameraDevicesArray.length; + + console.info(TAG + "getCameraSupportDevicesArray is: " + mCameraNum); + + console.info('Exit getCameraSupportDevicesArray'); + + return true; + } + + async function beginCameraSessionConfig() { + console.info('Enter beginCameraSessionConfig'); + + mCameraSession.beginConfig(async (err) => { + if (!err) { + console.info(TAG + "Entering beginConfig PASSED"); + } else { + console.info(TAG + "Entering beginConfig FAILED : " + err.message); + } + }) + + await sleep(10); + + console.info('Exit beginCameraSessionConfig'); + + return true; + } + + async function commitCameraSessionConfig() { + console.info('Enter commitCameraSessionConfig'); + + mCameraSession.commitConfig(async (err) => { + if (!err) { + console.info(TAG + "Entering commitConfig PASSED"); + } else { + console.info(TAG + "Entering commitConfig FAILED : " + err.message); + } + }) + + await sleep(500); + + console.info('Exit commitCameraSessionConfig'); + + return true; + } + + async function createCameraSessionInstance() { + console.info('Enter createCameraSessionInstance'); + + try { + mCameraSession = await mCameraManager.createCaptureSession(); + } + catch { + console.info('createCaptureSession FAILED'); + } + + if (isEmpty(mCameraSession)) { + console.info(TAG + "createCaptureSession FAILED"); + return false; + } + + await beginCameraSessionConfig(); + + console.info('Exit createCameraSessionInstance'); + + return true; + } + + async function releaseCameraSessionInstance() { + await mCameraSession.release(); + } + + async function createInput(idx:any) { + console.info('Enter createInput'); + + if (isEmpty(mCameraDevicesArray)) { + console.info(TAG + "Entering createInputs FAILED with NoCamera"); + return false; + } + + mCameraInput = await mCameraManager.createCameraInput(mCameraDevicesArray[idx]); + if (isEmpty(mCameraInput)) { + console.info(TAG + "createCameraInput FAILED"); + return false; + } + + mCameraInput.open(async (err) => { + 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); + + console.info(idx + 'th CameraInput is: ' + mCameraInput); + + console.info('Exit createInput'); + + return true; + } + + async function releaseInput() { + console.info('Enter releaseInput'); + + if (!isEmpty(mCameraInput)) { + await mCameraInput.close(); + await mCameraInput.release(); + } + + console.info('Exit releaseInput'); + + return true; + } + + async function createOutput(idx:any) { + console.info('Enter createOutput'); + + let cameraOutputCap = await mCameraManager.getSupportedOutputCapability(mCameraDevicesArray[idx]); + if (!isEmpty(cameraOutputCap.previewProfiles)) { + console.info(TAG + "cameraOutputCap.previewProfiles.length: " + cameraOutputCap.previewProfiles.length); + for (let i = 0; i < cameraOutputCap.previewProfiles.length; i++) { + mPreviewOutput = await mCameraManager.createPreviewOutput(cameraOutputCap.previewProfiles[i], surfaceId); + if (!isEmpty(mPreviewOutput)) { + break; + } + } + + if (isEmpty(mPreviewOutput)) { + console.info(TAG + "createPreviewOutput FAILED"); + } + + console.info(TAG + "createPreviewOutput: " + mPreviewOutput); + } + + console.info('Exit createOutputs'); + + return true; + } + + async function releaseOutput() { + console.info('Enter releaseOutput'); + + if (!isEmpty(mPreviewOutput)) { + await mPreviewOutput.stop(); + await mPreviewOutput.release(); + } + + console.info('Exit releaseOutput'); + + return true; + } + + async function startCameraSession(idx:any) { + console.info(TAG + "Enter startCameraSession"); + + await createInput(idx); + await createOutput(idx); + + await sleep(1); + + if (!isEmpty(mCameraInput)) { + console.info(TAG + "Start to addInput"); + await mCameraSession.addInput(mCameraInput); + } + + if (!isEmpty(mPreviewOutput)) { + console.info(TAG + "Start to addOutput mPreviewOutput"); + await mCameraSession.addOutput(mPreviewOutput); + } + + await sleep(1); + + await commitCameraSessionConfig(); + + console.info(TAG + "Exit startCameraSession"); + + return true; + } + + async function stopCameraSession() { + console.info(TAG + "Enter stopCameraSession"); + + if (!isEmpty(mCameraInput)) { + console.info(TAG + "Start to removeInput input"); + await mCameraSession.removeInput(mCameraInput); + } + + if (!isEmpty(mPreviewOutput)) { + console.info(TAG + "Start to removeOutput mPreviewOutput"); + await mCameraSession.removeOutput(mPreviewOutput); + } + + await releaseInput(); + await releaseOutput(); + + console.info(TAG + "Exit stopCameraSession"); + + return true; + } + + describe('CameraInputTest', function () { + console.info(TAG + '----------CameraInputTest--------------'); + beforeAll(async function () { + await applyPermission(); + await getCameraManagerInstance(); + await getCameraSupportDevicesArray(); + await createCameraSessionInstance(); + console.info('beforeAll case'); + }); + beforeEach(function () { + sleep(1000); + console.info('beforeEach case'); + }); + afterEach(async function () { + console.info('afterEach case'); + }); + afterAll(function () { + releaseCameraSessionInstance(); + console.info('afterAll case'); + }); + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_ERROR_0100 + * @tc.name : camera status callback on CameraInput async api for error + * @tc.desc : camera status callback on CameraInput async api for error + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_ERROR_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_ERROR_0100--------------"); + + if (mCameraNum == 0) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_ERROR_0100 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraNum; i++) { + let nfyFlag = false; + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_ERROR_0100 start for camera[" + i + "]"); + + await startCameraSession(i); + + mCameraInput.on('error', async (err, data) => { if (!err) { - console.info(TAG + "PASSED open with CameraID :" + camerasArray[i].cameraId); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_ERROR_0100 callback"); + if (data != null || data != undefined) { + console.info(TAG + "SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_ERROR_0100 PASSED: " + data); + nfyFlag = true; + } } else { - successFlag = false; - console.info(TAG + "open FAILED: " + err.message); + expect().assertFail(); + console.info(TAG + "SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_ERROR_0100 FAILED: " + err.message); } - }); - await sleep(400); - await cameraInput.close(async (err) => { + await sleep(1); + }) + + await sleep(3000); + + if (nfyFlag == false) { + //expect().assertFail(); + //console.info(TAG + "SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_ERROR_0100 FAILED without any nofity!"); + } + + await beginCameraSessionConfig(); + await stopCameraSession(); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_ERROR_0100 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_ERROR_0100 ends here"); + done(); + } + }); + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_FOCUS_STATE_CHANGE_0100 + * @tc.name : camera status callback on CameraInput async api for focusStateChange + * @tc.desc : camera status callback on CameraInput async api for focusStateChange + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_FOCUS_STATE_CHANGE_0100', 2, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_FOCUS_STATE_CHANGE_0100--------------"); + + if (mCameraNum == 0) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_FOCUS_STATE_CHANGE_0100 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraNum; i++) { + let nfyFlag = false; + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_FOCUS_STATE_CHANGE_0100 start for camera[" + i + "]"); + + await startCameraSession(i); + + mCameraInput.on('focusStateChange', async (err, data) => { if (!err) { - console.info(TAG + "PASSED close with CameraID :" + camerasArray[i].cameraId); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_FOCUS_STATE_CHANGE_0100 callback"); + if (data != null || data != undefined) { + console.info(TAG + "SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_FOCUS_STATE_CHANGE_0100 PASSED: " + data); + nfyFlag = true; + } } else { - successFlag = false; - console.info(TAG + "close FAILED: " + err.message); + expect().assertFail(); + console.info(TAG + "SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_FOCUS_STATE_CHANGE_0100 FAILED: " + err.message); } - }); - await sleep(100); - await cameraInput.release(async (err) => { + await sleep(1); + }) + + mCameraSession.setFocusMode(cameraObj.FocusMode.FOCUS_MODE_AUTO); + + await sleep(3000); + + if (nfyFlag == false) { + //expect().assertFail(); + //console.info(TAG + "SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_FOCUS_STATE_CHANGE_0100 FAILED without any nofity!"); + } + + await beginCameraSessionConfig(); + await stopCameraSession(); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_FOCUS_STATE_CHANGE_0100 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_FOCUS_STATE_CHANGE_0100 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_EXPOSURE_STATE_CHANGE_0100 + * @tc.name : camera status callback on CameraInput async api for exposureStateChange + * @tc.desc : camera status callback on CameraInput async api for exposureStateChange + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_EXPOSURE_STATE_CHANGE_0100', 2, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_EXPOSURE_STATE_CHANGE_0100--------------"); + + if (mCameraNum == 0) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_EXPOSURE_STATE_CHANGE_0100 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraNum; i++) { + let nfyFlag = false; + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_EXPOSURE_STATE_CHANGE_0100 start for camera[" + i + "]"); + + await startCameraSession(i); + + mCameraInput.on('exposureStateChange', async (err, data) => { if (!err) { - console.info(TAG + "PASSED release with CameraID :" + camerasArray[i].cameraId); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_EXPOSURE_STATE_CHANGE_0100 callback"); + if (data != null || data != undefined) { + console.info(TAG + "SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_EXPOSURE_STATE_CHANGE_0100 PASSED: " + data); + nfyFlag = true; + } } else { - successFlag = false; - console.info(TAG + "release FAILED: " + err.message); + expect().assertFail(); + console.info(TAG + "SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_EXPOSURE_STATE_CHANGE_0100 FAILED: " + err.message); } - }); - expect(successFlag).assertEqual(true); - }).catch((err) => { - expect().assertFail(); - console.info(TAG + "Failed To create cameraInput cameraId: " + camerasArray[i].cameraId + +JSON.stringify(err)); - }); + await sleep(1); + }) + + mCameraSession.setExposureMode(cameraObj.ExposureMode.EXPOSURE_MODE_AUTO); + + await sleep(3000); + + if (nfyFlag == false) { + //expect().assertFail(); + //console.info(TAG + "SUB_MULTIMEDIA_CAMERA_INPUT_STATUS_CALLBACK_0101 FAILED without any nofity!"); + } + + await beginCameraSessionConfig(); + await stopCameraSession(); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_EXPOSURE_STATE_CHANGE_0100 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_EXPOSURE_STATE_CHANGE_0100 ends here"); + done(); } - } - console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_RELEASE_CALLBACK_0100 ends here"); - await sleep(1000); - done(); - }); - /** - * @tc.number : SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_RELEASE_Promise_0100 - * @tc.name : open/close/release Camera with cameraInput promise api - * @tc.desc : open/close/release Camera with cameraInput promise api - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_RELEASE_Promise_0100', 0, async function (done) { - let functionTag = "SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_RELEASE_Promise_0100"; - console.info(functionTag); - if (isEmpty(mCameraManager)) { - console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_RELEASE_Promise_0100 cameraManager == null || undefined"); - expect().assertFail(); - } else { - let camerasArray = mCameraDevicesArray; - for (let i = 0; i < camerasArray.length; i++) { - let successFlag = true; - console.info(TAG + functionTag + "Entering createCameraInput with camera: " + camerasArray[i].cameraId); - mCameraManager.createCameraInput(camerasArray[i], async (err, cameraInput) => { - if (!err) { + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_RELEASE_CALLBACK_0100 + * @tc.name : open/close/release Camera with cameraInput callback api + * @tc.desc : open/close/release Camera with cameraInput callback api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_RELEASE_CALLBACK_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_RELEASE_CALLBACK_0100--------------"); + if (isEmpty(mCameraManager)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_RELEASE_CALLBACK_0100 cameraManager == null || undefined"); + expect().assertFail(); + } else { + let camerasArray = mCameraDevicesArray; + for (let i = 0; i < camerasArray.length; i++) { + let successFlag = true; + console.info(TAG + "Entering createCameraInput with camera: " + camerasArray[i].cameraId); + await mCameraManager.createCameraInput(camerasArray[i]).then(async (cameraInput) => { expect(isEmpty(cameraInput)).assertFalse(); - console.info(TAG + functionTag + "Entering cameraInput open with camera: " + camerasArray[i].cameraId); - await cameraInput.open().then(async () => { - console.info(TAG + functionTag + "PASSED open with CameraID :" + camerasArray[i].cameraId); - }).catch((err) => { - successFlag = false; - console.info(TAG + functionTag + "open FAILED: " + err.message); - });; + await cameraInput.open(async (err) => { + if (!err) { + console.info(TAG + "PASSED open with CameraID :" + camerasArray[i].cameraId); + } else { + successFlag = false; + console.info(TAG + "open FAILED: " + err.message); + } + }); await sleep(400); - await cameraInput.close().then(async () => { - console.info(TAG + functionTag + "PASSED close with CameraID :" + camerasArray[i].cameraId); - }).catch((err) => { - successFlag = false; - console.info(TAG + functionTag + "close FAILED: " + err.message); + await cameraInput.close(async (err) => { + if (!err) { + console.info(TAG + "PASSED close with CameraID :" + camerasArray[i].cameraId); + } else { + successFlag = false; + console.info(TAG + "close FAILED: " + err.message); + } }); await sleep(100); - await cameraInput.release().then(async () => { - console.info(TAG + functionTag + "PASSED release with CameraID :" + camerasArray[i].cameraId); - }).catch((err) => { - successFlag = false; - console.info(TAG + functionTag + "release FAILED: " + err.message); + await cameraInput.release(async (err) => { + if (!err) { + console.info(TAG + "PASSED release with CameraID :" + camerasArray[i].cameraId); + } else { + successFlag = false; + console.info(TAG + "release FAILED: " + err.message); + } }); expect(successFlag).assertEqual(true); - } else { + }).catch((err) => { expect().assertFail(); - console.info(TAG + functionTag + " FAILED: " + err.message); - } - }); + console.info(TAG + "Failed To create cameraInput cameraId: " + camerasArray[i].cameraId + +JSON.stringify(err)); + }); + } } - await sleep(400 * camerasArray.length); - } - console.info(TAG + functionTag + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_RELEASE_Promise_0100 ends here"); - done(); - }); -}) + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_RELEASE_CALLBACK_0100 ends here"); + await sleep(1000); + done(); + }); + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_RELEASE_PROMISE_0100 + * @tc.name : open/close/release Camera with cameraInput promise api + * @tc.desc : open/close/release Camera with cameraInput promise api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_RELEASE_PROMISE_0100', 0, async function (done) { + let functionTag = "SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_RELEASE_PROMISE_0100"; + console.info(functionTag); + if (isEmpty(mCameraManager)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_RELEASE_PROMISE_0100 cameraManager == null || undefined"); + expect().assertFail(); + } else { + let camerasArray = mCameraDevicesArray; + for (let i = 0; i < camerasArray.length; i++) { + let successFlag = true; + console.info(TAG + functionTag + "Entering createCameraInput with camera: " + camerasArray[i].cameraId); + mCameraManager.createCameraInput(camerasArray[i], async (err, cameraInput) => { + if (!err) { + expect(isEmpty(cameraInput)).assertFalse(); + console.info(TAG + functionTag + "Entering cameraInput open with camera: " + camerasArray[i].cameraId); + await cameraInput.open().then(async () => { + console.info(TAG + functionTag + "PASSED open with CameraID :" + camerasArray[i].cameraId); + }).catch((err) => { + successFlag = false; + console.info(TAG + functionTag + "open FAILED: " + err.message); + });; + await sleep(400); + await cameraInput.close().then(async () => { + console.info(TAG + functionTag + "PASSED close with CameraID :" + camerasArray[i].cameraId); + }).catch((err) => { + successFlag = false; + console.info(TAG + functionTag + "close FAILED: " + err.message); + }); + await sleep(100); + await cameraInput.release().then(async () => { + console.info(TAG + functionTag + "PASSED release with CameraID :" + camerasArray[i].cameraId); + }).catch((err) => { + successFlag = false; + console.info(TAG + functionTag + "release FAILED: " + err.message); + }); + expect(successFlag).assertEqual(true); + } else { + expect().assertFail(); + console.info(TAG + functionTag + " FAILED: " + err.message); + } + }); + } + await sleep(400 * camerasArray.length); + } + console.info(TAG + functionTag + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_RELEASE_PROMISE_0100 ends here"); + done(); + }); + + }) } \ No newline at end of file diff --git a/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraJSUnitOutput.test.ets b/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraJSUnitOutput.test.ets index 7b83474a9f23e13f2e6795f739592f8a50d9c504..b75ea9ad5b3fe7ffd45819ae98f0a7400c51f7dd 100755 --- a/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraJSUnitOutput.test.ets +++ b/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraJSUnitOutput.test.ets @@ -61,11 +61,15 @@ let cameraInput; let previewOutput; let photoOutput; let videoOutput; +let metadataOutput; let videoSurfaceId; let fdPath; let fileAsset; let fdNumber; +let mMetadataObjectTypeArray; +let mMetadataObjectArray; + export default function cameraJSUnitOutput(surfaceId: any) { async function getImageReceiverSurfaceId() { @@ -461,8 +465,8 @@ export default function cameraJSUnitOutput(surfaceId: any) { /** * @tc.number : SUB_MULTIMEDIA_CAMERA_CREATE_VIDEO_OUTPUT_CALLBACK_0100 - * @tc.name : Create previewOutput instance async api - * @tc.desc : Create previewOutput instance async api + * @tc.name : Create videoOutput instance async api + * @tc.desc : Create videoOutput instance async api * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 1 @@ -499,6 +503,53 @@ export default function cameraJSUnitOutput(surfaceId: any) { }) + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_CREATE_METADATA_OUTPUT_CALLBACK_0100 + * @tc.name : Create metadataOutput instance async api + * @tc.desc : Create metadataOutput instance async api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it('SUB_MULTIMEDIA_CAMERA_CREATE_METADATA_OUTPUT_CALLBACK_0100', 1, async function (done) { + console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_CREATE_METADATA_OUTPUT_CALLBACK_0100--------------"); + if (isEmpty(cameraManager)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_METADATA_OUTPUT_CALLBACK_0100 cameraManager == null || undefined") + expect().assertFail(); + } else { + let cameraOutputCap = await getSupportedOutputCapabilityInPromise(cameraDevicesArray[0]); + console.info("SUB_MULTIMEDIA_CAMERA_CREATE_METADATA_OUTPUT_CALLBACK_0100 camera:" + cameraDevicesArray[0].cameraId); + expect(isEmpty(cameraOutputCap)).assertFalse(); + mMetadataObjectTypeArray = cameraOutputCap.supportedMetadataObjectTypes; + if (isEmpty(mMetadataObjectTypeArray)) { + console.info("SUB_MULTIMEDIA_CAMERA_CREATE_METADATA_OUTPUT_CALLBACK_0100 end with mMetadataObjectTypeArray is null"); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_METADATA_OUTPUT_CALLBACK_0100 start createMetadataOutput") + cameraManager.createMetadataOutput(mMetadataObjectTypeArray, async (err, data) => { + if (!err) { + if (!isEmpty(data)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_METADATA_OUTPUT_CALLBACK_0100 success"); + metadataOutput = data; + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_METADATA_OUTPUT_CALLBACK_0100, data == null || undefined"); + expect().assertFail(); + } + + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_METADATA_OUTPUT_CALLBACK_0100 FAILED: " + err.message); + expect().assertFail(); + } + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_METADATA_OUTPUT_CALLBACK_0100 ends here"); + await sleep(1000); + done(); + }) + } + } + await sleep(1000); + done(); + }) + + /** * @tc.number : SUB_MULTIMEDIA_CAMERA_CREATE_CAPTURE_SESSION_CALLBACK_0100 @@ -549,7 +600,7 @@ export default function cameraJSUnitOutput(surfaceId: any) { console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_BEGIN_CONFIG_CALLBACK_0100 captureSession == null || undefined") expect().assertFail(); } else { - captureSession.beginConfig(async (err, data) => { + captureSession.beginConfig(async (err) => { if (!err) { expect(true).assertTrue(); console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_BEGIN_CONFIG_CALLBACK_0100 success"); @@ -582,7 +633,7 @@ export default function cameraJSUnitOutput(surfaceId: any) { console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_ADD_INPUT_CALLBACK_0100 captureSession == null || undefined") expect().assertFail(); } else { - captureSession.addInput(cameraInput, async (err, data) => { + captureSession.addInput(cameraInput, async (err) => { if (!err) { expect(true).assertTrue(); console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_ADD_INPUT_CALLBACK_0100 success"); @@ -619,7 +670,7 @@ export default function cameraJSUnitOutput(surfaceId: any) { console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_ADD_PREVIEW_OUTPUT_CALLBACK_0100 previewOutput == null || undefined") expect().assertFail(); } - captureSession.addOutput(previewOutput, async (err, data) => { + captureSession.addOutput(previewOutput, async (err) => { if (!err) { console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_ADD_PREVIEW_OUTPUT_CALLBACK_0100 success"); expect(true).assertTrue(); @@ -656,7 +707,7 @@ export default function cameraJSUnitOutput(surfaceId: any) { expect().assertFail(); } console.info(TAG + "captureSession start add photoOutput") - captureSession.addOutput(photoOutput, async (err, data) => { + captureSession.addOutput(photoOutput, async (err) => { if (!err) { expect(true).assertTrue(); console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_ADD_PHOTO_OUTPUT_CALLBACK_0100 success"); @@ -688,7 +739,7 @@ export default function cameraJSUnitOutput(surfaceId: any) { console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_ADD_VIDEO_OUTPUT_CALLBACK_0100 captureSession == null || undefined") expect().assertFail(); } else { - captureSession.addOutput(videoOutput, async (err, data) => { + captureSession.addOutput(videoOutput, async (err) => { if (!err) { expect(true).assertTrue(); console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_ADD_VIDEO_OUTPUT_CALLBACK_0100 success"); @@ -706,6 +757,37 @@ export default function cameraJSUnitOutput(surfaceId: any) { }) + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_ADD_METADATA_OUTPUT_CALLBACK_0100 + * @tc.name : captureSession add metadataOutput + * @tc.desc : captureSession add metadataOutput + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it('SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_ADD_METADATA_OUTPUT_CALLBACK_0100', 1, async function (done) { + console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_ADD_METADATA_OUTPUT_CALLBACK_0100--------------"); + if (isEmpty(captureSession)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_ADD_METADATA_OUTPUT_CALLBACK_0100 captureSession == null || undefined") + expect().assertFail(); + } else { + captureSession.addOutput(metadataOutput, async (err) => { + if (!err) { + expect(true).assertTrue(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_ADD_METADATA_OUTPUT_CALLBACK_0100 success"); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_ADD_METADATA_OUTPUT_CALLBACK_0100 FAILED: " + err.message); + expect().assertFail(); + } + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_ADD_METADATA_OUTPUT_CALLBACK_0100 ends here"); + await sleep(1000); + done(); + }) + } + await sleep(1000); + done(); + }) + /** * @tc.number : SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_COMMIT_CONFIG_CALLBACK_0100 @@ -721,7 +803,7 @@ export default function cameraJSUnitOutput(surfaceId: any) { console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_COMMIT_CONFIG_CALLBACK_0100 captureSession == null || undefined") expect().assertFail(); } else { - captureSession.commitConfig(async (err, data) => { + captureSession.commitConfig(async (err) => { if (!err) { console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_COMMIT_CONFIG_CALLBACK_0100 success"); expect(true).assertTrue(); @@ -739,6 +821,38 @@ export default function cameraJSUnitOutput(surfaceId: any) { }) + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_ON_AVAILABLE_METADATA_OUTPUT_CALLBACK_0100 + * @tc.name : Start metadataOutput type async api + * @tc.desc : Start metadataOutput type async api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it('SUB_MULTIMEDIA_CAMERA_ON_AVAILABLE_METADATA_OUTPUT_CALLBACK_0100', 1, async function (done) { + console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_ON_AVAILABLE_METADATA_OUTPUT_CALLBACK_0100--------------"); + if (isEmpty(metadataOutput)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ON_AVAILABLE_METADATA_OUTPUT_CALLBACK_0100 metadataOutput == null || undefined") + } else { + metadataOutput.on('metadataObjectsAvailable', async (err, data) => { + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ON_AVAILABLE_METADATA_OUTPUT_CALLBACK_0100 is not error"); + expect(isEmpty(data)).assertFalse(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ON_AVAILABLE_METADATA_OUTPUT_CALLBACK_0100 success"); + mMetadataObjectArray = data; + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ON_AVAILABLE_METADATA_OUTPUT_CALLBACK_0100 FAILED: " + err.message); + expect().assertFail(); + } + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ON_AVAILABLE_METADATA_OUTPUT_CALLBACK_0100 ends here"); + await sleep(1000); + }) + + } + await sleep(1000); + done(); + }) + /** * @tc.number : SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_START_CALLBACK_0100 @@ -748,7 +862,7 @@ export default function cameraJSUnitOutput(surfaceId: any) { * @tc.type : Function * @tc.level : Level 1 */ - it('SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_START_CALLBACK_0100', 1, async function (done) { + it('SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_START_CALLBACK_0100', 1, async function (done) { console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_START_CALLBACK_0100--------------"); if (isEmpty(captureSession)) { console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_START_CALLBACK_0100 captureSession == null || undefined") @@ -772,6 +886,247 @@ export default function cameraJSUnitOutput(surfaceId: any) { }) + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_START_METADATA_OUTPUT_CALLBACK_0100 + * @tc.name : Start metadataOutput type async api + * @tc.desc : Start metadataOutput type async api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it('SUB_MULTIMEDIA_CAMERA_START_METADATA_OUTPUT_CALLBACK_0100', 1, async function (done) { + console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_START_METADATA_OUTPUT_CALLBACK_0100--------------"); + if (isEmpty(metadataOutput)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_START_METADATA_OUTPUT_CALLBACK_0100 metadataOutput == null || undefined") + } else { + metadataOutput.start(async (err) => { + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_START_METADATA_OUTPUT_CALLBACK_0100 success"); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_START_METADATA_OUTPUT_CALLBACK_0100 FAILED: " + err.message); + expect().assertFail(); + } + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_START_METADATA_OUTPUT_CALLBACK_0100 ends here"); + await sleep(1000); + }) + } + await sleep(1000); + done(); + }) + + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_GET_METADATA_TYPE_CALLBACK_0100 + * @tc.name : Start metadataOutput type async api + * @tc.desc : Start metadataOutput type async api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it('SUB_MULTIMEDIA_CAMERA_GET_METADATA_TYPE_CALLBACK_0100', 1, async function (done) { + console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_GET_METADATA_TYPE_CALLBACK_0100--------------"); + if (isEmpty(mMetadataObjectArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_METADATA_TYPE_CALLBACK_0100 mMetadataObjectArray == null || undefined") + } else { + mMetadataObjectArray[0].getType(async (err, data) => { + if (!err) { + if (!isEmpty(data)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_METADATA_TYPE_CALLBACK_0100 success, data : " + data); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_METADATA_TYPE_CALLBACK_0100 FAILED, data == null || undefined"); + expect().assertFail(); + } + + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_METADATA_TYPE_CALLBACK_0100 FAILED: " + err.message); + expect().assertFail(); + } + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_METADATA_TYPE_CALLBACK_0100 ends here"); + await sleep(1000); + }) + } + await sleep(1000); + done(); + }) + + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_GET_METADATA_TYPE_PROMISE_0100 + * @tc.name : Start metadataOutput type async api + * @tc.desc : Start metadataOutput type async api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it('SUB_MULTIMEDIA_CAMERA_GET_METADATA_TYPE_PROMISE_0100', 1, async function (done) { + console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_GET_METADATA_TYPE_PROMISE_0100--------------"); + if (isEmpty(mMetadataObjectArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_METADATA_TYPE_PROMISE_0100 mMetadataObjectArray == null || undefined") + } else { + let type = mMetadataObjectArray[0].getType().then((result) => { + console.info('SUB_MULTIMEDIA_CAMERA_GET_METADATA_TYPE_PROMISE_0100 success :' + result); + }).catch((err) => { + console.info('SUB_MULTIMEDIA_CAMERA_GET_METADATA_TYPE_PROMISE_0100 failed :' + err); + expect().assertFail(); + }); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_METADATA_TYPE_PROMISE_0100 success, type : " + type); + } + await sleep(1000); + done(); + }) + + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_GET_METADATA_TIMESTAMP_CALLBACK_0100 + * @tc.name : Start metadataOutput timestamp async api + * @tc.desc : Start metadataOutput timestamp async api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it('SUB_MULTIMEDIA_CAMERA_GET_METADATA_TIMESTAMP_CALLBACK_0100', 1, async function (done) { + console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_GET_METADATA_TIMESTAMP_CALLBACK_0100--------------"); + if (isEmpty(mMetadataObjectArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_METADATA_TIMESTAMP_CALLBACK_0100 mMetadataObjectArray == null || undefined") + } else { + mMetadataObjectArray[0].getTimestamp(async (err, data) => { + if (!err) { + if (!isEmpty(data)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_METADATA_TIMESTAMP_CALLBACK_0100 success, data : " + data); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_METADATA_TIMESTAMP_CALLBACK_0100 FAILED, data == null || undefined"); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_METADATA_TIMESTAMP_CALLBACK_0100 FAILED: " + err.message); + expect().assertFail(); + } + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_METADATA_TIMESTAMP_CALLBACK_0100 ends here"); + await sleep(1000); + }) + } + await sleep(1000); + done(); + }) + + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_GET_METADATA_TIMESTAMP_PROMISE_0100 + * @tc.name : Start metadataOutput timestamp async api + * @tc.desc : Start metadataOutput timestamp async api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it('SUB_MULTIMEDIA_CAMERA_GET_METADATA_TIMESTAMP_PROMISE_0100', 1, async function (done) { + console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_GET_METADATA_TIMESTAMP_PROMISE_0100--------------"); + if (isEmpty(mMetadataObjectArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_METADATA_TIMESTAMP_PROMISE_0100 mMetadataObjectArray == null || undefined") + } else { + let timeStamp = mMetadataObjectArray[0].getTimestamp().then((result) => { + console.info('SUB_MULTIMEDIA_CAMERA_GET_METADATA_TIMESTAMP_PROMISE_0100 success :' + result); + }).catch((err) => { + console.info('SUB_MULTIMEDIA_CAMERA_GET_METADATA_TIMESTAMP_PROMISE_0100 failed :' + err); + expect().assertFail(); + }); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_METADATA_TIMESTAMP_PROMISE_0100 success, timeStamp : " + timeStamp); + } + await sleep(1000); + done(); + }) + + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_GET_METADATA_BOUNDING_BOX_CALLBACK_0100 + * @tc.name : Start metadataOutput bounding box async api + * @tc.desc : Start metadataOutput bounding box async api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it('SUB_MULTIMEDIA_CAMERA_GET_METADATA_BOUNDING_BOX_CALLBACK_0100', 1, async function (done) { + console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_GET_METADATA_BOUNDING_BOX_CALLBACK_0100--------------"); + if (isEmpty(mMetadataObjectArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_METADATA_BOUNDING_BOX_CALLBACK_0100 mMetadataObjectArray == null || undefined") + } else { + mMetadataObjectArray[0].getBoundingBox(async (err, data) => { + if (!err) { + if (!isEmpty(data)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_METADATA_BOUNDING_BOX_CALLBACK_0100 success, data : " + data); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_METADATA_BOUNDING_BOX_CALLBACK_0100 FAILED, data == null || undefined"); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_METADATA_BOUNDING_BOX_CALLBACK_0100 FAILED: " + err.message); + expect().assertFail(); + } + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_METADATA_BOUNDING_BOX_CALLBACK_0100 ends here"); + await sleep(1000); + done(); + }) + + } + await sleep(1000); + done(); + }) + + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_GET_METADATA_BOUNDING_BOX_PROMISE_0100 + * @tc.name : Start metadataOutput bounding box async api + * @tc.desc : Start metadataOutput bounding box async api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it('SUB_MULTIMEDIA_CAMERA_GET_METADATA_BOUNDING_BOX_PROMISE_0100', 1, async function (done) { + console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_GET_METADATA_BOUNDING_BOX_PROMISE_0100--------------"); + if (isEmpty(mMetadataObjectArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_METADATA_BOUNDING_BOX_PROMISE_0100 mMetadataObjectArray == null || undefined") + } else { + let boundingBox = mMetadataObjectArray[0].getBoundingBox().then((result) => { + console.info('SUB_MULTIMEDIA_CAMERA_GET_METADATA_BOUNDING_BOX_PROMISE_0100 success :' + result); + }).catch((err) => { + console.info('SUB_MULTIMEDIA_CAMERA_GET_METADATA_BOUNDING_BOX_PROMISE_0100 failed :' + err); + expect().assertFail(); + }); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_METADATA_BOUNDING_BOX_PROMISE_0100 success, boundingBox : " + boundingBox.width + "x" + boundingBox.height); + } + await sleep(1000); + done(); + }) + + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_STOP_METADATA_OUTPUT_CALLBACK_0100 + * @tc.name : Stop metadataOutput type async api + * @tc.desc : Stop metadataOutput type async api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it('SUB_MULTIMEDIA_CAMERA_STOP_METADATA_OUTPUT_CALLBACK_0100', 1, async function (done) { + console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_STOP_METADATA_OUTPUT_CALLBACK_0100--------------"); + if (isEmpty(metadataOutput)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_STOP_METADATA_OUTPUT_CALLBACK_0100 metadataOutput == null || undefined") + } else { + metadataOutput.stop(async (err) => { + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_STOP_METADATA_OUTPUT_CALLBACK_0100 success"); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_STOP_METADATA_OUTPUT_CALLBACK_0100 FAILED: " + err.message); + expect().assertFail(); + } + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_STOP_METADATA_OUTPUT_CALLBACK_0100 ends here"); + await sleep(1000); + done(); + }) + } + await sleep(1000); + done(); + }) + /** * @tc.number : SUB_MULTIMEDIA_CAMERA_START_PREVIEW_OUTPUT_PROMISE_0100 @@ -982,6 +1337,101 @@ export default function cameraJSUnitOutput(surfaceId: any) { }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_IS_MIRROR_SUPPORTED_PROMISE_0100 + * @tc.name : check photoOutput is mirror supported with promise mode + * @tc.desc : check photoOutput is mirror supported with promise mode + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it('SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_IS_MIRROR_SUPPORTED_PROMISE_0100', 1, async function (done) { + console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_IS_MIRROR_SUPPORTED_PROMISE_0100--------------"); + if (isEmpty(photoOutput)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_IS_MIRROR_SUPPORTED_PROMISE_0100 photoOutput == null || undefined") + expect().assertFail(); + } else { + let isMirrorSupportedFlag = await photoOutput.isMirrorSupported().then((result) => { + console.info('SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_IS_MIRROR_SUPPORTED_PROMISE_0100 success :' + result); + }).catch((err) => { + console.info('SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_IS_MIRROR_SUPPORTED_PROMISE_0100 failed :' + err); + expect().assertFail(); + }); + + console.info('SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_IS_MIRROR_SUPPORTED_PROMISE_0100 isMirrorSupportedFlag = ' + isMirrorSupportedFlag); + } + await sleep(1000); + done(); + }) + + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_IS_MIRROR_SUPPORTED_CALLBACK_0100 + * @tc.name : check photoOutput is mirror supported with callback mode + * @tc.desc : check photoOutput is mirror supported with callback mode + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it('SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_IS_MIRROR_SUPPORTED_CALLBACK_0100', 1, async function (done) { + console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_IS_MIRROR_SUPPORTED_CALLBACK_0100--------------"); + if (isEmpty(photoOutput)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_IS_MIRROR_SUPPORTED_CALLBACK_0100 photoOutput == null || undefined") + expect().assertFail(); + } else { + photoOutput.isMirrorSupported(async (err, data) => { + if (!err) { + if (!isEmpty(data)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_IS_MIRROR_SUPPORTED_CALLBACK_0100 success, data = " + data); + expect(true).assertTrue(); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_IS_MIRROR_SUPPORTED_CALLBACK_0100 FAILED, data == null || undefined"); + expect().assertFail(); + } + + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_IS_MIRROR_SUPPORTED_CALLBACK_0100 FAILED: " + err.message); + expect().assertFail(); + } + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_IS_MIRROR_SUPPORTED_CALLBACK_0100 ends here"); + await sleep(1000); + done(); + }) + } + await sleep(1000); + done(); + }) + + + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_DEFAULT_PROMISE_0100 + * @tc.name : photoOutput capture with promise mode + * @tc.desc : photoOutput capture with promise mode + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it('SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_DEFAULT_PROMISE_0100', 1, async function (done) { + console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_DEFAULT_PROMISE_0100--------------"); + if (isEmpty(photoOutput)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_DEFAULT_PROMISE_0100 photoOutput == null || undefined") + expect().assertFail(); + } else { + await photoOutput.capture().then((result) => { + console.info('SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_DEFAULT_PROMISE_0100 success :' + result); + }).catch((err) => { + console.info('SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_DEFAULT_PROMISE_0100 failed :' + err); + expect().assertFail(); + }); + } + await sleep(1000); + done(); + }) + + + /** * @tc.number : SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_DEFAULT_CALLBACK_0100 * @tc.name : photoOutput commitConfig @@ -996,7 +1446,7 @@ export default function cameraJSUnitOutput(surfaceId: any) { console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_DEFAULT_CALLBACK_0100 photoOutput == null || undefined") expect().assertFail(); } else { - photoOutput.capture(async (err, data) => { + photoOutput.capture(async (err) => { if (!err) { console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_DEFAULT_CALLBACK_0100 success"); expect(true).assertTrue(); @@ -1014,6 +1464,32 @@ export default function cameraJSUnitOutput(surfaceId: any) { }) + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_SETTING_PROMISE_0100 + * @tc.name : photoOutput commitConfig + * @tc.desc : captureSession commitConfig + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it('SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_SETTING_PROMISE_0100', 1, async function (done) { + console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_SETTING_PROMISE_0100--------------"); + if (isEmpty(photoOutput)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_SETTING_PROMISE_0100 photoOutput == null || undefined") + expect().assertFail(); + } else { + await photoOutput.capture(captureSetting).then((result) => { + console.info('SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_SETTING_PROMISE_0100 success :' + result); + }).catch((err) => { + console.info('SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_SETTING_PROMISE_0100 failed :' + err); + }); + + } + await sleep(1000); + done(); + }) + + /** * @tc.number : SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_SETTING_CALLBACK_0100 @@ -1029,7 +1505,7 @@ export default function cameraJSUnitOutput(surfaceId: any) { console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_SETTING_CALLBACK_0100 photoOutput == null || undefined") expect().assertFail(); } else { - photoOutput.capture(captureSetting, async (err, data) => { + photoOutput.capture(captureSetting, async (err) => { if (!err) { expect(true).assertTrue(); console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_SETTING_CALLBACK_0100 success"); @@ -1261,6 +1737,56 @@ export default function cameraJSUnitOutput(surfaceId: any) { }) + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_START_METADATA_OUTPUT_PROMISE_0100 + * @tc.name : Start metadataOutput sync api + * @tc.desc : Start metadataOutput sync api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it('SUB_MULTIMEDIA_CAMERA_START_METADATA_OUTPUT_PROMISE_0100', 1, async function (done) { + console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_START_METADATA_OUTPUT_PROMISE_0100--------------"); + if (isEmpty(metadataOutput)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_START_METADATA_OUTPUT_PROMISE_0100 metadataOutput == null || undefined") + } else { + metadataOutput.start().then((result) => { + console.info('SUB_MULTIMEDIA_CAMERA_START_METADATA_OUTPUT_PROMISE_0100 success :' + result); + }).catch((err) => { + console.info('SUB_MULTIMEDIA_CAMERA_START_METADATA_OUTPUT_PROMISE_0100 failed :' + err); + }); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_START_METADATA_OUTPUT_PROMISE_0100 ends here"); + } + await sleep(1000); + done(); + }) + + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_STOP_METADATA_OUTPUT_PROMISE_0100 + * @tc.name : Stop metadataOutput sync api + * @tc.desc : Stop metadataOutput aync api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it('SUB_MULTIMEDIA_CAMERA_STOP_METADATA_OUTPUT_PROMISE_0100', 1, async function (done) { + console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_STOP_METADATA_OUTPUT_PROMISE_0100--------------"); + if (isEmpty(metadataOutput)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_STOP_METADATA_OUTPUT_PROMISE_0100 metadataOutput == null || undefined") + } else { + metadataOutput.stop().then((result) => { + console.info('SUB_MULTIMEDIA_CAMERA_STOP_METADATA_OUTPUT_PROMISE_0100 success :' + result); + }).catch((err) => { + console.info('SUB_MULTIMEDIA_CAMERA_STOP_METADATA_OUTPUT_PROMISE_0100 failed :' + err); + }); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_STOP_METADATA_OUTPUT_PROMISE_0100 ends here"); + } + await sleep(1000); + done(); + }) + + /** * @tc.number : SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_START_CALLBACK_0100 diff --git a/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraManagerTest.test.ets b/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraManagerTest.test.ets index 0be8b5ea3dbce9d53b53b3cf5ca5a3d27835b7bd..603e9f55d860790b6ddd7388f8a62a4c4c1fe480 100755 --- a/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraManagerTest.test.ets +++ b/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraManagerTest.test.ets @@ -26,14 +26,18 @@ const TAG = "CameraUnitTest: "; // Define global variables let mCameraManager; -let mPhotoSurfaceId; let mCameraDevicesArray; -let mVideoSurface; + +let mPhotoSurface; let mVideoRecorder; -let mFdPath; +let mVideoSurface; let mFileAsset; +let mFdPath; let mFdNumber; +// CAMERA-0 letiables +let mCameraNum; + let mVideoProfileCfg = { audioBitrate: 48000, audioChannels: 2, @@ -67,8 +71,8 @@ export default function cameraManagerTest(surfaceId: any) { console.log(TAG + 'before receiver check') if (receiver !== undefined) { console.log(TAG + 'Receiver is ok') - mPhotoSurfaceId = await receiver.getReceivingSurfaceId() - console.log(TAG + 'Received id: ' + JSON.stringify(mPhotoSurfaceId)) + mPhotoSurface = await receiver.getReceivingSurfaceId() + console.log(TAG + 'Received id: ' + JSON.stringify(mPhotoSurface)) } else { console.log(TAG + 'Receiver is not ok') } @@ -168,9 +172,44 @@ export default function cameraManagerTest(surfaceId: any) { console.info(TAG + "getCameraManager FAILED"); return false; } - await sleep(500); console.info('Exit getCameraManagerInstance'); + + return true; + } + + async function getCameraSupportDevicesArray() { + console.info('Enter getCameraSupportDevicesArray'); + + mCameraDevicesArray = await mCameraManager.getSupportedCameras(); + /* + mCameraManager.getSupportedCameras(async (err, data) => { + console.info(TAG + "Entering getCameraSupportDevicesArray callback"); + if (!err) { + if (data != null || data != undefined) { + mCameraDevicesArray = data; + console.info(TAG + "Entering getCameraSupportDevicesArray PASSED with CameraDevicesArray is: " + data); + } else { + console.info(TAG + "Entering getCameraSupportDevicesArray FAILED with CameraDevicesArray is: " + data); + } + } else { + console.info(TAG + "Entering getCameraSupportDevicesArray FAILED : " + err.message); + } + }) + await sleep(3000); + */ + if (isEmpty(mCameraDevicesArray)) { + console.info(TAG + "getSupportedCameras FAILED"); + return false; + } + + //mCameraNum = 1; + mCameraNum = mCameraDevicesArray.length; + + console.info(TAG + "getCameraSupportDevicesArray is: " + mCameraNum); + + console.info('Exit getCameraSupportDevicesArray'); + return true; } @@ -286,6 +325,7 @@ describe('CameraManagerTest', function () { await getCameraManagerInstance(); await getImageReceiverSurfaceId(); await getVideoReceiveSurface(); + await getCameraSupportDevicesArray(); console.info('beforeAll case'); }) @@ -324,7 +364,6 @@ describe('CameraManagerTest', function () { } console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_CAMERAMANAGER_CALLBACK_0100 ends here"); await sleep(1000); - done(); }) await sleep(1000); done(); @@ -733,6 +772,70 @@ describe('CameraManagerTest', function () { done(); }) + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_BY_POSITION_AND_TYPE_CALLBACK_0100 + * @tc.name : Create camerainput from camera-0 cameraposition back & cameratype unspecified async api + * @tc.desc : Create camerainput from camera-0 cameraposition back & cameratype unspecified async api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_BY_POSITION_AND_TYPE_CALLBACK_0100', 2, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_BY_POSITION_AND_TYPE_CALLBACK_0100--------------"); + if (isEmpty(mCameraManager)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_BY_POSITION_AND_TYPE_CALLBACK_0100 cameraManager == null || undefined") + expect().assertFail(); + } else { + let camerasArray = mCameraDevicesArray; + for (let i = 0; i < camerasArray.length; i++) { + mCameraManager.createCameraInput(camerasArray[i].cameraPosition, camerasArray[i].cameraType, async (err, data) => { + if (!err) { + if (isEmpty(data)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_BY_POSITION_AND_TYPE_CALLBACK_0100 data == null || undefined") + expect().assertFail(); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_BY_POSITION_AND_TYPE_CALLBACK_0100 success"); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_BY_POSITION_AND_TYPE_CALLBACK_0100 FAILED: " + err.message); + expect().assertFail(); + } + }) + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_PROMISE_0100 camera: " + camerasArray[i].cameraId); + } + } + await sleep(1000); + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_BY_POSITION_AND_TYPE_PROMISE_0100 + * @tc.name : Create camerainput from camera-0 cameraposition back & cameratype unspecified promise api + * @tc.desc : Create camerainput from camera-0 cameraposition back & cameratype unspecified promise api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_BY_POSITION_AND_TYPE_PROMISE_0100', 2, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_BY_POSITION_AND_TYPE_PROMISE_0100--------------"); + if (isEmpty(mCameraManager)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_BY_POSITION_AND_TYPE_PROMISE_0100 cameraManager == null || undefined") + expect().assertFail(); + } else { + let camerasArray = mCameraDevicesArray; + for (let i = 0; i < camerasArray.length; i++) { + let cameraInputPromiseByType = await mCameraManager.createCameraInput(camerasArray[i].cameraPosition, camerasArray[i].cameraType); + if (isEmpty(cameraInputPromiseByType)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_BY_POSITION_AND_TYPE_PROMISE_0100 cameraInputPromiseByType == null || undefined") + expect().assertFail(); + } + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_BY_POSITION_AND_TYPE_PROMISE_0100 camera: " + camerasArray[i].cameraId); + } + } + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_BY_POSITION_AND_TYPE_PROMISE_0100 ends here"); + await sleep(1000); + done(); + }) /*CREATE CAMERAOUTPUT*/ /** @@ -763,8 +866,7 @@ describe('CameraManagerTest', function () { expect().assertFail(); } }) - await sleep(10); - done(); + await sleep(100); } } console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_PREVIEW_OUTPUT_CALLBACK_0100 PASS"); @@ -802,8 +904,7 @@ describe('CameraManagerTest', function () { console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_PREVIEW_OUTPUT_PROMISE_0100 previewOutputPromise == null || undefined") expect().assertFail(); } - await sleep(10); - done(); + await sleep(100); } } console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_PREVIEW_OUTPUT_PROMISE_0100 PASS"); @@ -836,14 +937,13 @@ describe('CameraManagerTest', function () { expect().assertFail(); } for (let j = 0; j < photoProfilesArray.length; j++) { - mCameraManager.createPhotoOutput(photoProfilesArray[j], mPhotoSurfaceId, async (err, data) => { + mCameraManager.createPhotoOutput(photoProfilesArray[j], mPhotoSurface, async (err, data) => { if (isEmpty(data)) { console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_PHOTO_OUTPUT_CALLBACK_0100 data == null || undefined") expect().assertFail(); } }) - await sleep(10); - done(); + await sleep(100); } } console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_PHOTO_OUTPUT_CALLBACK_0100 PASS"); @@ -876,13 +976,12 @@ describe('CameraManagerTest', function () { expect().assertFail(); } for (let j = 0; j < photoProfilesArray.length; j++) { - let photoOutputPromise = await mCameraManager.createPhotoOutput(photoProfilesArray[j], mPhotoSurfaceId); + let photoOutputPromise = await mCameraManager.createPhotoOutput(photoProfilesArray[j], mPhotoSurface); if (isEmpty(photoOutputPromise)) { console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_PHOTO_OUTPUT_PROMISE_0100 photoOutputPromise == null || undefined") expect().assertFail(); } - await sleep(10); - done(); + await sleep(100); } } console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_PHOTO_OUTPUT_PROMISE_0100 PASS"); @@ -901,6 +1000,7 @@ describe('CameraManagerTest', function () { it('SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_VIDEO_OUTPUT_CALLBACK_0100', 2, async function (done) { console.info("--------------SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_VIDEO_OUTPUT_CALLBACK_0100--------------"); let camerasArray = mCameraDevicesArray; + let createVideoOutputFlag; for (let i = 0; i < camerasArray.length; i++) { let cameraOutputCap = await getSupportedOutputCapabilityInPromise(camerasArray[i]); console.info("SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_VIDEO_OUTPUT_CALLBACK_0100 camera:" + camerasArray[i].cameraId); @@ -914,15 +1014,29 @@ describe('CameraManagerTest', function () { console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_VIDEO_OUTPUT_CALLBACK_0100 videoProfilesArray == null || undefined") expect().assertFail(); } + + createVideoOutputFlag = false; for (let j = 0; j < videoProfilesArray.length; j++) { mCameraManager.createVideoOutput(videoProfilesArray[j], mVideoSurface, async (err, data) => { - if (isEmpty(data)) { - console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_VIDEO_OUTPUT_CALLBACK_0100 data == null || undefined") + if (!err) { + if (isEmpty(data)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_VIDEO_OUTPUT_CALLBACK_0100 data == null || undefined"); + expect().assertFail(); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_VIDEO_OUTPUT_CALLBACK_0100 data = " + data); + createVideoOutputFlag = true; + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_VIDEO_OUTPUT_CALLBACK_0100 failed, err = " + err.message); expect().assertFail(); } + }) - await sleep(10); - done(); + await sleep(100); + + if (createVideoOutputFlag == true) { + break; + } } } console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_VIDEO_OUTPUT_CALLBACK_0100 PASS"); @@ -959,9 +1073,11 @@ describe('CameraManagerTest', function () { if (isEmpty(videoOutputPromise)) { console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_VIDEO_OUTPUT_PROMISE_0100 videoOutputPromise == null || undefined") expect().assertFail(); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_VIDEO_OUTPUT_CALLBACK_0100 videoOutputPromise = " + videoOutputPromise); + break; } - await sleep(10); - done(); + await sleep(100); } } console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_VIDEO_OUTPUT_PROMISE_0100 PASS"); @@ -970,7 +1086,92 @@ describe('CameraManagerTest', function () { }) /** - * @tc.number : SUB_MULTIMEDIA_CAMERA_MANAGER_CREATE_CAPTURE_SESSION_CALLBACK_0100 + * @tc.number : SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_METADATA_OUTPUT_CALLBACK_0100 + * @tc.name : Create camerainput from camera-0 cameraposition front & cameratype unspecified async api + * @tc.desc : Create camerainput from camera-0 cameraposition front & cameratype unspecified async api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_METADATA_OUTPUT_CALLBACK_0100', 2, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_METADATA_OUTPUT_CALLBACK_0100--------------"); + let camerasArray = mCameraDevicesArray; + for (let i = 0; i < camerasArray.length; i++) { + let cameraOutputCap = await getSupportedOutputCapabilityInPromise(camerasArray[i]); + console.info("SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_METADATA_OUTPUT_CALLBACK_0100 camera:" + camerasArray[i].cameraId); + if (isEmpty(cameraOutputCap)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_METADATA_OUTPUT_CALLBACK_0100 cameraOutputCap == null || undefined") + expect().assertFail(); + } + + let metadataObjectTypeArray = cameraOutputCap.supportedMetadataObjectTypes; + if (!isEmpty(metadataObjectTypeArray)) { + mCameraManager.createMetadataOutput(metadataObjectTypeArray, async (err, data) => { + if (!err) { + if (isEmpty(data)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_METADATA_OUTPUT_CALLBACK_0100 data == null || undefined") + expect().assertFail(); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_METADATA_OUTPUT_CALLBACK_0100 data = " + data) + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_METADATA_OUTPUT_CALLBACK_0100 err = " + err.message) + expect().assertFail(); + } + + }) + await sleep(100); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_METADATA_OUTPUT_CALLBACK_0100 metadataObjectTypeArray == null || undefined") + } + await sleep(1000); + } + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_METADATA_OUTPUT_CALLBACK_0100 PASS"); + await sleep(1000); + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_METADATA_OUTPUT_PROMISE_0100 + * @tc.name : Create camerainput from camera-0 cameraposition front & cameratype unspecified async api + * @tc.desc : Create camerainput from camera-0 cameraposition front & cameratype unspecified async api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_METADATA_OUTPUT_PROMISE_0100', 2, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_METADATA_OUTPUT_PROMISE_0100--------------"); + let camerasArray = mCameraDevicesArray; + for (let i = 0; i < camerasArray.length; i++) { + let cameraOutputCap = await getSupportedOutputCapabilityInPromise(camerasArray[i]); + console.info("SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_METADATA_OUTPUT_PROMISE_0100 camera:" + camerasArray[i].cameraId); + if (isEmpty(cameraOutputCap)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_METADATA_OUTPUT_PROMISE_0100 cameraOutputCap == null || undefined") + expect().assertFail(); + } + + let metadataObjectTypeArray = cameraOutputCap.supportedMetadataObjectTypes; + if (!isEmpty(metadataObjectTypeArray)) { + let metadataOutputPromise = await mCameraManager.createMetadataOutput(metadataObjectTypeArray); + if (isEmpty(metadataOutputPromise)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_METADATA_OUTPUT_PROMISE_0100 metadataOutputPromise == null || undefined") + expect().assertFail(); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_METADATA_OUTPUT_PROMISE_0100 metadataOutputPromise = " + metadataOutputPromise) + } + await sleep(100); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_METADATA_OUTPUT_PROMISE_0100 metadataObjectTypeArray == null || undefined") + } + + } + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_METADATA_OUTPUT_PROMISE_0100 PASS"); + await sleep(1000); + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_CREATE_CAPTURE_SESSION_CALLBACK_0100 * @tc.name : Create CaptureSession instance api * @tc.desc : Create CaptureSession instance api * @tc.size : MEDIUM @@ -996,7 +1197,6 @@ describe('CameraManagerTest', function () { console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_MANAGER_CREATE_CAPTURE_SESSION_CALLBACK_0100 ends here"); } await sleep(1000); - done(); }) await sleep(1000); await cameraSession.release(); @@ -1052,7 +1252,6 @@ describe('CameraManagerTest', function () { console.info(TAG + "SUB_MULTIMEDIA_CAMERA_CAMERA_STATUS_CALLBACK_0100 FAILED: " + err.message); } await sleep(1000); - done(); }) } await sleep(1000); diff --git a/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraSessionBaseTest.test.ets b/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraSessionBaseTest.test.ets index af2fd124ced1bbe616d91390ea5932dd0c484dd7..126d701ca309cd14c980a14395c5f2055df3bfe1 100755 --- a/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraSessionBaseTest.test.ets +++ b/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraSessionBaseTest.test.ets @@ -32,7 +32,7 @@ let mCameraManager; let mCameraDevicesArray; let mCameraSession; -let mPhoteSurface; +let mPhotoSurface; let mVideoRecorder; let mVideoSurface; let mFileAsset; @@ -183,8 +183,8 @@ export default function cameraSessionTest(surfaceId: any) { console.log(TAG + 'before receiver check') if (receiver !== undefined) { console.log(TAG + 'Photo receiver is created successfully') - mPhoteSurface = await receiver.getReceivingSurfaceId() - console.log(TAG + 'Photo received id: ' + JSON.stringify(mPhoteSurface)) + mPhotoSurface = await receiver.getReceivingSurfaceId() + console.log(TAG + 'Photo received id: ' + JSON.stringify(mPhotoSurface)) } else { console.log(TAG + 'Photo receiver is created failed') } @@ -409,12 +409,11 @@ export default function cameraSessionTest(surfaceId: any) { console.info(TAG + "createPreviewOutput: " + mPreviewOutput); } - - if (!isEmpty(cameraOutputCap.photoProfiles)) { + if (!isEmpty(cameraOutputCap.photoProfiles)) { console.info(TAG + "cameraOutputCap.photoProfiles.length: " + cameraOutputCap.photoProfiles.length); for (let i = 0; i < cameraOutputCap.photoProfiles.length; i++) { - mPhotoOutput = await mCameraManager.createPhotoOutput(cameraOutputCap.photoProfiles[i], mPhoteSurface); + mPhotoOutput = await mCameraManager.createPhotoOutput(cameraOutputCap.photoProfiles[i], mPhotoSurface); if (!isEmpty(mPhotoOutput)) { break; } @@ -503,9 +502,11 @@ export default function cameraSessionTest(surfaceId: any) { await mCameraSession.addOutput(mVideoOutput); } */ - await sleep(1); + await sleep(100); await commitCameraSessionConfig(); + + await sleep(100); /* await mCameraSession.start(async (err) => { @@ -902,6 +903,104 @@ export default function cameraSessionTest(surfaceId: any) { } }) + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_START_STOP_CALLBACK_0100 + * @tc.name : Check capture session start/stop with callback or not + * @tc.desc : Check capture session start/stop with callback or not + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_START_STOP_CALLBACK_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_START_STOP_CALLBACK_0100--------------"); + + if (mCameraNum == 0) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_START_STOP_CALLBACK_0100 FAILED with NoCamera"); + expect().assertFail(); + done(); + } + else { + for (let i = 0; i < mCameraNum; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_START_STOP_CALLBACK_0100 start for camera[" + i + "]"); + + await startCameraSession(i); + + mCameraSession.start(async (err) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_START_STOP_CALLBACK_0100 start callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_START_STOP_CALLBACK_0100 start PASSED"); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_START_STOP_CALLBACK_0100 start FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(2000); + + mCameraSession.stop(async (err) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_START_STOP_CALLBACK_0100 stop callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_START_STOP_CALLBACK_0100 stop PASSED"); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_START_STOP_CALLBACK_0100 stop FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + await beginCameraSessionConfig(); + + await stopCameraSession(); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_START_STOP_CALLBACK_0100 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_START_STOP_CALLBACK_0100 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_START_STOP_PROMISE_0100 + * @tc.name : Check capture session start/stop output with promise or not + * @tc.desc : Check capture session start/stop output with promise or not + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_START_STOP_PROMISE_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_START_STOP_PROMISE_0100--------------"); + + if (mCameraNum == 0) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_START_STOP_PROMISE_0100 FAILED with NoCamera"); + expect().assertFail(); + done(); + } + else { + for (let i = 0; i < mCameraNum; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_START_STOP_PROMISE_0100 start for camera[" + i + "]"); + + await startCameraSession(i); + + await mCameraSession.start(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_START_STOP_PROMISE_0100 start PASSED"); + await sleep(2000); + + await mCameraSession.stop(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_START_STOP_PROMISE_0100 stop PASSED"); + await sleep(500); + + await beginCameraSessionConfig(); + + await stopCameraSession(); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_START_STOP_PROMISE_0100 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_START_STOP_PROMISE_0100 ends here"); + done(); + } + }) + /** * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_INPUT_CALLBACK_0100 * @tc.name : Check capture session add/remove input with callback or not @@ -1415,6 +1514,22 @@ export default function cameraSessionTest(surfaceId: any) { console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_STATUS_CALLBACK_0100 start for camera[" + i + "]"); await startCameraSession(i); + + let focusModeSupportedFlag = await mCameraSession.isFocusModeSupported(cameraObj.FocusMode.FOCUS_MODE_AUTO); + if (focusModeSupportedFlag == false) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_STATUS_CALLBACK_0100 skip camera[" + i + "], for FOCUS_MODE_AUTO"); + await beginCameraSessionConfig(); + await stopCameraSession(); + continue; + } + + focusModeSupportedFlag = await mCameraSession.isFocusModeSupported(cameraObj.FocusMode.FOCUS_MODE_CONTINUOUS_AUTO); + if (focusModeSupportedFlag == false) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_STATUS_CALLBACK_0100 skip camera[" + i + "], for FOCUS_MODE_CONTINUOUS_AUTO"); + await beginCameraSessionConfig(); + await stopCameraSession(); + continue; + } mCameraSession.on('focusStateChange', async (err, data) => { if (!err) { @@ -1429,16 +1544,31 @@ export default function cameraSessionTest(surfaceId: any) { } await sleep(1); }) + + await mCameraSession.start(); + + await beginCameraSessionConfig(); mCameraSession.setFocusMode(cameraObj.FocusMode.FOCUS_MODE_AUTO); + + await commitCameraSessionConfig(); + + await sleep(1000); + + await beginCameraSessionConfig(); - await sleep(3000); + mCameraSession.setFocusMode(cameraObj.FocusMode.FOCUS_MODE_CONTINUOUS_AUTO); + + await commitCameraSessionConfig(); + + await sleep(1000); if (nfyFlag == false) { //expect().assertFail(); //console.info(TAG + "SUB_MULTIMEDIA_CAMERA_SESSION_STATUS_CALLBACK_0100 FAILED without any nofity!"); } + await mCameraSession.stop(); await beginCameraSessionConfig(); await stopCameraSession(); @@ -1452,8 +1582,8 @@ export default function cameraSessionTest(surfaceId: any) { /** * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_STATUS_CALLBACK_0101 - * @tc.name : camera status callback on CaptureSession async api for exposureStateChange - * @tc.desc : camera status callback on CaptureSession async api for exposureStateChange + * @tc.name : camera status callback on CaptureSession async api for error + * @tc.desc : camera status callback on CaptureSession async api for error * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 2 @@ -1469,11 +1599,11 @@ export default function cameraSessionTest(surfaceId: any) { for (let i = 0; i < mCameraNum; i++) { let nfyFlag = false; - console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_STATUS_CALLBACK_0101 start for camera[" + i + "]"); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_STATUS_CALLBACK_0101 start for camera[" + i + "]"); await startCameraSession(i); - mCameraSession.on('exposureStateChange', async (err, data) => { + mCameraSession.on('error', async (err, data) => { if (!err) { console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_STATUS_CALLBACK_0101 callback"); if (data != null || data != undefined) { @@ -1487,15 +1617,13 @@ export default function cameraSessionTest(surfaceId: any) { await sleep(1); }) - mCameraSession.setExposureMode(cameraObj.ExposureMode.EXPOSURE_MODE_AUTO); - await sleep(3000); if (nfyFlag == false) { //expect().assertFail(); //console.info(TAG + "SUB_MULTIMEDIA_CAMERA_SESSION_STATUS_CALLBACK_0101 FAILED without any nofity!"); } - + await beginCameraSessionConfig(); await stopCameraSession(); @@ -1507,61 +1635,6 @@ export default function cameraSessionTest(surfaceId: any) { } }) - /** - * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_STATUS_CALLBACK_0102 - * @tc.name : camera status callback on CaptureSession async api for error - * @tc.desc : camera status callback on CaptureSession async api for error - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_CAMERA_SESSION_STATUS_CALLBACK_0102', 2, async function (done) { - console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_STATUS_CALLBACK_0102--------------"); - - if (mCameraNum == 0) { - console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_STATUS_CALLBACK_0102 FAILED with NoCamera"); - expect().assertFail(); - done(); - } else { - for (let i = 0; i < mCameraNum; i++) { - let nfyFlag = false; - - console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_STATUS_CALLBACK_0102 start for camera[" + i + "]"); - - await startCameraSession(i); - - mCameraSession.on('error', async (err, data) => { - if (!err) { - console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_STATUS_CALLBACK_0102 callback"); - if (data != null || data != undefined) { - console.info(TAG + "SUB_MULTIMEDIA_CAMERA_SESSION_STATUS_CALLBACK_0102 PASSED: " + data); - nfyFlag = true; - } - } else { - expect().assertFail(); - console.info(TAG + "SUB_MULTIMEDIA_CAMERA_SESSION_STATUS_CALLBACK_0102 FAILED: " + err.message); - } - await sleep(1); - }) - - await sleep(3000); - - if (nfyFlag == false) { - //expect().assertFail(); - //console.info(TAG + "SUB_MULTIMEDIA_CAMERA_SESSION_STATUS_CALLBACK_0102 FAILED without any nofity!"); - } - - await beginCameraSessionConfig(); - await stopCameraSession(); - - console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_STATUS_CALLBACK_0102 end for camera[" + i + "]"); - } - - console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_STATUS_CALLBACK_0102 ends here"); - done(); - } - }) - /** * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_RELEASE_CALLBACK_0100 * @tc.name : Check capture session release with callback or not for preview diff --git a/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraSessionExposureTest.test.ets b/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraSessionExposureTest.test.ets index 6ab8fe7af1e7019bbf95214d33f0b88cacec941b..f71fcf35d722400ca7a29be06e0f6c000c27cd31 100755 --- a/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraSessionExposureTest.test.ets +++ b/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraSessionExposureTest.test.ets @@ -32,7 +32,7 @@ let mCameraManager; let mCameraDevicesArray; let mCameraSession; -let mPhoteSurface; +let mPhotoSurface; let mVideoRecorder; let mVideoSurface; let mFileAsset; @@ -238,8 +238,8 @@ export default function cameraSessionExposureTest(surfaceId: any) { console.log(TAG + 'before receiver check') if (receiver !== undefined) { console.log(TAG + 'Photo receiver is created successfully') - mPhoteSurface = await receiver.getReceivingSurfaceId() - console.log(TAG + 'Photo received id: ' + JSON.stringify(mPhoteSurface)) + mPhotoSurface = await receiver.getReceivingSurfaceId() + console.log(TAG + 'Photo received id: ' + JSON.stringify(mPhotoSurface)) } else { console.log(TAG + 'Photo receiver is created failed') } @@ -473,7 +473,7 @@ export default function cameraSessionExposureTest(surfaceId: any) { console.info(TAG + "cameraOutputCap.photoProfiles.length: " + cameraOutputCap.photoProfiles.length); for (let i = 0; i < cameraOutputCap.photoProfiles.length; i++) { - mPhotoOutput = await mCameraManager.createPhotoOutput(cameraOutputCap.photoProfiles[i], mPhoteSurface); + mPhotoOutput = await mCameraManager.createPhotoOutput(cameraOutputCap.photoProfiles[i], mPhotoSurface); if (!isEmpty(mPhotoOutput)) { break; } diff --git a/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraSessionFlashTest.test.ets b/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraSessionFlashTest.test.ets index 4da6083e657e9ee82d836ef7de9140af19a89e61..abd6c75df443666cf69ef23dc0fb932cfba856d9 100755 --- a/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraSessionFlashTest.test.ets +++ b/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraSessionFlashTest.test.ets @@ -32,7 +32,7 @@ let mCameraManager; let mCameraDevicesArray; let mCameraSession; -let mPhoteSurface; +let mPhotoSurface; let mVideoRecorder; let mVideoSurface; let mFileAsset; @@ -189,8 +189,8 @@ export default function cameraSessionFlashTest(surfaceId: any) { console.log(TAG + 'before receiver check') if (receiver !== undefined) { console.log(TAG + 'Photo receiver is created successfully') - mPhoteSurface = await receiver.getReceivingSurfaceId() - console.log(TAG + 'Photo received id: ' + JSON.stringify(mPhoteSurface)) + mPhotoSurface = await receiver.getReceivingSurfaceId() + console.log(TAG + 'Photo received id: ' + JSON.stringify(mPhotoSurface)) } else { console.log(TAG + 'Photo receiver is created failed') } @@ -424,7 +424,7 @@ export default function cameraSessionFlashTest(surfaceId: any) { console.info(TAG + "cameraOutputCap.photoProfiles.length: " + cameraOutputCap.photoProfiles.length); for (let i = 0; i < cameraOutputCap.photoProfiles.length; i++) { - mPhotoOutput = await mCameraManager.createPhotoOutput(cameraOutputCap.photoProfiles[i], mPhoteSurface); + mPhotoOutput = await mCameraManager.createPhotoOutput(cameraOutputCap.photoProfiles[i], mPhotoSurface); if (!isEmpty(mPhotoOutput)) { break; } diff --git a/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraSessionFocusTest.test.ets b/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraSessionFocusTest.test.ets index 37112c121940a272a2308c9aba2a64997795b475..092e673817eef2c9846f51644ccd3fc723e0b176 100755 --- a/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraSessionFocusTest.test.ets +++ b/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraSessionFocusTest.test.ets @@ -32,7 +32,7 @@ let mCameraManager; let mCameraDevicesArray; let mCameraSession; -let mPhoteSurface; +let mPhotoSurface; let mVideoRecorder; let mVideoSurface; let mFileAsset; @@ -235,8 +235,8 @@ export default function cameraSessionFocusTest(surfaceId: any) { console.log(TAG + 'before receiver check') if (receiver !== undefined) { console.log(TAG + 'Photo receiver is created successfully') - mPhoteSurface = await receiver.getReceivingSurfaceId() - console.log(TAG + 'Photo received id: ' + JSON.stringify(mPhoteSurface)) + mPhotoSurface = await receiver.getReceivingSurfaceId() + console.log(TAG + 'Photo received id: ' + JSON.stringify(mPhotoSurface)) } else { console.log(TAG + 'Photo receiver is created failed') } @@ -469,7 +469,7 @@ export default function cameraSessionFocusTest(surfaceId: any) { console.info(TAG + "cameraOutputCap.photoProfiles.length: " + cameraOutputCap.photoProfiles.length); for (let i = 0; i < cameraOutputCap.photoProfiles.length; i++) { - mPhotoOutput = await mCameraManager.createPhotoOutput(cameraOutputCap.photoProfiles[i], mPhoteSurface); + mPhotoOutput = await mCameraManager.createPhotoOutput(cameraOutputCap.photoProfiles[i], mPhotoSurface); if (!isEmpty(mPhotoOutput)) { break; } diff --git a/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraSessionVideoStabilizationTest.test.ets b/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraSessionVideoStabilizationTest.test.ets index aac3571a696bf3efa394864a4063ea49c6c180c8..263cd9d70d15981f71b3f74ca696790dcd9f79b6 100755 --- a/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraSessionVideoStabilizationTest.test.ets +++ b/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraSessionVideoStabilizationTest.test.ets @@ -32,7 +32,7 @@ let mCameraManager; let mCameraDevicesArray; let mCameraSession; -let mPhoteSurface; +let mPhotoSurface; let mVideoRecorder; let mVideoSurface; let mFileAsset; @@ -188,8 +188,8 @@ export default function cameraSessionVideoStabilizationTest(surfaceId: any) { console.log(TAG + 'before receiver check') if (receiver !== undefined) { console.log(TAG + 'Photo receiver is created successfully') - mPhoteSurface = await receiver.getReceivingSurfaceId() - console.log(TAG + 'Photo received id: ' + JSON.stringify(mPhoteSurface)) + mPhotoSurface = await receiver.getReceivingSurfaceId() + console.log(TAG + 'Photo received id: ' + JSON.stringify(mPhotoSurface)) } else { console.log(TAG + 'Photo receiver is created failed') } @@ -422,7 +422,7 @@ export default function cameraSessionVideoStabilizationTest(surfaceId: any) { console.info(TAG + "cameraOutputCap.photoProfiles.length: " + cameraOutputCap.photoProfiles.length); for (let i = 0; i < cameraOutputCap.photoProfiles.length; i++) { - mPhotoOutput = await mCameraManager.createPhotoOutput(cameraOutputCap.photoProfiles[i], mPhoteSurface); + mPhotoOutput = await mCameraManager.createPhotoOutput(cameraOutputCap.photoProfiles[i], mPhotoSurface); if (!isEmpty(mPhotoOutput)) { break; } diff --git a/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraSessionZoomRatioTest.test.ets b/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraSessionZoomRatioTest.test.ets index c943a9b30eed325ff0c9cb48915f5f16f837f1b7..85e6261fa1895d4760a1dc171933b176fab7453a 100755 --- a/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraSessionZoomRatioTest.test.ets +++ b/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraSessionZoomRatioTest.test.ets @@ -32,7 +32,7 @@ let mCameraManager; let mCameraDevicesArray; let mCameraSession; -let mPhoteSurface; +let mPhotoSurface; let mVideoRecorder; let mVideoSurface; let mFileAsset; @@ -190,8 +190,8 @@ export default function cameraSessionZoomRatioTest(surfaceId: any) { console.log(TAG + 'before receiver check') if (receiver !== undefined) { console.log(TAG + 'Photo receiver is created successfully') - mPhoteSurface = await receiver.getReceivingSurfaceId() - console.log(TAG + 'Photo received id: ' + JSON.stringify(mPhoteSurface)) + mPhotoSurface = await receiver.getReceivingSurfaceId() + console.log(TAG + 'Photo received id: ' + JSON.stringify(mPhotoSurface)) } else { console.log(TAG + 'Photo receiver is created failed') } @@ -426,7 +426,7 @@ export default function cameraSessionZoomRatioTest(surfaceId: any) { console.info(TAG + "cameraOutputCap.photoProfiles.length: " + cameraOutputCap.photoProfiles.length); for (let i = 0; i < cameraOutputCap.photoProfiles.length; i++) { - mPhotoOutput = await mCameraManager.createPhotoOutput(cameraOutputCap.photoProfiles[i], mPhoteSurface); + mPhotoOutput = await mCameraManager.createPhotoOutput(cameraOutputCap.photoProfiles[i], mPhotoSurface); if (!isEmpty(mPhotoOutput)) { break; }