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 old mode 100644 new mode 100755 index 2743a3a6f94f359e98785fa0a21bf1518e7a9859..7b12db6095dfb5b40003306b54020e4bd555a53e --- 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 @@ -13,12 +13,16 @@ * limitations under the License. */ -import cameraJSUnitEnum from './CameraJSUnitEnum.test.ets' -import cameraJSUnitCameraFormat from './CameraJSUnitCameraFormat.test.ets' -import cameraJSUnitPhotoAsync from './CameraJSUnitPhotoAsync.test.ets' -import cameraJSUnitPhotoPromise from './CameraJSUnitPhotoPromise.test.ets' -import cameraJSUnitVideoAsync from './CameraJSUnitVideoAsync.test.ets' -import cameraJSUnitVideoPromise from './CameraJSUnitVideoPromise.test.ets' +import cameraJSUnitOutput from './CameraJSUnitOutput.test.ets' + +import cameraSessionFlashTest from './CameraSessionFlashTest.test.ets' +import cameraSessionExposureTest from './CameraSessionExposureTest.test.ets' +import cameraSessionFocusTest from './CameraSessionFocusTest.test.ets' +import cameraSessionZoomRatioTest from './CameraSessionZoomRatioTest.test.ets' +import cameraSessionVideoStabilizationTest from './CameraSessionVideoStabilizationTest.test.ets' +import cameraSessionBaseTest from './CameraSessionBaseTest.test.ets' +import cameraInputTest from './CameraInputTest.test.ets' +import cameraManagerTest from './CameraManagerTest.test.ets' let TAG = 'CameraModuleTest: ' @@ -26,10 +30,13 @@ export default function cameraKit(surfaceId: any) { console.info(TAG + 'Entering cameraKit') console.info(TAG + 'surfaceId: ' + surfaceId) - cameraJSUnitEnum(surfaceId) - cameraJSUnitCameraFormat(surfaceId) - cameraJSUnitPhotoAsync(surfaceId) - cameraJSUnitPhotoPromise(surfaceId) - cameraJSUnitVideoAsync(surfaceId) - cameraJSUnitVideoPromise(surfaceId) + cameraInputTest(surfaceId) + cameraJSUnitOutput(surfaceId) + cameraSessionFlashTest(surfaceId) + cameraSessionExposureTest(surfaceId) + cameraSessionFocusTest(surfaceId) + cameraSessionZoomRatioTest(surfaceId) + cameraSessionVideoStabilizationTest(surfaceId) + cameraSessionBaseTest(surfaceId) + cameraManagerTest(surfaceId) } \ 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 new file mode 100755 index 0000000000000000000000000000000000000000..a67ee7b848bfa039b8996301859da048d54b88f0 --- /dev/null +++ b/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraInputTest.test.ets @@ -0,0 +1,275 @@ +/* + * 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 cameraObj from '@ohos.multimedia.camera'; +import image from '@ohos.multimedia.image'; +import abilityAccessCtrl from '@ohos.abilityAccessCtrl' +import bundle from '@ohos.bundle' +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'; + +const TAG = "CameraInputTest: "; + +// Define global variables +let mCameraManager; +let surfaceId1; +let mCameraDevicesArray; + +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'); + } + } + 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(); + if (atManager != null) { + let tokenID = appInfo.accessTokenId; + console.info('[permission] case accessTokenID is ' + tokenID); + let permissionName1 = 'ohos.permission.CAMERA'; + let permissionName2 = 'ohos.permission.MICROPHONE'; + let permissionName3 = 'ohos.permission.MEDIA_LOCATION'; + let permissionName4 = 'ohos.permission.READ_MEDIA'; + let permissionName5 = 'ohos.permission.WRITE_MEDIA'; + await atManager.grantUserGrantedPermission(tokenID, permissionName1, 1).then((result) => { + console.info('[permission] case grantUserGrantedPermission success :' + result); + }).catch((err) => { + console.info('[permission] case grantUserGrantedPermission failed :' + err); + }); + await atManager.grantUserGrantedPermission(tokenID, permissionName2, 1).then((result) => { + console.info('[permission] case grantUserGrantedPermission success :' + result); + }).catch((err) => { + console.info('[permission] case grantUserGrantedPermission failed :' + err); + }); + await atManager.grantUserGrantedPermission(tokenID, permissionName3, 1).then((result) => { + console.info('[permission] case grantUserGrantedPermission success :' + result); + }).catch((err) => { + console.info('[permission] case grantUserGrantedPermission failed :' + err); + }); + await atManager.grantUserGrantedPermission(tokenID, permissionName4, 1).then((result) => { + console.info('[permission] case grantUserGrantedPermission success :' + result); + }).catch((err) => { + console.info('[permission] case grantUserGrantedPermission failed :' + err); + }); + await atManager.grantUserGrantedPermission(tokenID, permissionName5, 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'); + } + } + +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_CALLBACK_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_CALLBACK_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_CALLBACK_0100--------------"); + if (isEmpty(mCameraManager)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_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) => { + 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 + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_CALLBACK_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) => { + 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(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(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); + }).catch((err) => { + expect().assertFail(); + console.info(TAG + "Failed To create cameraInput cameraId: " + camerasArray[i].cameraId + +JSON.stringify(err)); + }); + } + } + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_RELEASE_CALLBACK_0100 ends here"); + 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 new file mode 100755 index 0000000000000000000000000000000000000000..6e5f40a1dc94df153923c2276b23f228d42d04e6 --- /dev/null +++ b/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraJSUnitOutput.test.ets @@ -0,0 +1,1447 @@ +/* + * 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 cameraObj from '@ohos.multimedia.camera'; +import image from '@ohos.multimedia.image'; +import media from '@ohos.multimedia.media' +import abilityAccessCtrl from '@ohos.abilityAccessCtrl' +import bundle from '@ohos.bundle' +import mediaLibrary from '@ohos.multimedia.mediaLibrary' +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; + +const TAG = "CameraUnitTest: "; + +let captureSetting = { +} + +// 创建视频录制的参数 +let videoProfile = { + audioBitrate: 48000, + audioChannels: 2, + audioCodec: 'audio/mp4a-latm', + audioSampleRate: 48000, + fileFormat: 'mp4', + videoBitrate: 48000, + videoCodec: 'video/mp4v-es', + videoFrameWidth: 640, + videoFrameHeight: 480, + videoFrameRate: 30 +} + +let videoConfig = { + audioSourceType: 1, + videoSourceType: 0, + profile: videoProfile, + url: 'file:///data/media/CameraOutput.mp4', + orientationHint: 0, + location: { latitude: 30, longitude: 130 }, + maxSize: 100, + maxDuration: 500 +} + +// 创建录像输出流 +let videoRecorder + +let surfaceId1 +let cameraManager; +let cameraDevicesArray; +let captureSession; +let cameraInput; +let previewOutput; +let photoOutput; +let videoOutput; +let videoSurfaceId; +let fdPath; +let fileAsset; +let fdNumber; + +export default function cameraJSUnitOutput(surfaceId: any) { + + async function getImageReceiverSurfaceId() { + console.log(TAG + 'Entering create Image receiver') + var 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') + } + } + + async function getFd(pathName) { + let displayName = pathName; + const mediaTest = mediaLibrary.getMediaLibrary(); + let fileKeyObj = mediaLibrary.FileKey; + let mediaType = mediaLibrary.MediaType.VIDEO; + let publicPath = await mediaTest.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO); + let dataUri = await mediaTest.createAsset(mediaType, displayName, publicPath); + if (dataUri != undefined) { + let args = dataUri.id.toString(); + let fetchOp = { + selections: fileKeyObj.ID + "=?", + selectionArgs: [args], + } + let fetchFileResult = await mediaTest.getFileAssets(fetchOp); + fileAsset = await fetchFileResult.getAllObject(); + fdNumber = await fileAsset[0].open('Rw'); + fdPath = "fd://" + fdNumber.toString(); + } + } + + async function closeFd() { + if (fileAsset != null) { + await fileAsset[0].close(fdNumber).then(() => { + console.info('[mediaLibrary] case close fd success'); + }).catch((err) => { + console.info('[mediaLibrary] case close fd failed'); + }); + } else { + console.info('[mediaLibrary] case fileAsset is null'); + } + } + + + async function getvideosurface() { + await getFd('CameraOutput.mp4'); + videoConfig.url = fdPath; + media.createVideoRecorder((err, recorder) => { + console.info(TAG + 'createVideoRecorder called') + videoRecorder = recorder + console.info(TAG + 'videoRecorder is :' + JSON.stringify(videoRecorder)) + console.info(TAG + 'videoRecorder.prepare called.') + videoRecorder.prepare(videoConfig, (err) => { + console.info(TAG + 'videoRecorder.prepare success.') + }) + videoRecorder.getInputSurface((err, id) => { + console.info(TAG + 'getInputSurface called') + videoSurfaceId = id + console.info(TAG + 'getInputSurface surfaceId: ' + JSON.stringify(videoSurfaceId)) + }) + }) + } + + async function release() { + console.log(TAG +"start release"); + await cameraInput.release(); + await captureSession.release(); + console.log(TAG +"release end") + } + + + function sleep(ms) { + console.info(TAG + "Entering sleep -> Promise constructor"); + return new Promise(resolve => setTimeout(resolve, ms)); + } + + function isEmpty(data) { + if (data == null || data == undefined) { + return true; + } + return false; + } + + async function applyPermission() { + let appInfo = await bundle.getApplicationInfo('com.open.harmony.multimedia.cameratest', 0, 100); + let atManager = abilityAccessCtrl.createAtManager(); + if (atManager != null) { + let tokenID = appInfo.accessTokenId; + console.info('[permission] case accessTokenID is ' + tokenID); + let permissionName1 = 'ohos.permission.CAMERA'; + let permissionName2 = 'ohos.permission.MICROPHONE'; + let permissionName3 = 'ohos.permission.MEDIA_LOCATION'; + let permissionName4 = 'ohos.permission.READ_MEDIA'; + let permissionName5 = 'ohos.permission.WRITE_MEDIA'; + let permissionName6 = 'ohos.permission.START_ABILITIES_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) => { + console.info('[permission] case grantUserGrantedPermission failed :' + err); + }); + await atManager.grantUserGrantedPermission(tokenID, permissionName2, 1).then((result) => { + console.info('[permission] case grantUserGrantedPermission success :' + result); + }).catch((err) => { + console.info('[permission] case grantUserGrantedPermission failed :' + err); + }); + await atManager.grantUserGrantedPermission(tokenID, permissionName3, 1).then((result) => { + console.info('[permission] case grantUserGrantedPermission success :' + result); + }).catch((err) => { + console.info('[permission] case grantUserGrantedPermission failed :' + err); + }); + await atManager.grantUserGrantedPermission(tokenID, permissionName4, 1).then((result) => { + console.info('[permission] case grantUserGrantedPermission success :' + result); + }).catch((err) => { + console.info('[permission] case grantUserGrantedPermission failed :' + err); + }); + await atManager.grantUserGrantedPermission(tokenID, permissionName5, 1).then((result) => { + console.info('[permission] case grantUserGrantedPermission success :' + result); + }).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'); + } + } + + function getSupportedOutputCapabilityInPromise(cameraDevice) { + if (isEmpty(cameraManager)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_PROMISE_0100 cameraManager == null || undefined") + expect().assertFail(); + return undefined; + } + let outputCapabilityPromise = cameraManager.getSupportedOutputCapability(cameraDevice); + console.info("CameraUnitTest: Entering testSupportedOutputCapabilityPromise: " + JSON.stringify(outputCapabilityPromise)); + expect(isEmpty(outputCapabilityPromise)).assertFalse(); + + return outputCapabilityPromise; + } + + describe('cameraJSUnitOutput', function () { + console.info(TAG + '----------cameraJSUnitOutput begin--------------') + + beforeAll(async function () { + await applyPermission(); + await getImageReceiverSurfaceId(); + await getvideosurface(); + console.info('beforeAll case'); + }) + + beforeEach(function () { + sleep(5000); + console.info('beforeEach case'); + }) + + afterEach(async function () { + console.info('afterEach case'); + }) + + afterAll(function () { + closeFd(); + release(); + console.info('afterAll case'); + }) + + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_GET_CAMERA_MANAGER_0100 + * @tc.name : Create CameraManager instance async api + * @tc.desc : Create CameraManager instance async api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_GET_CAMERA_MANAGER_0100', 0, async function (done) { + console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_GET_CAMERA_MANAGER_0100--------------"); + if (isEmpty(cameraObj)) { + console.info(TAG + "Entering GET_CAMERA_MANAGER cameraManager == null || undefined") + expect().assertFail(); + } else { + cameraObj.getCameraManager(null, async (err, data) => { + if (!err) { + expect(isEmpty(data)).assertFalse(); + console.info(TAG + "Entering GET_CAMERA_MANAGER success"); + cameraManager = data; + } else { + expect().assertFail(); + console.info(TAG + "Entering GET_CAMERA_MANAGER FAILED: " + err.message); + } + console.info(TAG + "Entering GET_CAMERA_MANAGER ends here"); + await sleep(1000); + done(); + }) + await sleep(1000); + done(); + } + }) + + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_CALLBACK_0100 + * @tc.name : Get camera from cameramanager to get array of camera async api + * @tc.desc : Get camera from cameramanager to get array of camera async api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_0100', 0, async function (done) { + console.info("--------------GET_CAMERAS--------------"); + if (isEmpty(cameraManager)) { + console.info(TAG + "Entering GET_CAMERAS cameraManager == null || undefined") + expect().assertFail(); + } + cameraManager.getSupportedCameras(async (err, data) => { + if (!err) { + console.info(TAG + "Entering GET_CAMERAS success"); + if (isEmpty(data)) { + expect().assertFail(); + console.info(TAG + "Entering GET_CAMERAS FAILED cameraArray is null || undefined"); + } else { + console.info(TAG + "Entering GET_CAMERAS data is not null || undefined"); + cameraDevicesArray = data; + if (cameraDevicesArray != null && cameraDevicesArray.length > 0) { + for (let i = 0; i < cameraDevicesArray.length; i++) { + // Get the variables from camera object + let cameraId = cameraDevicesArray[i].cameraId; + expect(isEmpty(cameraId)).assertFalse(); + console.info(TAG + "Entering GET_CAMERAS camera" + i + "Id: " + cameraId); + let cameraPosition = cameraDevicesArray[i].cameraPosition; + expect(isEmpty(cameraPosition)).assertFalse(); + console.info(TAG + "Entering GET_CAMERAS camera" + i + "Position: " + cameraPosition); + let cameraType = cameraDevicesArray[i].cameraType; + expect(isEmpty(cameraType)).assertFalse(); + console.info(TAG + "Entering GET_CAMERAS camera" + i + "Type: " + cameraType); + let connectionType = cameraDevicesArray[i].connectionType + expect(isEmpty(connectionType)).assertFalse(); + console.info(TAG + "Entering GET_CAMERAS connection" + i + "Type: " + connectionType); + } + expect(true).assertTrue(); + console.info(TAG + "Entering GET_CAMERAS PASSED"); + } + } + } else { + expect().assertFail(); + console.info(TAG + "Entering GET_CAMERAS FAILED: " + err.message); + } + console.info(TAG + "Entering GET_CAMERAS ends here"); + await sleep(1000); + done(); + }) + await sleep(1000); + done(); + }) + + + + /** + * @tc.number : CREATE_PREVIEW_OUTPUT + * @tc.name : Create previewOutput instance async api + * @tc.desc : Create previewOutput instance async api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_0100', 0, async function (done) { + console.info(TAG + " --------------CREATE_CAMERA_INPUT--------------"); + if (isEmpty(cameraManager)) { + console.info(TAG + "Entering CREATE_CAMERA_INPUT cameraManager == null || undefined") + expect().assertFail(); + } else { + cameraInput = await cameraManager.createCameraInput(cameraDevicesArray[0]); + if (isEmpty(cameraInput)) { + console.info(TAG + "CREATE_CAMERA_INPUT FAILED"); + } + cameraInput.open(async (err) => { + if (!err) { + console.info(TAG + "Entering CREATE_CAMERA_INPUT open callback"); + } else { + console.info(TAG + "Entering CREATE_CAMERA_INPUT FAILED: " + err.message); + } + await sleep(1000); + done(); + }) + } + }) + + + + /** + * @tc.number : CREATE_PREVIEW_OUTPUT + * @tc.name : Create previewOutput instance async api + * @tc.desc : Create previewOutput instance async api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_CREATE_PREVIEW_OUTPUT_0100', 0, async function (done) { + console.info(TAG + " --------------CREATE_PREVIEW_OUTPUT--------------"); + if (isEmpty(cameraManager)) { + console.info(TAG + "Entering CREATE_PREVIEW_OUTPUT cameraManager == null || undefined") + expect().assertFail(); + } else { + console.info(TAG + "Entering CREATE_PREVIEW_OUTPUT") + let cameraOutputCap = await getSupportedOutputCapabilityInPromise(cameraDevicesArray[0]); + let previewProfilesArray = cameraOutputCap.previewProfiles; + if (isEmpty(previewProfilesArray)) { + console.info(TAG + "Entering CREATE_PREVIEW_OUTPUT previewProfilesArray == null || undefined") + expect(isEmpty(previewProfilesArray)).assertFalse(); + } + cameraManager.createPreviewOutput(previewProfilesArray[0], surfaceId, async (err, data) => { + if (!err) { + console.info(TAG + "Entering CREATE_PREVIEW_OUTPUT is not error"); + expect(isEmpty(data)).assertFalse(); + console.info(TAG + "Entering CREATE_PREVIEW_OUTPUT success"); + previewOutput = data; + } else { + expect().assertFail(); + console.info(TAG + "Entering CREATE_PREVIEW_OUTPUT FAILED: " + err.message); + } + console.info(TAG + "Entering CREATE_PREVIEW_OUTPUT ends here"); + await sleep(1000); + done(); + }) + } + await sleep(1000); + done(); + }) + + + + /** + * @tc.number : CREATE_PHOTO_OUTPUT + * @tc.name : Create photoOutput instance async api + * @tc.desc : Create photoOutput instance async api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_CREATE_PHOTO_OUTPUT_0100', 0, async function (done) { + console.info(TAG + " --------------CREATE_PHOTO_OUTPUT--------------"); + if (isEmpty(cameraManager)) { + console.info(TAG + "Entering CREATE_PHOTO_OUTPUT cameraManager == null || undefined") + expect().assertFail(); + } else { + let cameraOutputCap = await getSupportedOutputCapabilityInPromise(cameraDevicesArray[0]); + let photoProfilesArray = cameraOutputCap.photoProfiles; + if (isEmpty(photoProfilesArray)) { + console.info(TAG + "Entering CREATE_PREVIEW_OUTPUT previewProfilesArray == null || undefined") + expect().assertFalse(); + } + photoOutput = await cameraManager.createPhotoOutput(photoProfilesArray[0], surfaceId1); + if (isEmpty(photoOutput)) { + console.info(TAG + "Entering CREATE_PHOTO_OUTPUT data is empty"); + expect().assertFalse(); + } + } + await sleep(1000); + done(); + }) + + + + /** + * @tc.number : CREATE_VIDEO_OUTPUT + * @tc.name : Create previewOutput instance async api + * @tc.desc : Create previewOutput instance async api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_CREATE_VIDEO_OUTPUT_0100', 0, async function (done) { + console.info(TAG + " --------------CREATE_VIDEO_OUTPUT--------------"); + if (isEmpty(cameraManager)) { + console.info(TAG + "Entering CREATE_VIDEO_OUTPUT cameraManager == null || undefined") + expect().assertFail(); + } else { + let cameraOutputCap = await getSupportedOutputCapabilityInPromise(cameraDevicesArray[0]); + console.info("CREATE_VIDEO_OUTPUT camera:" + cameraDevicesArray[0].cameraId); + expect(isEmpty(cameraOutputCap)).assertFalse(); + let videoProfilesArray = cameraOutputCap.videoProfiles; + expect(isEmpty(videoProfilesArray)).assertFalse(); + console.info(TAG + "Entering CREATE_VIDEO_OUTPUT start createVideoOutput") + cameraManager.createVideoOutput(videoProfilesArray[0], videoSurfaceId, async (err, data) => { + if (!err) { + console.info(TAG + "Entering CREATE_VIDEO_OUTPUT is not error"); + expect(isEmpty(data)).assertFalse(); + console.info(TAG + "Entering CREATE_VIDEO_OUTPUT success"); + videoOutput = data; + } else { + console.info(TAG + "Entering CREATE_VIDEO_OUTPUT FAILED: " + err.message); + expect().assertFail(); + } + console.info(TAG + "Entering CREATE_VIDEO_OUTPUT ends here"); + await sleep(1000); + done(); + }) + } + await sleep(1000); + done(); + }) + + + + /** + * @tc.number : CREATE_CAPTURE_SESSION + * @tc.name : Create CaptureSession instance api + * @tc.desc : Create CaptureSession instance api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_CREATE_CAPTURE_SESSION_0100', 0, async function (done) { + console.info(TAG + "--------------CREATE_CAPTURE_SESSION--------------"); + if (isEmpty(cameraManager)) { + console.info(TAG + "Entering CREATE_CAPTURE_SESSION cameraManager == null || undefined") + expect().assertFail(); + } else { + console.info(TAG + "Entering CREATE_CAPTURE_SESSION") + cameraManager.createCaptureSession(async (err, data) => { + if (!err) { + console.info(TAG + "Entering createCaptureSession is not error"); + expect(isEmpty(data)).assertFalse(); + captureSession = data; + console.info(TAG + "Entering CREATE_CAPTURE_SESSION PASSED"); + } else { + console.info(TAG + "Entering CREATE_CAPTURE_SESSION FAILED : " + err.message); + expect().assertFail(); + } + console.info(TAG + "Entering CREATE_CAPTURE_SESSION ends here"); + await sleep(1000); + done(); + }) + } + await sleep(1000); + done(); + }) + + + /** + * @tc.number : CAPTURE_SESSION_BEGIN_CONFIG + * @tc.name : captureSession beginConfig + * @tc.desc : captureSession beginConfig + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_BEGIN_CONFIG_0100', 0, async function (done) { + console.info(TAG + " --------------CAPTURE_SESSION_BEGIN_CONFIG--------------"); + if (isEmpty(captureSession)) { + console.info(TAG + "Entering CAPTURE_SESSION_BEGIN_CONFIG captureSession == null || undefined") + expect().assertFail(); + } else { + captureSession.beginConfig(async (err, data) => { + if (!err) { + expect(true).assertTrue(); + console.info(TAG + "Entering CAPTURE_SESSION_BEGIN_CONFIG success"); + } else { + expect().assertFail(); + console.info(TAG + "Entering CAPTURE_SESSION_BEGIN_CONFIG FAILED: " + err.message); + } + console.info(TAG + "Entering CAPTURE_SESSION_BEGIN_CONFIG ends here"); + await sleep(1000); + done(); + }) + } + await sleep(1000); + done(); + }) + + + + /** + * @tc.number : CAPTURE_SESSION_ADD_INPUT + * @tc.name : captureSession addInput + * @tc.desc : captureSession addInput + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_ADD_INPUT_0100', 0, async function (done) { + console.info(TAG + " --------------CAPTURE_SESSION_ADD_INPUT--------------"); + if (isEmpty(captureSession)) { + console.info(TAG + "Entering CAPTURE_SESSION_ADD_INPUT captureSession == null || undefined") + expect().assertFail(); + } else { + captureSession.addInput(cameraInput, async (err, data) => { + if (!err) { + expect(true).assertTrue(); + console.info(TAG + "Entering CAPTURE_SESSION_ADD_INPUT success"); + } else { + expect().assertFail(); + console.info(TAG + "Entering CAPTURE_SESSION_ADD_INPUT FAILED: " + err.message); + } + console.info(TAG + "Entering CAPTURE_SESSION_ADD_INPUT ends here"); + await sleep(1000); + done(); + }) + } + await sleep(1000); + done(); + }) + + + + /** + * @tc.number : CAPTURE_SESSION_ADD_PREVIEW_OUTPUT + * @tc.name : captureSession add previewOutput + * @tc.desc : captureSession add previewOutput + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_ADD_PREVIEW_OUTPUT_0100', 0, async function (done) { + console.info(TAG + " --------------CAPTURE_SESSION_ADD_PREVIEW_OUTPUT--------------"); + if (isEmpty(captureSession)) { + console.info(TAG + "Entering CAPTURE_SESSION_ADD_PREVIEW_OUTPUT captureSession == null || undefined") + expect().assertFail(); + } else { + if (isEmpty(previewOutput)) { + console.info(TAG + "Entering CAPTURE_SESSION_ADD_PREVIEW_OUTPUT previewOutput == null || undefined") + expect().assertFail(); + } + captureSession.addOutput(previewOutput, async (err, data) => { + if (!err) { + console.info(TAG + "Entering CAPTURE_SESSION_ADD_PREVIEW_OUTPUT success"); + expect(true).assertTrue(); + } else { + console.info(TAG + "Entering CAPTURE_SESSION_ADD_PREVIEW_OUTPUT FAILED: " + err.message); + expect().assertFail(); + } + console.info(TAG + "Entering CAPTURE_SESSION_ADD_PREVIEW_OUTPUT ends here"); + await sleep(1000); + done(); + }) + } + await sleep(1000); + done(); + }) + + + /** + * @tc.number : CAPTURE_SESSION_ADD_PHOTO_OUTPUT + * @tc.name : captureSession add photoOutput + * @tc.desc : captureSession add photoOutput + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_ADD_PHOTO_OUTPUT_0100', 0, async function (done) { + console.info(TAG + " --------------CAPTURE_SESSION_ADD_PHOTO_OUTPUT--------------"); + if (isEmpty(captureSession)) { + console.info(TAG + "Entering CAPTURE_SESSION_ADD_PHOTO_OUTPUT captureSession == null || undefined") + expect().assertFail(); + } else { + if (isEmpty(photoOutput)) { + console.info(TAG + "Entering CAPTURE_SESSION_ADD_PHOTO_OUTPUT photoOutput == null || undefined") + expect().assertFail(); + } + console.info(TAG + "captureSession start add photoOutput") + captureSession.addOutput(photoOutput, async (err, data) => { + if (!err) { + expect(true).assertTrue(); + console.info(TAG + "Entering CAPTURE_SESSION_ADD_PHOTO_OUTPUT success"); + } else { + console.info(TAG + "Entering CAPTURE_SESSION_ADD_PHOTO_OUTPUT FAILED: " + err.message); + expect().assertFail(); + } + console.info(TAG + "Entering CAPTURE_SESSION_ADD_PHOTO_OUTPUT ends here"); + await sleep(1000); + done(); + }) + } + await sleep(1000); + done(); + }) + + + /** + * @tc.number : CAPTURE_SESSION_REMOVE_PHOTO_OUTPUT + * @tc.name : captureSession remove photoOutput + * @tc.desc : captureSession remove photoOutput + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_ADD_VIDEO_OUTPUT_0100', 0, async function (done) { + console.info(TAG + " --------------CAPTURE_SESSION_ADD_VIDEO_OUTPUT--------------"); + if (isEmpty(captureSession)) { + console.info(TAG + "Entering CAPTURE_SESSION_ADD_VIDEO_OUTPUT captureSession == null || undefined") + expect().assertFail(); + } else { + captureSession.addOutput(videoOutput, async (err, data) => { + if (!err) { + expect(true).assertTrue(); + console.info(TAG + "Entering CAPTURE_SESSION_ADD_VIDEO_OUTPUT success"); + } else { + console.info(TAG + "Entering CAPTURE_SESSION_ADD_VIDEO_OUTPUT FAILED: " + err.message); + expect().assertFail(); + } + console.info(TAG + "Entering CAPTURE_SESSION_ADD_VIDEO_OUTPUT ends here"); + await sleep(1000); + done(); + }) + } + await sleep(1000); + done(); + }) + + + + /** + * @tc.number : CAPTURE_SESSION_COMMIT_CONFIG + * @tc.name : captureSession commitConfig + * @tc.desc : captureSession commitConfig + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_COMMIT_CONFIG_0100', 0, async function (done) { + console.info(TAG + " --------------CAPTURE_SESSION_COMMIT_CONFIG--------------"); + if (isEmpty(captureSession)) { + console.info(TAG + "Entering CAPTURE_SESSION_COMMIT_CONFIG captureSession == null || undefined") + expect().assertFail(); + } else { + captureSession.commitConfig(async (err, data) => { + if (!err) { + console.info(TAG + "Entering CAPTURE_SESSION_COMMIT_CONFIG success"); + expect(true).assertTrue(); + } else { + console.info(TAG + "Entering CAPTURE_SESSION_COMMIT_CONFIG FAILED: " + err.message); + expect().assertFail(); + } + console.info(TAG + "Entering CAPTURE_SESSION_COMMIT_CONFIG ends here"); + await sleep(1000); + done(); + }) + } + await sleep(1000); + done(); + }) + + + + /** + * @tc.number : CAPTURE_SESSION_START + * @tc.name : captureSession start + * @tc.desc : captureSession start + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_START_0100', 0, async function (done) { + console.info(TAG + " --------------CAPTURE_SESSION_START--------------"); + if (isEmpty(captureSession)) { + console.info(TAG + "Entering CAPTURE_SESSION_START captureSession == null || undefined") + expect().assertFail(); + } else { + captureSession.start(async (err, data) => { + if (!err) { + console.info(TAG + "Entering CAPTURE_SESSION_START success"); + expect(true).assertTrue(); + } else { + console.info(TAG + "Entering CAPTURE_SESSION_START FAILED: " + err.message); + expect().assertFail(); + } + console.info(TAG + "Entering CAPTURE_SESSION_START ends here"); + await sleep(1000); + done(); + }) + } + await sleep(1000); + done(); + }) + + + + /** + * @tc.number : START_PREVIEW_OUTPUT_PROMISE + * @tc.name : Create previewOutput instance promise api + * @tc.desc : Create previewOutput instance promise api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_START_PREVIEW_OUTPUT_PROMISE_0100', 0, async function (done) { + console.info(TAG + " --------------START_PREVIEW_OUTPUT_PROMISE--------------"); + if (isEmpty(previewOutput)) { + console.info(TAG + "Entering START_PREVIEW_OUTPUT_PROMISE previewOutput == null || undefined") + expect().assertFail(); + } else { + console.info(TAG + "Entering START_PREVIEW_OUTPUT_PROMISE start") + previewOutput.start(); + console.info(TAG + "Entering START_PREVIEW_OUTPUT_PROMISE end") + } + await sleep(1000); + done(); + }) + + + /** + * @tc.number : STOP_PREVIEW_OUTPUT_PROMISE + * @tc.name : Create previewOutput instance promise api + * @tc.desc : Create previewOutput instance promise api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_STOP_PREVIEW_OUTPUT_PROMISE_0100', 0, async function (done) { + console.info(TAG + " --------------STOP_PREVIEW_OUTPUT_PROMISE--------------"); + if (isEmpty(previewOutput)) { + console.info(TAG + "Entering STOP_PREVIEW_OUTPUT_PROMISE previewOutput == null || undefined") + expect().assertFail(); + } else { + console.info(TAG + "Entering STOP_PREVIEW_OUTPUT_PROMISE start") + previewOutput.stop(); + console.info(TAG + "Entering STOP_PREVIEW_OUTPUT_PROMISE end") + } + await sleep(1000); + done(); + }) + + + + + /** + * @tc.number : START_PREVIEW_OUTPUT_ASYNC + * @tc.name : Create previewOutput instance async api + * @tc.desc : Create previewOutput instance async api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_START_PREVIEW_OUTPUT_ASYNC_0100', 0, async function (done) { + console.info(TAG + " --------------START_PREVIEW_OUTPUT_ASYNC--------------"); + if (isEmpty(previewOutput)) { + console.info(TAG + "Entering START_PREVIEW_OUTPUT_ASYNC previewOutput == null || undefined") + expect().assertFail(); + } else { + previewOutput.start(async (err, data) => { + if (!err) { + console.info(TAG + "Entering START_PREVIEW_OUTPUT_ASYNC success"); + expect(true).assertTrue(); + } else { + console.info(TAG + "Entering START_PREVIEW_OUTPUT_ASYNC FAILED: " + err.message); + expect().assertFail(); + } + console.info(TAG + "Entering START_PREVIEW_OUTPUT_ASYNC ends here"); + await sleep(1000); + done(); + }) + } + await sleep(1000); + done(); + }) + + + /** + * @tc.number : START_PREVIEW_OUTPUT_ASYNC + * @tc.name : Create previewOutput instance async api + * @tc.desc : Create previewOutput instance async api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_STOP_PREVIEW_OUTPUT_ASYNC_0100', 0, async function (done) { + console.info(TAG + " --------------STOP_PREVIEW_OUTPUT_ASYNC--------------"); + if (isEmpty(previewOutput)) { + console.info(TAG + "Entering STOP_PREVIEW_OUTPUT_ASYNC previewOutput == null || undefined") + expect().assertFail(); + } else { + previewOutput.stop(async (err, data) => { + if (!err) { + expect(true).assertTrue(); + console.info(TAG + "Entering STOP_PREVIEW_OUTPUT_ASYNC success"); + } else { + expect().assertFail(); + console.info(TAG + "Entering STOP_PREVIEW_OUTPUT_ASYNC FAILED: " + err.message); + } + console.info(TAG + "Entering STOP_PREVIEW_OUTPUT_ASYNC ends here"); + await sleep(1000); + done(); + }) + } + await sleep(1000); + done(); + }) + + + /** + * @tc.number : PREVIEW_OUTPUT_CALLBACK_ON_FRAME_START + * @tc.name : preview output callback on frameStart api + * @tc.desc : preview output callback on frameStart api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_PREVIEW_OUTPUT_CALLBACK_ON_FRAME_START_0100', 0, async function (done) { + console.info("--------------PREVIEW_OUTPUT_CALLBACK_ON_FRAME_START--------------"); + if (isEmpty(previewOutput)) { + console.info(TAG + "Entering PREVIEW_OUTPUT_CALLBACK_ON_FRAME_START previewOutput == null || undefined") + expect().assertFail(); + } else { + console.info(TAG + "Entering PREVIEW_OUTPUT_CALLBACK_ON_FRAME_START to operate"); + previewOutput.on('frameStart', async (err, data) => { + if (!err) { + console.info(TAG + "Entering PREVIEW_OUTPUT_CALLBACK_ON_FRAME_START success"); + expect(true).assertTrue(); + } else { + console.info(TAG + "Error in PREVIEW_OUTPUT_CALLBACK_ON_FRAME_START FAILED: " + err.message); + expect().assertFail(); + } + await sleep(1000); + done(); + }) + } + await sleep(1000); + done(); + }) + + + + /** + * @tc.number : PREVIEW_OUTPUT_CALLBACK_ON_FRAME_END + * @tc.name : preview output callback on frameEnd api + * @tc.desc : preview output callback on frameEnd api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_PREVIEW_OUTPUT_CALLBACK_ON_FRAME_END_0100', 0, async function (done) { + console.info("--------------PREVIEW_OUTPUT_CALLBACK_ON_FRAME_END--------------"); + if (isEmpty(previewOutput)) { + console.info(TAG + "Entering PREVIEW_OUTPUT_CALLBACK_ON_FRAME_END previewOutput == null || undefined") + expect().assertFail(); + } else { + console.info(TAG + "Entering PREVIEW_OUTPUT_CALLBACK_ON_FRAME_END to operate"); + previewOutput.on('frameEnd', async (err, data) => { + if (!err) { + expect(true).assertTrue(); + console.info(TAG + "Entering PREVIEW_OUTPUT_CALLBACK_ON_FRAME_END success"); + } else { + expect().assertFail(); + console.info(TAG + "Error in PREVIEW_OUTPUT_CALLBACK_ON_FRAME_END FAILED: " + err.message); + } + await sleep(1000); + done(); + }) + } + await sleep(1000); + done(); + }) + + + /** + * @tc.number : PREVIEW_OUTPUT_CALLBACK_ON_ERROR + * @tc.name : preview output callback on frameEnd api + * @tc.desc : preview output callback on frameEnd api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_PREVIEW_OUTPUT_CALLBACK_ON_ERROR_0100', 0, async function (done) { + console.info("--------------PREVIEW_OUTPUT_CALLBACK_ON_ERROR--------------"); + if (isEmpty(previewOutput)) { + console.info(TAG + "Entering PREVIEW_OUTPUT_CALLBACK_ON_ERROR previewOutput == null || undefined") + expect().assertFail(); + } else { + console.info(TAG + "Entering PREVIEW_OUTPUT_CALLBACK_ON_ERROR to operate"); + previewOutput.on('error', async (err, data) => { + if (!err) { + expect(true).assertTrue(); + console.info(TAG + "Entering PREVIEW_OUTPUT_CALLBACK_ON_ERROR success"); + } else { + expect().assertFail(); + console.info(TAG + "Error in PREVIEW_OUTPUT_CALLBACK_ON_ERROR FAILED: " + err.message); + } + await sleep(1000); + done(); + }) + } + await sleep(1000); + done(); + }) + + + /** + * @tc.number : PHOTO_OUTPUT_CAPTURE_DEFAULT + * @tc.name : photoOutput commitConfig + * @tc.desc : captureSession commitConfig + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_DEFAULT_0100', 0, async function (done) { + console.info(TAG + " --------------CAPTURE_SESSION_COMMIT_CONFIG--------------"); + if (isEmpty(photoOutput)) { + console.info(TAG + "Entering PHOTO_OUTPUT_CAPTURE_DEFAULT photoOutput == null || undefined") + expect().assertFail(); + } else { + photoOutput.capture(async (err, data) => { + if (!err) { + console.info(TAG + "Entering PHOTO_OUTPUT_CAPTURE_DEFAULT success"); + expect(true).assertTrue(); + } else { + console.info(TAG + "Entering PHOTO_OUTPUT_CAPTURE_DEFAULT FAILED: " + err.message); + expect().assertFail(); + } + console.info(TAG + "Entering PHOTO_OUTPUT_CAPTURE_DEFAULT ends here"); + await sleep(1000); + done(); + }) + } + await sleep(1000); + done(); + }) + + + + /** + * @tc.number : PHOTO_OUTPUT_CAPTURE_SETTING + * @tc.name : photoOutput commitConfig + * @tc.desc : captureSession commitConfig + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_SETTING_0100', 0, async function (done) { + console.info(TAG + " --------------PHOTO_OUTPUT_CAPTURE_SETTING--------------"); + if (isEmpty(photoOutput)) { + console.info(TAG + "Entering PHOTO_OUTPUT_CAPTURE_SETTING photoOutput == null || undefined") + expect().assertFail(); + } else { + photoOutput.capture(captureSetting, async (err, data) => { + if (!err) { + expect(true).assertTrue(); + console.info(TAG + "Entering PHOTO_OUTPUT_CAPTURE_SETTING success"); + } else { + expect().assertFail(); + console.info(TAG + "Entering PHOTO_OUTPUT_CAPTURE_SETTING FAILED: " + err.message); + } + console.info(TAG + "Entering PHOTO_OUTPUT_CAPTURE_SETTING ends here"); + await sleep(1000); + done(); + }) + } + await sleep(1000); + done(); + }) + + + /** + * @tc.number : PHOTO_OUTPUT_CALLBACK_ON_CAPTURE_START + * @tc.name : photo output callback on captureStart + * @tc.desc : photo output callback on captureStart + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CALLBACK_ON_CAPTURE_START_0100', 0, async function (done) { + console.info("--------------PHOTO_OUTPUT_CALLBACK_ON_CAPTURE_START--------------"); + if (isEmpty(photoOutput)) { + console.info(TAG + "Entering PREVIEW_OUTPUT_CALLBACK_ON_FRAME_START previewOutput == null || undefined") + expect().assertFail(); + } else { + console.info(TAG + "Entering PHOTO_OUTPUT_CALLBACK_ON_CAPTURE_START to operate"); + photoOutput.on('captureStart', async (err, data) => { + if (!err) { + expect(true).assertTrue(); + console.info(TAG + "Entering PHOTO_OUTPUT_CALLBACK_ON_CAPTURE_START success"); + } else { + expect().assertFail(); + console.info(TAG + "Error in PHOTO_OUTPUT_CALLBACK_ON_CAPTURE_START FAILED: " + err.message); + } + await sleep(1000); + done(); + }) + } + await sleep(1000); + done(); + }) + + + + /** + * @tc.number : PHOTO_OUTPUT_CALLBACK_ON_FRAME_SHUTTER + * @tc.name : photo output callback on frameShutter + * @tc.desc : photo output callback on frameShutter + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CALLBACK_ON_FRAME_SHUTTER_0100', 0, async function (done) { + console.info("--------------PHOTO_OUTPUT_CALLBACK_ON_FRAME_SHUTTER--------------"); + if (isEmpty(photoOutput)) { + console.info(TAG + "Entering PHOTO_OUTPUT_CALLBACK_ON_FRAME_SHUTTER previewOutput == null || undefined") + expect().assertFail(); + } else { + console.info(TAG + "Entering PHOTO_OUTPUT_CALLBACK_ON_FRAME_SHUTTER to operate"); + photoOutput.on('frameShutter', async (err, data) => { + if (!err) { + expect(true).assertTrue(); + console.info(TAG + "Entering PHOTO_OUTPUT_CALLBACK_ON_FRAME_SHUTTER success"); + } else { + expect().assertFail(); + console.info(TAG + "Error in PHOTO_OUTPUT_CALLBACK_ON_FRAME_SHUTTER FAILED: " + err.message); + } + await sleep(1000); + done(); + }) + } + await sleep(1000); + done(); + }) + + + + /** + * @tc.number : PHOTO_OUTPUT_CALLBACK_ON_CAPTURE_END + * @tc.name : photo output callback on captureEnd + * @tc.desc : photo output callback on captureEnd + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CALLBACK_ON_CAPTURE_END_0100', 0, async function (done) { + console.info("--------------PHOTO_OUTPUT_CALLBACK_ON_CAPTURE_END--------------"); + if (isEmpty(photoOutput)) { + console.info(TAG + "Entering PHOTO_OUTPUT_CALLBACK_ON_CAPTURE_END previewOutput == null || undefined") + expect().assertFail(); + } else { + console.info(TAG + "Entering PHOTO_OUTPUT_CALLBACK_ON_CAPTURE_END to operate"); + photoOutput.on('captureEnd', async (err, data) => { + if (!err) { + expect(true).assertTrue(); + console.info(TAG + "Entering PHOTO_OUTPUT_CALLBACK_ON_CAPTURE_END success"); + } else { + expect().assertFail(); + console.info(TAG + "Error in PHOTO_OUTPUT_CALLBACK_ON_CAPTURE_END FAILED: " + err.message); + } + await sleep(1000); + done(); + }) + } + await sleep(1000); + done(); + }) + + + /** + * @tc.number : PHOTO_OUTPUT_CALLBACK_ON_ERROR + * @tc.name : photo output callback on error + * @tc.desc : photo output callback on error + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CALLBACK_ON_ERROR_0100', 0, async function (done) { + console.info("--------------PHOTO_OUTPUT_CALLBACK_ON_ERROR--------------"); + if (isEmpty(photoOutput)) { + console.info(TAG + "Entering PHOTO_OUTPUT_CALLBACK_ON_ERROR previewOutput == null || undefined") + expect().assertFail(); + } else { + console.info(TAG + "Entering PHOTO_OUTPUT_CALLBACK_ON_ERROR to operate"); + photoOutput.on('error', async (err, data) => { + if (!err) { + expect(true).assertTrue(); + console.info(TAG + "Entering PHOTO_OUTPUT_CALLBACK_ON_ERROR success"); + } else { + expect().assertFail(); + console.info(TAG + "Error in PHOTO_OUTPUT_CALLBACK_ON_ERROR FAILED: " + err.message); + } + await sleep(1000); + done(); + }) + } + await sleep(1000); + done(); + }) + + + + + + /** + * @tc.number : PHOTO_OUTPUT_RELEASE + * @tc.name : Create previewOutput instance async api + * @tc.desc : Create previewOutput instance async api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_RELEASE_0100', 0, async function (done) { + console.info(TAG + " --------------PHOTO_OUTPUT_RELEASE--------------"); + if (isEmpty(photoOutput)) { + console.info(TAG + "Entering PHOTO_OUTPUT_RELEASE photoOutput == null || undefined") + expect().assertFail(); + } else { + photoOutput.release(async (err, data) => { + if (!err) { + expect(true).assertTrue(); + console.info(TAG + "Entering PHOTO_OUTPUT_RELEASE success"); + } else { + expect().assertFail(); + console.info(TAG + "Entering PHOTO_OUTPUT_RELEASE FAILED: " + err.message); + } + console.info(TAG + "Entering PHOTO_OUTPUT_RELEASE ends here"); + await sleep(1000); + done(); + }) + } + await sleep(1000); + done(); + }) + + + + + + /** + * @tc.number : VIDEO_OUTPUT_START_PROMISE + * @tc.name : videoOutput start promise api + * @tc.desc : videoOutput start promise api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_START_PROMISE_0100', 0, async function (done) { + console.info(TAG + " --------------VIDEO_OUTPUT_START_PROMISE--------------"); + if (isEmpty(videoOutput)) { + console.info(TAG + "Entering VIDEO_OUTPUT_START_PROMISE videoOutput == null || undefined") + expect().assertFail(); + } else { + console.info(TAG + "Entering VIDEO_OUTPUT_START_PROMISE start") + videoOutput.start(); + console.info(TAG + "Entering VIDEO_OUTPUT_START_PROMISE end") + } + await sleep(1000); + done(); + }) + + + /** + * @tc.number : VIDEO_OUTPUT_STOP_PROMISE + * @tc.name : videoOutput stop promise api + * @tc.desc : videoOutput stop promise api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_STOP_PROMISE_0100', 0, async function (done) { + console.info(TAG + " --------------VIDEO_OUTPUT_STOP_PROMISE--------------"); + if (isEmpty(videoOutput)) { + console.info(TAG + "Entering VIDEO_OUTPUT_STOP_PROMISE videoOutput == null || undefined") + expect().assertFail(); + } else { + console.info(TAG + "Entering VIDEO_OUTPUT_STOP_PROMISE start") + videoOutput.stop(); + console.info(TAG + "Entering VIDEO_OUTPUT_STOP_PROMISE end") + } + await sleep(1000); + done(); + }) + + + + /** + * @tc.number : VIDEO_OUTPUT_START_ASYNC + * @tc.name : videoOutput start async api + * @tc.desc : videoOutput start async api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_START_ASYNC_0100', 0, async function (done) { + console.info(TAG + " --------------VIDEO_OUTPUT_START_ASYNC--------------"); + if (isEmpty(videoOutput)) { + console.info(TAG + "Entering VIDEO_OUTPUT_START_ASYNC videoOutput == null || undefined") + expect().assertFail(); + } else { + videoOutput.start(async (err, data) => { + if (!err) { + expect(true).assertTrue(); + console.info(TAG + "Entering VIDEO_OUTPUT_START_ASYNC success"); + } else { + expect().assertFail(); + console.info(TAG + "Entering VIDEO_OUTPUT_START_ASYNC FAILED: " + err.message); + } + console.info(TAG + "Entering VIDEO_OUTPUT_START_ASYNC ends here"); + await sleep(1000); + done(); + }) + } + await sleep(1000); + done(); + }) + + + /** + * @tc.number : VIDEO_OUTPUT_STOP_ASYNC + * @tc.name : videoOutput stop async api + * @tc.desc : videoOutput stop async api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_STOP_ASYNC_0100', 0, async function (done) { + console.info(TAG + " --------------VIDEO_OUTPUT_STOP_ASYNC--------------"); + if (isEmpty(videoOutput)) { + console.info(TAG + "Entering VIDEO_OUTPUT_STOP_ASYNC videoOutput == null || undefined") + expect().assertFail(); + } else { + videoOutput.stop(async (err, data) => { + if (!err) { + expect(true).assertTrue(); + console.info(TAG + "Entering VIDEO_OUTPUT_STOP_ASYNC success"); + } else { + expect().assertFail(); + console.info(TAG + "Entering VIDEO_OUTPUT_STOP_ASYNC FAILED: " + err.message); + } + console.info(TAG + "Entering VIDEO_OUTPUT_STOP_ASYNC ends here"); + await sleep(1000); + done(); + }) + } + await sleep(1000); + done(); + }) + + + + /** + * @tc.number : VIDEO_OUTPUT_CALLBACK_ON_FRAME_START + * @tc.name : video output callback on frameStart api + * @tc.desc : video output callback on frameStart api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_CALLBACK_ON_FRAME_START_0100', 0, async function (done) { + console.info("--------------VIDEO_OUTPUT_CALLBACK_ON_FRAME_START--------------"); + if (isEmpty(videoOutput)) { + console.info(TAG + "Entering VIDEO_OUTPUT_CALLBACK_ON_FRAME_START videoOutput == null || undefined") + expect().assertFail(); + } else { + console.info(TAG + "Entering VIDEO_OUTPUT_CALLBACK_ON_FRAME_START to operate"); + videoOutput.on('frameStart', async (err, data) => { + if (!err) { + expect(true).assertTrue(); + console.info(TAG + "Entering VIDEO_OUTPUT_CALLBACK_ON_FRAME_START success"); + } else { + expect().assertFail(); + console.info(TAG + "Error in VIDEO_OUTPUT_CALLBACK_ON_FRAME_START FAILED: " + err.message); + } + await sleep(1000); + done(); + }) + } + await sleep(1000); + done(); + }) + + + /** + * @tc.number : VIDEO_OUTPUT_CALLBACK_ON_FRAME_START + * @tc.name : video output callback on frameStart api + * @tc.desc : video output callback on frameStart api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_CALLBACK_ON_FRAME_START_0100', 0, async function (done) { + console.info("--------------VIDEO_OUTPUT_CALLBACK_ON_FRAME_START--------------"); + if (isEmpty(videoOutput)) { + console.info(TAG + "Entering VIDEO_OUTPUT_CALLBACK_ON_FRAME_START videoOutput == null || undefined") + expect().assertFail(); + } else { + console.info(TAG + "Entering VIDEO_OUTPUT_CALLBACK_ON_FRAME_START to operate"); + videoOutput.on('frameStart', async (err, data) => { + if (!err) { + expect(true).assertTrue(); + console.info(TAG + "Entering VIDEO_OUTPUT_CALLBACK_ON_FRAME_START success"); + } else { + expect().assertFail(); + console.info(TAG + "Error in VIDEO_OUTPUT_CALLBACK_ON_FRAME_START FAILED: " + err.message); + } + await sleep(1000); + done(); + }) + } + await sleep(1000); + done(); + }) + + + /** + * @tc.number : VIDEO_OUTPUT_CALLBACK_ON_FRAME_END + * @tc.name : video output callback on frameEnd api + * @tc.desc : video output callback on frameEnd api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_CALLBACK_ON_FRAME_END_0100', 0, async function (done) { + console.info("--------------VIDEO_OUTPUT_CALLBACK_ON_FRAME_END--------------"); + if (isEmpty(videoOutput)) { + console.info(TAG + "Entering VIDEO_OUTPUT_CALLBACK_ON_FRAME_END videoOutput == null || undefined") + expect().assertFail(); + } else { + console.info(TAG + "Entering VIDEO_OUTPUT_CALLBACK_ON_FRAME_END to operate"); + videoOutput.on('frameEnd', async (err, data) => { + if (!err) { + expect(true).assertTrue(); + console.info(TAG + "Entering VIDEO_OUTPUT_CALLBACK_ON_FRAME_END success"); + } else { + expect().assertFail(); + console.info(TAG + "Error in VIDEO_OUTPUT_CALLBACK_ON_FRAME_END FAILED: " + err.message); + } + await sleep(1000); + done(); + }) + } + await sleep(1000); + done(); + }) + + + + /** + * @tc.number : VIDEO_OUTPUT_CALLBACK_ON_FRAME_ERROR + * @tc.name : video output callback on error api + * @tc.desc : video output callback on error api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_CALLBACK_ON_FRAME_ERROR_0100', 0, async function (done) { + console.info("--------------VIDEO_OUTPUT_CALLBACK_ON_FRAME_ERROR--------------"); + if (isEmpty(videoOutput)) { + console.info(TAG + "Entering VIDEO_OUTPUT_CALLBACK_ON_FRAME_ERROR videoOutput == null || undefined") + expect().assertFail(); + } else { + console.info(TAG + "Entering VIDEO_OUTPUT_CALLBACK_ON_FRAME_ERROR to operate"); + videoOutput.on('error', async (err, data) => { + if (!err) { + expect(true).assertTrue(); + console.info(TAG + "Entering VIDEO_OUTPUT_CALLBACK_ON_FRAME_ERROR success"); + } else { + expect().assertFail(); + console.info(TAG + "Error in VIDEO_OUTPUT_CALLBACK_ON_FRAME_ERROR FAILED: " + err.message); + } + await sleep(1000); + done(); + }) + } + await sleep(1000); + done(); + }) + }) + +} \ No newline at end of file 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 new file mode 100755 index 0000000000000000000000000000000000000000..3ce15e8f0dd546d6fc3b15f3c496659459fd539c --- /dev/null +++ b/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraManagerTest.test.ets @@ -0,0 +1,1050 @@ +/* + * 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 cameraObj from '@ohos.multimedia.camera'; +import image from '@ohos.multimedia.image'; +import fileio from '@ohos.fileio'; +import abilityAccessCtrl from '@ohos.abilityAccessCtrl' +import bundle from '@ohos.bundle' +import mediaLibrary from '@ohos.multimedia.mediaLibrary' +import media from '@ohos.multimedia.media' +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'; + +const TAG = "CameraUnitTest: "; + +// Define global variables +let mCameraManager; +let mPhotoSurfaceId; +let mCameraDevicesArray; +let mVideoSurface; +let mVideoRecorder; +let mFdPath; +let mFileAsset; +let mFdNumber; + +let mVideoProfileCfg = { + audioBitrate: 48000, + audioChannels: 2, + audioCodec: 'audio/mp4a-latm', + audioSampleRate: 48000, + durationTime: 1000, + fileFormat: 'mp4', + videoBitrate: 48000, + videoCodec: 'video/mp4v-es', + videoFrameWidth: 640, + videoFrameHeight: 480, + videoFrameRate: 30 +} + +let mVideoConfig = { + audioSourceType: 1, + videoSourceType: 0, + profile: mVideoProfileCfg, + url: 'file:///data/media/CameraManager.mp4', + orientationHint: 0, + location: { latitude: 30, longitude: 130 }, + maxSize: 100, + maxDuration: 500 +} + +export default function cameraManagerTest(surfaceId: any) { + + 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') + mPhotoSurfaceId = await receiver.getReceivingSurfaceId() + console.log(TAG + 'Received id: ' + JSON.stringify(mPhotoSurfaceId)) + } else { + console.log(TAG + 'Receiver is not ok') + } + } + + async function getFd(pathName) { + let displayName = pathName; + const mediaTest = mediaLibrary.getMediaLibrary(); + let fileKeyObj = mediaLibrary.FileKey; + let mediaType = mediaLibrary.MediaType.VIDEO; + let publicPath = await mediaTest.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO); + let dataUri = await mediaTest.createAsset(mediaType, displayName, publicPath); + if (dataUri != undefined) { + let args = dataUri.id.toString(); + let fetchOp = { + selections: fileKeyObj.ID + "=?", + selectionArgs: [args], + } + let fetchFileResult = await mediaTest.getFileAssets(fetchOp); + mFileAsset = await fetchFileResult.getAllObject(); + mFdNumber = await mFileAsset[0].open('Rw'); + mFdPath = "fd://" + mFdNumber.toString(); + } + } + + async function closeFd() { + if (mFileAsset != null) { + await mFileAsset[0].close(mFdNumber).then(() => { + console.info('[mediaLibrary] case close fd success'); + }).catch((err) => { + console.info('[mediaLibrary] case close fd failed'); + }); + } else { + console.info('[mediaLibrary] case fileAsset is null'); + } + } + + async function getVideoReceiveSurface() { + console.log(TAG + 'Entering getVideoReceiveSurface') + await getFd('CameraManager.mp4'); + mVideoConfig.url = mFdPath; + media.createVideoRecorder((err, recorder) => { + console.info(TAG + 'Entering create video receiver') + mVideoRecorder = recorder + console.info(TAG + 'videoRecorder is :' + JSON.stringify(mVideoRecorder)) + console.info(TAG + 'videoRecorder.prepare called.') + mVideoRecorder.prepare(mVideoConfig, (err) => { + console.info(TAG + 'videoRecorder.prepare success.') + mVideoRecorder.getInputSurface((err, id) => { + console.info(TAG + 'getInputSurface called') + mVideoSurface = id + console.info(TAG + 'getInputSurface surfaceId: ' + JSON.stringify(mVideoSurface)) + }) + }) + }) + console.log(TAG + 'Exit getVideoReceiveSurface') + } + + async function releaseVideoReceiveSurface() { + console.log(TAG + 'Entering releaseVideoReceiveSurface') + mVideoRecorder.release((err) => { + console.info(TAG + 'Entering release video receiver') + }) + await closeFd(); + console.log(TAG + 'Exit releaseVideoReceiveSurface') + } + + function sleep(ms) { + console.info(TAG + "Entering sleep -> Promise constructor"); + return new Promise(resolve => setTimeout(resolve, ms)); + } + + function isEmpty(data) { + if (data == null || data == undefined) { + return true; + } + return false; + } + + async function getCameraManagerInstance() { + console.info('Enter getCameraManagerInstance'); + + mCameraManager = await cameraObj.getCameraManager(null); + if (isEmpty(mCameraManager)) { + console.info(TAG + "getCameraManager FAILED"); + return false; + } + await sleep(500); + + console.info('Exit getCameraManagerInstance'); + return true; + } + + async function getSupportedOutputCapabilityInCallback(cameraDevice) { + if (isEmpty(mCameraManager)) { + console.info(TAG + "Entering getSupportedOutputCapabilityInCallback cameraManager == null || undefined") + expect().assertFail(); + return undefined; + } + let outputCapabilityCallback = null; + mCameraManager.getSupportedOutputCapability(cameraDevice, async (err, data) => { + if (!err) { + if (!isEmpty(data)) { + console.info(TAG + "Entering SupportedOutputCapability data is not null || undefined"); + outputCapabilityCallback = data; + expect(outputCapabilityCallback).assertNotNull(); + } + else { + console.info(TAG + "getSupportedOutputCapabilityInCallback FAILED"); + expect().assertFail(); + } + } else { + console.info(TAG + "getSupportedOutputCapabilityInCallback FAILED: " + err.message); + expect().assertFail(); + } + console.info(TAG + "getSupportedOutputCapabilityInCallback ends here"); + }) + await sleep(100); + return outputCapabilityCallback; + } + + async function getSupportedOutputCapabilityInPromise(cameraDevice) { + if (isEmpty(mCameraManager)) { + console.info(TAG + "Entering getSupportedOutputCapabilityInPromise cameraManager == null || undefined") + expect().assertFail(); + return undefined; + } + let outputCapabilityPromise = await mCameraManager.getSupportedOutputCapability(cameraDevice); + if (isEmpty(outputCapabilityPromise)) { + console.info(TAG + "Entering getSupportedOutputCapabilityInPromise outputCapabilityPromise == null || undefined") + expect().assertFail(); + } else { + console.info("CameraUnitTest: Entering testSupportedOutputCapabilityPromise: " + JSON.stringify(outputCapabilityPromise)); + } + + return outputCapabilityPromise; + } + + async function applyPermission() { + let appInfo = await bundle.getApplicationInfo('com.open.harmony.multimedia.cameratest', 0, 100); + let atManager = abilityAccessCtrl.createAtManager(); + if (atManager != null) { + let tokenID = appInfo.accessTokenId; + console.info('[permission] case accessTokenID is ' + tokenID); + let permissionName1 = 'ohos.permission.CAMERA'; + let permissionName2 = 'ohos.permission.MICROPHONE'; + let permissionName3 = 'ohos.permission.MEDIA_LOCATION'; + let permissionName4 = 'ohos.permission.READ_MEDIA'; + let permissionName5 = 'ohos.permission.WRITE_MEDIA'; + let permissionName6 = 'ohos.permission.START_ABILITIES_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) => { + console.info('[permission] case grantUserGrantedPermission failed :' + err); + }); + await atManager.grantUserGrantedPermission(tokenID, permissionName2, 1).then((result) => { + console.info('[permission] case grantUserGrantedPermission success :' + result); + }).catch((err) => { + console.info('[permission] case grantUserGrantedPermission failed :' + err); + }); + await atManager.grantUserGrantedPermission(tokenID, permissionName3, 1).then((result) => { + console.info('[permission] case grantUserGrantedPermission success :' + result); + }).catch((err) => { + console.info('[permission] case grantUserGrantedPermission failed :' + err); + }); + await atManager.grantUserGrantedPermission(tokenID, permissionName4, 1).then((result) => { + console.info('[permission] case grantUserGrantedPermission success :' + result); + }).catch((err) => { + console.info('[permission] case grantUserGrantedPermission failed :' + err); + }); + await atManager.grantUserGrantedPermission(tokenID, permissionName5, 1).then((result) => { + console.info('[permission] case grantUserGrantedPermission success :' + result); + }).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'); + } + } + +describe('CameraManagerTest', function () { + console.info(TAG + '----------CameraManagerTest--------------') + + beforeAll(async function () { + await applyPermission(); + await getCameraManagerInstance(); + await getImageReceiverSurfaceId(); + await getVideoReceiveSurface(); + console.info('beforeAll case'); + }) + + beforeEach(function () { + sleep(5000); + console.info('beforeEach case'); + }) + + afterEach(async function () { + console.info('afterEach case'); + }) + + afterAll(function () { + releaseVideoReceiveSurface(); + sleep(1000); + console.info('afterAll case'); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_GET_CAMERA_MANAGER_0100 + * @tc.name : Create camera manager instance async api + * @tc.desc : Create camera manager instance async api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_GET_CAMERA_MANAGER_CALLBACK_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_GET_CAMERA_MANAGER_0100--------------"); + cameraObj.getCameraManager(null, async (err, data) => { + if (!err) { + expect(isEmpty(data)).assertFalse(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_CAMERA_MANAGER_0100 success"); + } else { + expect().assertFail(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_CAMERA_MANAGER_0100 FAILED: " + err.message); + } + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_CAMERA_MANAGER_0100 ends here"); + await sleep(1000); + done(); + }) + await sleep(1000); + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_GET_CAMERA_MANAGER_PROMISE_0100 + * @tc.name : Create camera manager instance promise api + * @tc.desc : Create camera manager instance promise api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_GET_CAMERA_MANAGER_PROMISE_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_GET_CAMERA_MANAGER_PROMISE_0100--------------"); + let cameraManagerPromise = await cameraObj.getCameraManager(null); + expect(isEmpty(cameraManagerPromise)).assertFalse(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_CAMERA_MANAGER_PROMISE_0100 cameraManagerPromise: " + JSON.stringify(cameraManagerPromise)); + await sleep(1000); + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_CALLBACK_0100 + * @tc.name : Get camera from cameramanager to get array of camera async api + * @tc.desc : Get camera from cameramanager to get array of camera async api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_CALLBACK_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_CALLBACK_0100--------------"); + if (isEmpty(mCameraManager)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_PROMISE_0100 cameraManager == null || undefined") + expect().assertFail(); + } + mCameraManager.getSupportedCameras(async (err, data) => { + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_CALLBACK_0100 success"); + if (!isEmpty(data)) { + mCameraDevicesArray = data; + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_CALLBACK_0100 data is " + mCameraDevicesArray.length); + if (mCameraDevicesArray.length > 0) { + for (let i = 0; i < mCameraDevicesArray.length; i++) { + // Get the variables from camera object + let cameraId = mCameraDevicesArray[i].cameraId; + expect(isEmpty(cameraId)).assertFalse(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_CALLBACK_0100 camera" + i + "Id: " + cameraId); + let cameraPosition = mCameraDevicesArray[i].cameraPosition; + expect(isEmpty(cameraPosition)).assertFalse(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_CALLBACK_0100 camera" + i + "Position: " + cameraPosition); + let cameraType = mCameraDevicesArray[i].cameraType; + expect(isEmpty(cameraType)).assertFalse(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_CALLBACK_0100 camera" + i + "Type: " + cameraType); + let connectionType = mCameraDevicesArray[i].connectionType + expect(isEmpty(connectionType)).assertFalse(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_CALLBACK_0100 connection" + i + "Type: " + connectionType); + } + expect(true).assertTrue(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_CALLBACK_0100 PASSED"); + } else { + expect().assertFail(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_CALLBACK_0100 FAILED cameraArray is null || undefined"); + } + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_CALLBACK_0100 ends here"); + await sleep(1000); + done(); + } else { + expect().assertFail(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_CALLBACK_0100 FAILED cameraArray is null || undefined"); + } + } else { + expect().assertFail(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_CALLBACK_0100 FAILED , err = " + err.message); + } + }) + await sleep(1000); + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_PROMISE_0100 + * @tc.name : Get camera from cameramanager to get array of camera promise api + * @tc.desc : Get camera from cameramanager to get array of camera promise api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_PROMISE_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_PROMISE_0100--------------"); + if (isEmpty(mCameraManager)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_PROMISE_0100 cameraManager == null || undefined") + expect().assertFail(); + } else { + let mCameraDevicesArrayPromise = await mCameraManager.getSupportedCameras(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_PROMISE_0100: " + JSON.stringify(mCameraDevicesArrayPromise)); + if (mCameraDevicesArrayPromise != null && mCameraDevicesArrayPromise.length > 0) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_PROMISE_0100 success"); + for (let i = 0; i < mCameraDevicesArrayPromise.length; i++) { + // Get the variables from camera object + let cameraId = mCameraDevicesArrayPromise[i].cameraId; + expect(isEmpty(cameraId)).assertFalse(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_PROMISE_0100 camera" + i + "Id: " + cameraId); + let cameraPosition = mCameraDevicesArrayPromise[i].cameraPosition; + expect(isEmpty(cameraPosition)).assertFalse(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_PROMISE_0100 camera" + i + "Position: " + cameraPosition); + let cameraType = mCameraDevicesArrayPromise[i].cameraType; + expect(isEmpty(cameraType)).assertFalse(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_PROMISE_0100 camera" + i + "Type: " + cameraType); + let connectionType = mCameraDevicesArrayPromise[i].connectionType + expect(isEmpty(connectionType)).assertFalse(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_PROMISE_0100 connection" + i + "Type: " + connectionType); + } + expect(true).assertTrue(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_PROMISE_0100 PASSED"); + } else { + expect().assertFail(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_PROMISE_0100 FAILED"); + } + } + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_PROMISE_0100 ends here"); + await sleep(1000); + done(); + }) + + /*GET_SUPPORTED_CAMERA_OUTPUT_CAPABILITY_TC*/ + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_GET_SUPPORTED_CAMERA_OUTPUT_CAPABILITY_CALLBACK_0100 + * @tc.name : Get supported preview formats from camera-0 camerainput async api + * @tc.desc : Get supported preview formats from camera-0 camerainput async api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_GET_SUPPORTED_CAMERA_OUTPUT_CAPABILITY_CALLBACK_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_GET_SUPPORTED_CAMERA_OUTPUT_CAPABILITY_CALLBACK_0100--------------"); + let camerasArray = mCameraDevicesArray; + for (let i = 0; i < camerasArray.length; i++) { + let cameraOutputCap = await getSupportedOutputCapabilityInCallback(camerasArray[i]); + await sleep(100); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_SUPPORTED_CAMERA_OUTPUT_CAPABILITY_CALLBACK_0100 camera:" + camerasArray[i].cameraId); + if (isEmpty(cameraOutputCap)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_SUPPORTED_CAMERA_OUTPUT_CAPABILITY_CALLBACK_0100 cameraOutputCap == null || undefined") + expect().assertFail(); + } + + let previewProfilesArray = cameraOutputCap.previewProfiles; + if (isEmpty(previewProfilesArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_SUPPORTED_CAMERA_OUTPUT_CAPABILITY_CALLBACK_0100 previewProfilesArray == null || undefined") + expect().assertFail(); + } + + let photoProfilesArray = cameraOutputCap.photoProfiles; + if (isEmpty(photoProfilesArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_SUPPORTED_CAMERA_OUTPUT_CAPABILITY_CALLBACK_0100 photoProfilesArray == null || undefined") + expect().assertFail(); + } + + let videoProfilesArray = cameraOutputCap.videoProfiles; + if (isEmpty(videoProfilesArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_SUPPORTED_CAMERA_OUTPUT_CAPABILITY_CALLBACK_0100 videoProfilesArray == null || undefined") + expect().assertFail(); + } + + let metadataObjectTypesArray = cameraOutputCap.supportedMetadataObjectTypes; + if (isEmpty(metadataObjectTypesArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_SUPPORTED_CAMERA_OUTPUT_CAPABILITY_CALLBACK_0100 metadataObjectTypesArray == null || undefined") + } + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_SUPPORTED_CAMERA_OUTPUT_CAPABILITY_CALLBACK_0100 PASSED camera:" + camerasArray[i].cameraId); + } + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_SUPPORTED_CAMERA_OUTPUT_CAPABILITY_CALLBACK_0100 ends here"); + await sleep(1000); + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_GET_SUPPORTED_CAMERA_OUTPUT_CAPABILITY_PROMISE_0100 + * @tc.name : Get supported preview formats from camera-0 camerainput promise api + * @tc.desc : Get supported preview formats from camera-0 camerainput promise api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_GET_SUPPORTED_CAMERA_OUTPUT_CAPABILITY_PROMISE_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_GET_SUPPORTED_CAMERA_OUTPUT_CAPABILITY_PROMISE_0100--------------"); + for (let i = 0; i < mCameraDevicesArray.length; i++) { + let cameraOutputCap = await getSupportedOutputCapabilityInPromise(mCameraDevicesArray[i]); + console.info("Entering SUB_MULTIMEDIA_CAMERA_GET_SUPPORTED_CAMERA_OUTPUT_CAPABILITY_PROMISE_0100 camera:" + mCameraDevicesArray[i].cameraId); + if (isEmpty(cameraOutputCap)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_SUPPORTED_CAMERA_OUTPUT_CAPABILITY_PROMISE_0100 cameraOutputCap == null || undefined") + expect().assertFail(); + } + + let previewProfilesArray = cameraOutputCap.previewProfiles; + if (isEmpty(previewProfilesArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_SUPPORTED_CAMERA_OUTPUT_CAPABILITY_PROMISE_0100 previewProfilesArray == null || undefined") + expect().assertFail(); + } + + let photoProfilesArray = cameraOutputCap.photoProfiles; + if (isEmpty(photoProfilesArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_SUPPORTED_CAMERA_OUTPUT_CAPABILITY_PROMISE_0100 photoProfilesArray == null || undefined") + expect().assertFail(); + } + + let videoProfilesArray = cameraOutputCap.videoProfiles; + if (isEmpty(videoProfilesArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_SUPPORTED_CAMERA_OUTPUT_CAPABILITY_PROMISE_0100 videoProfilesArray == null || undefined") + expect().assertFail(); + } + expect(isEmpty(videoProfilesArray)).assertFalse(); + + let metadataObjectTypesArray = cameraOutputCap.supportedMetadataObjectTypes; + if (isEmpty(metadataObjectTypesArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_SUPPORTED_CAMERA_OUTPUT_CAPABILITY_PROMISE_0100 metadataObjectTypesArray == null || undefined") + } + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_SUPPORTED_CAMERA_OUTPUT_CAPABILITY_PROMISE_0100 PASSED camera:" + mCameraDevicesArray[i].cameraId); + } + console.info("CameraUnitTest: Entering SUB_MULTIMEDIA_CAMERA_GET_SUPPORTED_CAMERA_OUTPUT_CAPABILITY_PROMISE_0100 ends here"); + await sleep(1000); + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_PREVIEW_PROFILES_0100 + * @tc.name : Get supported preview formats from camera-0 camerainput promise api + * @tc.desc : Get supported preview formats from camera-0 camerainput promise api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_PREVIEW_PROFILES_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_PREVIEW_PROFILES_0100--------------"); + let camerasArray = mCameraDevicesArray; + for (let i = 0; i < camerasArray.length; i++) { + let cameraOutputCap = await getSupportedOutputCapabilityInPromise(camerasArray[i]); + console.info("Entering SUB_MULTIMEDIA_CAMERA_PREVIEW_PROFILES_0100 camera:" + camerasArray[i].cameraId); + if (isEmpty(cameraOutputCap)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PREVIEW_PROFILES_0100 cameraOutputCap == null || undefined") + expect().assertFail(); + } + + let previewProfilesArray = cameraOutputCap.previewProfiles; + if (isEmpty(previewProfilesArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PREVIEW_PROFILES_0100 previewProfilesArray == null || undefined") + expect().assertFail(); + } + + for (let i = 0; i < previewProfilesArray.length; i++) { + let previewProfilesFormat = previewProfilesArray[i].format; + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PREVIEW_PROFILES_0100 previewProfilesFormat: " + previewProfilesFormat); + let previewProfilesSize = previewProfilesArray[i].size; + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PREVIEW_PROFILES_0100 width: " + previewProfilesSize.width); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PREVIEW_PROFILES_0100 height: " + previewProfilesSize.height); + } + expect(true).assertTrue(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PREVIEW_PROFILES_0100 PASSED camera:" + camerasArray[i].cameraId); + } + await sleep(1000); + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_PHOTO_PROFILES_0100 + * @tc.name : Get supported preview formats from camera-0 camerainput promise api + * @tc.desc : Get supported preview formats from camera-0 camerainput promise api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_PHOTO_PROFILES_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_PHOTO_PROFILES_0100--------------"); + let camerasArray = mCameraDevicesArray; + for (let i = 0; i < camerasArray.length; i++) { + let cameraOutputCap = await getSupportedOutputCapabilityInPromise(camerasArray[i]); + console.info("Entering SUB_MULTIMEDIA_CAMERA_PHOTO_PROFILES_0100 camera:" + camerasArray[i].cameraId); + if (isEmpty(cameraOutputCap)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PHOTO_PROFILES_0100 cameraOutputCap == null || undefined") + expect().assertFail(); + } + + let photoProfilesArray = cameraOutputCap.photoProfiles; + if (isEmpty(cameraOutputCap)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PHOTO_PROFILES_0100 photoProfilesArray == null || undefined") + expect().assertFail(); + } + + for (let i = 0; i < photoProfilesArray.length; i++) { + let photoProfilesFormat = photoProfilesArray[i].format; + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PHOTO_PROFILES_0100 photoProfilesFormat: " + photoProfilesFormat); + let photoProfilesSize = photoProfilesArray[i].size; + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PHOTO_PROFILES_0100 width: " + photoProfilesSize.width); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PHOTO_PROFILES_0100 height: " + photoProfilesSize.height); + } + expect(true).assertTrue(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PHOTO_PROFILES_0100 PASSED camera:" + camerasArray[i].cameraId); + } + await sleep(1000); + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_VIDEO_PROFILES_0100 + * @tc.name : Get supported preview formats from camera-0 camerainput promise api + * @tc.desc : Get supported preview formats from camera-0 camerainput promise api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_VIDEO_PROFILES_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_VIDEO_PROFILES_0100--------------"); + let camerasArray = mCameraDevicesArray; + for (let i = 0; i < camerasArray.length; i++) { + let cameraOutputCap = await getSupportedOutputCapabilityInPromise(camerasArray[i]); + console.info("Entering SUB_MULTIMEDIA_CAMERA_VIDEO_PROFILES_0100 camera:" + camerasArray[i].cameraId); + if (isEmpty(cameraOutputCap)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_VIDEO_PROFILES_0100 cameraOutputCap == null || undefined") + expect().assertFail(); + } + + let videoProfilesArray = cameraOutputCap.videoProfiles; + if (isEmpty(videoProfilesArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_VIDEO_PROFILES_0100 videoProfilesArray == null || undefined") + expect().assertFail(); + } + + for (let i = 0; i < videoProfilesArray.length; i++) { + let videoProfilesFormat = videoProfilesArray[i].format; + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_VIDEO_PROFILES_0100 videoProfilesFormat: " + videoProfilesFormat); + let videoProfilesSize = videoProfilesArray[i].size; + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_VIDEO_PROFILES_0100 width: " + videoProfilesSize.width); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_VIDEO_PROFILES_0100 height: " + videoProfilesSize.height); + let videoProfilesFrameRateRange = videoProfilesArray[i].frameRateRange; + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_VIDEO_PROFILES_0100 min: " + videoProfilesFrameRateRange.min); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_VIDEO_PROFILES_0100 max: " + videoProfilesFrameRateRange.max); + } + expect(true).assertTrue(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_VIDEO_PROFILES_0100 PASSED camera:" + camerasArray[i].cameraId); + } + await sleep(1000); + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_CALLBACK_0100 + * @tc.name : Create camerainput from camera-0 cameraId async api + * @tc.desc : Create camerainput from camera-0 cameraId async api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_CALLBACK_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_CALLBACK_0100--------------"); + if (isEmpty(mCameraManager)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_CALLBACK_0100 cameraManager == null || undefined") + expect().assertFail(); + } else { + let camerasArray = mCameraDevicesArray; + for (let i = 0; i < camerasArray.length; i++) { + mCameraManager.createCameraInput(camerasArray[i], async (err, data) => { + if (!err) { + if (isEmpty(data)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_CALLBACK_0100 data == null || undefined") + expect().assertFail(); + } + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_CALLBACK_0100 PASSED with CameraID :" + mCameraDevicesArray[0].cameraId); + } else { + expect().assertFail(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_CALLBACK_0100 FAILED: " + err.message); + } + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_CALLBACK_0100 camera: " + camerasArray[i].cameraId); + }) + } + } + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_CALLBACK_0100 ends here"); + await sleep(1000); + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_PROMISE_0100 + * @tc.name : Create camerainput from camera-0 cameraId promise api + * @tc.desc : Create camerainput from camera-0 cameraId promise api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_PROMISE_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_PROMISE_0100--------------"); + if (isEmpty(mCameraManager)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_PROMISE_0100 cameraManager == null || undefined") + expect().assertFail(); + } else { + let camerasArray = mCameraDevicesArray; + for (let i = 0; i < camerasArray.length; i++) { + let cameraInputPromise = await mCameraManager.createCameraInput(camerasArray[i]); + if (isEmpty(cameraInputPromise)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_PROMISE_0100 cameraInputPromise == null || undefined") + expect().assertFail(); + } + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_PROMISE_0100 camera: " + camerasArray[i].cameraId); + } + } + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_PROMISE_0100 ends here"); + await sleep(1000); + done(); + }) + + + /*CREATE CAMERAOUTPUT*/ + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_PREVIEW_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 0 + */ + it('SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_PREVIEW_OUTPUT_CALLBACK_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_PREVIEW_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_PREVIEW_OUTPUT_CALLBACK_0100 camera:" + camerasArray[i].cameraId); + expect(isEmpty(cameraOutputCap)).assertFalse(); + + let previewProfilesArray = cameraOutputCap.previewProfiles; + if (isEmpty(previewProfilesArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_PREVIEW_OUTPUT_CALLBACK_0100 previewProfilesArray == null || undefined") + expect().assertFail(); + } + for (let j = 0; j < previewProfilesArray.length; j++) { + mCameraManager.createPreviewOutput(previewProfilesArray[j], surfaceId, async (err, data) => { + if (isEmpty(data)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_PREVIEW_OUTPUT_CALLBACK_0100 data == null || undefined") + expect().assertFail(); + } + }) + await sleep(10); + done(); + } + } + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_PREVIEW_OUTPUT_CALLBACK_0100 PASS"); + await sleep(1000); + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_PREVIEW_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 0 + */ + it('SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_PREVIEW_OUTPUT_PROMISE_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_PREVIEW_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_PREVIEW_OUTPUT_PROMISE_0100 camera:" + camerasArray[i].cameraId); + if (isEmpty(cameraOutputCap)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_PREVIEW_OUTPUT_PROMISE_0100 cameraOutputCap == null || undefined") + expect().assertFail(); + } + + let previewProfilesArray = cameraOutputCap.previewProfiles; + if (isEmpty(previewProfilesArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_PREVIEW_OUTPUT_PROMISE_0100 previewProfilesArray == null || undefined") + expect().assertFail(); + } + for (let j = 0; j < previewProfilesArray.length; j++) { + let previewOutputPromise = await mCameraManager.createPreviewOutput(previewProfilesArray[j], surfaceId); + if (isEmpty(previewOutputPromise)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_PREVIEW_OUTPUT_PROMISE_0100 previewOutputPromise == null || undefined") + expect().assertFail(); + } + await sleep(10); + done(); + } + } + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_PREVIEW_OUTPUT_PROMISE_0100 PASS"); + await sleep(1000); + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_PHOTO_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 0 + */ + it('SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_PHOTO_OUTPUT_CALLBACK_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_PHOTO_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_PHOTO_OUTPUT_CALLBACK_0100 camera:" + camerasArray[i].cameraId); + if (isEmpty(cameraOutputCap)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_PHOTO_OUTPUT_CALLBACK_0100 cameraOutputCap == null || undefined") + expect().assertFail(); + } + + let photoProfilesArray = cameraOutputCap.photoProfiles; + if (isEmpty(photoProfilesArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_PHOTO_OUTPUT_CALLBACK_0100 photoProfilesArray == null || undefined") + expect().assertFail(); + } + for (let j = 0; j < photoProfilesArray.length; j++) { + mCameraManager.createPhotoOutput(photoProfilesArray[j], mPhotoSurfaceId, 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(); + } + } + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_PHOTO_OUTPUT_CALLBACK_0100 PASS"); + await sleep(1000); + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_PHOTO_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 0 + */ + it('SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_PHOTO_OUTPUT_PROMISE_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_PHOTO_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_PHOTO_OUTPUT_PROMISE_0100 camera:" + camerasArray[i].cameraId); + if (isEmpty(cameraOutputCap)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_PHOTO_OUTPUT_PROMISE_0100 cameraOutputCap == null || undefined") + expect().assertFail(); + } + + let photoProfilesArray = cameraOutputCap.photoProfiles; + if (isEmpty(photoProfilesArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_PHOTO_OUTPUT_PROMISE_0100 photoProfilesArray == null || undefined") + expect().assertFail(); + } + for (let j = 0; j < photoProfilesArray.length; j++) { + let photoOutputPromise = await mCameraManager.createPhotoOutput(photoProfilesArray[j], mPhotoSurfaceId); + 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(); + } + } + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_PHOTO_OUTPUT_PROMISE_0100 PASS"); + await sleep(1000); + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_VIDEO_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 0 + */ + it('SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_VIDEO_OUTPUT_CALLBACK_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_VIDEO_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_VIDEO_OUTPUT_CALLBACK_0100 camera:" + camerasArray[i].cameraId); + if (isEmpty(cameraOutputCap)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_VIDEO_OUTPUT_CALLBACK_0100 cameraOutputCap == null || undefined") + expect().assertFail(); + } + + let videoProfilesArray = cameraOutputCap.videoProfiles; + if (isEmpty(videoProfilesArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_VIDEO_OUTPUT_CALLBACK_0100 videoProfilesArray == null || undefined") + expect().assertFail(); + } + 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") + expect().assertFail(); + } + }) + await sleep(10); + done(); + } + } + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_VIDEO_OUTPUT_CALLBACK_0100 PASS"); + await sleep(1000); + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_VIDEO_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 0 + */ + it('SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_VIDEO_OUTPUT_PROMISE_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_VIDEO_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_VIDEO_OUTPUT_PROMISE_0100 camera:" + camerasArray[i].cameraId); + if (isEmpty(cameraOutputCap)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_VIDEO_OUTPUT_PROMISE_0100 cameraOutputCap == null || undefined") + expect().assertFail(); + } + + let videoProfilesArray = cameraOutputCap.videoProfiles; + if (isEmpty(videoProfilesArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_VIDEO_OUTPUT_PROMISE_0100 videoProfilesArray == null || undefined") + expect().assertFail(); + } + for (let j = 0; j < videoProfilesArray.length; j++) { + let videoOutputPromise = await mCameraManager.createVideoOutput(videoProfilesArray[j], mVideoSurface); + if (isEmpty(videoOutputPromise)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_VIDEO_OUTPUT_PROMISE_0100 videoOutputPromise == null || undefined") + expect().assertFail(); + } + await sleep(10); + done(); + } + } + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_VIDEO_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 + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_CREATE_CAPTURE_SESSION_CALLBACK_0100', 0, async function (done) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAPTURE_SESSION_CALLBACK_0100 to operate"); + let cameraSession; + mCameraManager.createCaptureSession(async (err, data) => { + if (!err) { + console.info(TAG + "Entering createCaptureSession success"); + if (isEmpty(data)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAPTURE_SESSION_CALLBACK_0100 data == null || undefined") + expect().assertFail(); + } else { + cameraSession = data; + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAPTURE_SESSION_CALLBACK_0100 PASSED"); + } + } else { + expect().assertFail(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAPTURE_SESSION_CALLBACK_0100 FAILED : " + err.message); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAPTURE_SESSION_CALLBACK_0100 ends here"); + } + await sleep(1000); + done(); + }) + await sleep(1000); + await cameraSession.release(); + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_CREATE_CAPTURE_SESSION_PROMISE_0100 + * @tc.name : Create CaptureSession instance promise api + * @tc.desc : Create Capturesession instance promise api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_CREATE_CAPTURE_SESSION_PROMISE_0100', 0, async function (done) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAPTURE_SESSION_PROMISE_0100 to operate"); + let captureSessionPromise = await mCameraManager.createCaptureSession(); + if (isEmpty(captureSessionPromise)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAPTURE_SESSION_PROMISE_0100 captureSessionPromise == null || undefined") + expect().assertFail(); + } + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAPTURE_SESSION_PROMISE_0100 PASSED"); + await sleep(1000); + await captureSessionPromise.release(); + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_CAMERA_STATUS_CALLBACK_0100 + * @tc.name : camera status callback on CameraManager async api + * @tc.desc : camera status callback on CameraManager async api + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_CAMERA_STATUS_CALLBACK_0100', 0, async function (done) { + if (isEmpty(mCameraManager)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_STATUS_CALLBACK_0100 cameraManager == null || undefined") + expect().assertFail(); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_STATUS_CALLBACK_0100 to operate") + mCameraManager.on('cameraStatus', async (err, data) => { + if (!err) { + console.info(TAG + "Camera status Callback on cameraManager is success"); + if (isEmpty(data)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_STATUS_CALLBACK_0100 data == null || undefined") + expect().assertFail(); + } + console.info(TAG + "Camera status Callback CameraStatusInfo_Camera: " + data.camera); + console.info(TAG + "Camera status Callback CameraStatusInfo_Status: " + data.status); + } else { + expect().assertFail(); + console.info(TAG + "SUB_MULTIMEDIA_CAMERA_CAMERA_STATUS_CALLBACK_0100 FAILED: " + err.message); + } + await sleep(1000); + done(); + }) + } + await sleep(1000); + done(); + }) +}) +} \ No newline at end of file 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 new file mode 100755 index 0000000000000000000000000000000000000000..b076a395226e4d54a0940b99ffa1f4e195963769 --- /dev/null +++ b/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraSessionBaseTest.test.ets @@ -0,0 +1,1423 @@ +/* + * 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. + */ + +// @ts-ignore + +import cameraObj from '@ohos.multimedia.camera'; +import image from '@ohos.multimedia.image'; +import media from '@ohos.multimedia.media' +import mediaLibrary from '@ohos.multimedia.mediaLibrary' +import fileio from '@ohos.fileio'; +import abilityAccessCtrl from '@ohos.abilityAccessCtrl' +import bundle from '@ohos.bundle' +import deviceInfo from '@ohos.deviceInfo'; +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'; + +const TAG = "CameraModuleTest: "; + +// Define global letiables +let mCameraManager; +let mCameraDevicesArray; +let mCameraSession; + +let mPhoteSurface; +let mVideoRecorder; +let mVideoSurface; +let mFileAsset; +let mFdPath; +let mFdNumber; + +// CAMERA-0 letiables +let mCameraInputArray; +let mPreviewOutputArray; +let mPhotoOutputArray; +let mVideoOutputArray; + +let mVideoProfileCfg = { + audioBitrate: 48000, + audioChannels: 2, + audioCodec: 'audio/mp4a-latm', + audioSampleRate: 48000, + durationTime: 1000, + fileFormat: 'mp4', + videoBitrate: 48000, + videoCodec: 'video/mp4v-es', + videoFrameWidth: 640, + videoFrameHeight: 480, + videoFrameRate: 30 +} + +let mVideoConfig = { + audioSourceType: 1, + videoSourceType: 0, + profile: mVideoProfileCfg, + url: 'file:///data/media/CameraSessionBase.mp4', + orientationHint: 0, + location: { latitude: 30, longitude: 130 }, + maxSize: 100, + maxDuration: 500 +} + +export default function cameraSessionTest(surfaceId: any) { + + function sleep(ms) { + console.info(TAG + "Entering sleep -> Promise constructor"); + return new Promise(resolve => setTimeout(resolve, ms)); + } + + function isEmpty(data) { + if (data == null || data == undefined) { + return true; + } + return false; + } + + async function getFd(pathName){ + let displayName = pathName; + const mediaTest = mediaLibrary.getMediaLibrary(); + let fileKeyObj = mediaLibrary.FileKey; + let mediaType = mediaLibrary.MediaType.VIDEO; + let publicPath = await mediaTest.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO); + let dataUri = await mediaTest.createAsset(mediaType, displayName, publicPath); + if (dataUri != undefined) { + let args = dataUri.id.toString(); + let fetchOp = { + selections: fileKeyObj.ID + "=?", + selectionArgs: [args], + } + let fetchFileResult = await mediaTest.getFileAssets(fetchOp); + mFileAsset = await fetchFileResult.getAllObject(); + mFdNumber = await mFileAsset[0].open('Rw'); + mFdPath = "fd://" + mFdNumber.toString(); + } + } + + async function closeFd() { + if (mFileAsset != null) { + await mFileAsset[0].close(mFdNumber).then(() => { + console.info('[mediaLibrary] case close fd success'); + }).catch((err) => { + console.info('[mediaLibrary] case close fd failed'); + }); + } else { + console.info('[mediaLibrary] case fileAsset is null'); + } + } + + async function applyPermission() { + let appInfo = await bundle.getApplicationInfo('com.open.harmony.multimedia.cameratest', 0, 100); + let atManager = abilityAccessCtrl.createAtManager(); + if (atManager != null) { + let tokenID = appInfo.accessTokenId; + console.info('[permission] case accessTokenID is ' + tokenID); + let permissionName1 = 'ohos.permission.CAMERA'; + let permissionName2 = 'ohos.permission.MICROPHONE'; + let permissionName3 = 'ohos.permission.MEDIA_LOCATION'; + let permissionName4 = 'ohos.permission.READ_MEDIA'; + let permissionName5 = 'ohos.permission.WRITE_MEDIA'; + let permissionName6 = 'ohos.permission.START_ABILITIES_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) => { + console.info('[permission] case grantUserGrantedPermission failed :' + err); + }); + await atManager.grantUserGrantedPermission(tokenID, permissionName2, 1).then((result) => { + console.info('[permission] case grantUserGrantedPermission success :' + result); + }).catch((err) => { + console.info('[permission] case grantUserGrantedPermission failed :' + err); + }); + await atManager.grantUserGrantedPermission(tokenID, permissionName3, 1).then((result) => { + console.info('[permission] case grantUserGrantedPermission success :' + result); + }).catch((err) => { + console.info('[permission] case grantUserGrantedPermission failed :' + err); + }); + await atManager.grantUserGrantedPermission(tokenID, permissionName4, 1).then((result) => { + console.info('[permission] case grantUserGrantedPermission success :' + result); + }).catch((err) => { + console.info('[permission] case grantUserGrantedPermission failed :' + err); + }); + await atManager.grantUserGrantedPermission(tokenID, permissionName5, 1).then((result) => { + console.info('[permission] case grantUserGrantedPermission success :' + result); + }).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 getPhotoReceiverSurface() { + console.log(TAG + 'Entering getPhotoReceiverSurface') + let receiver = image.createImageReceiver(640, 480, 4, 8) + 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)) + } else { + console.log(TAG + 'Photo receiver is created failed') + } + console.log(TAG + 'Exit getPhotoReceiverSurface') + } + + async function getVideoReceiveSurface() { + console.log(TAG + 'Entering getVideoReceiveSurface') + await getFd('CameraSessionBase.mp4'); + mVideoConfig.url = mFdPath; + media.createVideoRecorder((err, recorder) => { + console.info(TAG + 'Entering create video receiver') + mVideoRecorder = recorder + console.info(TAG + 'videoRecorder is :' + JSON.stringify(mVideoRecorder)) + console.info(TAG + 'videoRecorder.prepare called.') + mVideoRecorder.prepare(mVideoConfig, (err) => { + console.info(TAG + 'videoRecorder.prepare success.') + mVideoRecorder.getInputSurface((err, id) => { + console.info(TAG + 'getInputSurface called') + mVideoSurface = id + console.info(TAG + 'getInputSurface surfaceId: ' + JSON.stringify(mVideoSurface)) + }) + }) + }) + console.log(TAG + 'Exit getVideoReceiveSurface') + } + + async function releaseVideoReceiveSurface() { + console.log(TAG + 'Entering releaseVideoReceiveSurface') + mVideoRecorder.release((err) => { + console.info(TAG + 'Entering release video receiver') + }) + await closeFd(); + console.log(TAG + 'Exit releaseVideoReceiveSurface') + } + + async function getCameraManagerInstance() { + console.info('Enter getCameraManagerInstance'); + + mCameraManager = await cameraObj.getCameraManager(null); + if (isEmpty(mCameraManager)) { + 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 + "getCameraSupportDevicesArray is: " + mCameraDevicesArray.length); + 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 createInputs() { + console.info('Enter createInputs'); + + if (isEmpty(mCameraDevicesArray)) { + console.info(TAG + "Entering createInputs FAILED with NoCamera"); + return false; + } + + mCameraInputArray = new Array(mCameraDevicesArray.length); + + for (let i = 0; i < mCameraDevicesArray.length; i++) { + mCameraInputArray[i] = await mCameraManager.createCameraInput(mCameraDevicesArray[i]); + if (isEmpty(mCameraInputArray[i])) { + console.info(TAG + "createCameraInput FAILED"); + return false; + } + + mCameraInputArray[i].open(async (err) => { + console.info(TAG + "Entering mCameraInputArray open callback"); + if (!err) { + console.info(TAG + "Entering mCameraInputArray open PASSED "); + } else { + console.info(TAG + "Entering mCameraInputArray open FAILED : " + err.message); + } + }) + + await sleep(2000); + + console.info(i + 'th CameraInput is: ' + mCameraInputArray[i]); + } + + console.info('Exit createInputs'); + + return true; + } + + async function releaseInputs() { + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering releaseInputs FAILED with NoCamera"); + } + + for (let i = 0; i < mCameraInputArray.length; i++) { + await mCameraInputArray[i].close(); + await mCameraInputArray[i].release(); + } + + return true; + } + + async function createOutputs() { + console.info('Enter createOutputs'); + + mPreviewOutputArray = new Array(mCameraDevicesArray.length); + mPhotoOutputArray = new Array(mCameraDevicesArray.length); + mVideoOutputArray = new Array(mCameraDevicesArray.length); + + for (let i = 0; i < mCameraDevicesArray.length; i++) { + let cameraOutputCap = await mCameraManager.getSupportedOutputCapability(mCameraDevicesArray[i]); + if (!isEmpty(cameraOutputCap.previewProfiles)) { + console.info(TAG + "cameraOutputCap.previewProfiles.length: " + cameraOutputCap.previewProfiles.length); + for (let j = 0; j < cameraOutputCap.previewProfiles.length; j++) { + mPreviewOutputArray[i] = await mCameraManager.createPreviewOutput(cameraOutputCap.previewProfiles[j], surfaceId); + if (!isEmpty(mPreviewOutputArray[i])) { + break; + } + } + + if (isEmpty(mPreviewOutputArray[i])) { + console.info(TAG + "createPreviewOutput FAILED"); + } + } + } + + let cameraOutputCap = await mCameraManager.getSupportedOutputCapability(mCameraDevicesArray[0]); + if (!isEmpty(cameraOutputCap.photoProfiles)) { + console.info(TAG + "cameraOutputCap.photoProfiles.length: " + cameraOutputCap.photoProfiles.length); + + for (let j = 0; j < cameraOutputCap.photoProfiles.length; j++) { + mPhotoOutputArray[0] = await mCameraManager.createPhotoOutput(cameraOutputCap.photoProfiles[j], mPhoteSurface); + if (!isEmpty(mPhotoOutputArray[0])) { + break; + } + } + + if (isEmpty(mPhotoOutputArray[0])) { + console.info(TAG + "createPhotoOutput FAILED"); + } + + console.info(TAG + "createPhotoOutput: " + mPhotoOutputArray[0]); + } + + if (!isEmpty(cameraOutputCap.videoProfiles)) { + console.info(TAG + "cameraOutputCap.videoProfiles.length: " + cameraOutputCap.videoProfiles.length); + for (let j = 0; j < cameraOutputCap.videoProfiles.length; j++) { + mVideoOutputArray[0] = await mCameraManager.createVideoOutput(cameraOutputCap.videoProfiles[j], mVideoSurface); + if (!isEmpty(mVideoOutputArray[0])) { + break; + } + } + + if (isEmpty(mVideoOutputArray[0])) { + console.info(TAG + "createVideoOutput FAILED"); + } + + console.info(TAG + "createVideoOutput: " + mPhotoOutputArray[0]); + } + + console.info('Exit createOutputs'); + + return true; + } + + async function releaseOutputs() { + for (let i = 0; i < mCameraDevicesArray.length; i++) { + if (!isEmpty(mPreviewOutputArray[i])) { + await mPreviewOutputArray[i].close(); + await mPreviewOutputArray[i].release(); + } + } + + if (!isEmpty(mPhotoOutputArray[0])) { + await mPhotoOutputArray[0].close(); + await mPhotoOutputArray[0].release(); + } + + if (!isEmpty(mVideoOutputArray[0])) { + await mVideoOutputArray[0].close(); + await mVideoOutputArray[0].release(); + } + + return true; + } + + async function startCameraSession(idx:any) { + console.info(TAG + "Enter startCameraSession"); + + if (!isEmpty(mCameraInputArray[idx])) { + console.info(TAG + "Start to addInput"); + await mCameraSession.addInput(mCameraInputArray[idx]); + } + + if (!isEmpty(mPreviewOutputArray[idx])) { + console.info(TAG + "Start to addOutput mPreviewOutput"); + await mCameraSession.addOutput(mPreviewOutputArray[idx]); + } + + /* + if (!isEmpty(mPhotoOutputArray[idx])) { + console.info(TAG + "Start to addOutput mPhotoOutput"); + await mCameraSession.addOutput(mPhotoOutputArray[idx]); + } + + if (!isEmpty(mVideoOutputArray[idx])) { + console.info(TAG + "Start to addOutput mVideoOutput"); + await mCameraSession.addOutput(mVideoOutputArray[idx]); + } + */ + + await commitCameraSessionConfig(); + + /* + await mCameraSession.start(async (err) => { + console.info(TAG + "Entering mCameraSession start callback"); + if (!err) { + console.info(TAG + "Entering mCameraSession start PASSED "); + } else { + console.info(TAG + "Entering mCameraSession start FAILED : " + err.message); + } + }) + + await sleep(1000); + */ + console.info(TAG + "Exit startCameraSession"); + + return true; + } + + async function stopCameraSession(idx:any) { + console.info(TAG + "Enter stopCameraSession"); + /* + mCameraSession.stop(async (err) => { + console.info(TAG + "Entering mCameraSession stop callback"); + if (!err) { + console.info(TAG + "Entering mCameraSession stop PASSED "); + } else { + console.info(TAG + "Entering mCameraSession stop FAILED : " + err.message); + } + }) + + await sleep(1000); + */ + + if (!isEmpty(mCameraInputArray[idx])) { + console.info(TAG + "Start to removeInput input"); + await mCameraSession.removeInput(mCameraInputArray[idx]); + } + + if (!isEmpty(mPreviewOutputArray[idx])) { + console.info(TAG + "Start to removeOutput mPreviewOutput"); + await mCameraSession.removeOutput(mPreviewOutputArray[idx]); + } + + /* + if (!isEmpty(mPhotoOutputArray[idx])) { + console.info(TAG + "Start to removeOutput mPhotoOutput"); + await mCameraSession.removeOutput(mPhotoOutputArray[idx]); + } + + if (!isEmpty(mVideoOutputArray[idx])) { + console.info(TAG + "Start to removeOutput mVideoOutput"); + await mCameraSession.removeOutput(mVideoOutputArray[idx]); + } + */ + + console.info(TAG + "Exit stopCameraSession"); + + return true; + } + + describe('CameraSessionBaseTest', function () { + console.info(TAG + '----------CameraSessionTest--------------') + + beforeAll(async function () { + sleep(100); + await applyPermission(); + await getPhotoReceiverSurface(); + await getVideoReceiveSurface(); + await getCameraManagerInstance(); + await getCameraSupportDevicesArray(); + await createCameraSessionInstance(); + await createInputs(); + await createOutputs(); + + console.info('Device type = ' + deviceInfo.deviceType); + + console.info('beforeAll case'); + }) + + beforeEach(async function () { + await sleep(100); + console.info('beforeEach case'); + //await createCameraSessionInstance(); + await sleep(100); + }) + + afterEach(async function () { + console.info('afterEach case'); + //await releaseCameraSessionInstance(); + await sleep(100); + }) + + afterAll(function () { + releaseInputs(); + releaseOutputs(); + releaseVideoReceiveSurface(); + releaseCameraSessionInstance(); + sleep(1000); + console.info('afterAll case'); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_CONFIG_CALLBACK_0100 + * @tc.name : Check capture session begin and commit config with callback or not + * @tc.desc : Check capture session begin and commit config with callback or not + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_CONFIG_CALLBACK_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_CONFIG_CALLBACK_0100--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_CONFIG_CALLBACK_0100 FAILED with NoCamera"); + expect().assertFail(); + done(); + } + else { + if (!isEmpty(mCameraInputArray[0])) { + console.info(TAG + "Start to addInput"); + try { + await mCameraSession.addInput(mCameraInputArray[0]); + } + catch { + console.info(TAG + "addInput failed!"); + } + } + + if (!isEmpty(mPreviewOutputArray[0])) { + console.info(TAG + "Start to addOutput mPreviewOutput"); + try { + await mCameraSession.addOutput(mPreviewOutputArray[0]); + } + catch { + console.info(TAG + "addOutput failed!"); + } + } + + await sleep(500); + + mCameraSession.commitConfig(async (err) => { + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_CONFIG_CALLBACK_0100 PASSED"); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_CONFIG_CALLBACK_0100 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + mCameraSession.beginConfig(async (err) => { + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_CONFIG_CALLBACK_0100 PASSED"); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_CONFIG_CALLBACK_0100 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + if (!isEmpty(mCameraInputArray[0])) { + console.info(TAG + "Start to removeInput"); + await mCameraSession.removeInput(mCameraInputArray[0]); + } + + if (!isEmpty(mPreviewOutputArray[0])) { + console.info(TAG + "Start to removeOutput mPreviewOutput"); + await mCameraSession.removeOutput(mPreviewOutputArray[0]); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_CONFIG_CALLBACK_0100 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_CONFIG_PROMISE_0100 + * @tc.name : Check capture session begin and commit config with promise or not + * @tc.desc : Check capture session begin and commit config with promise or not + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_CONFIG_PROMISE_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_CONFIG_PROMISE_0100--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_CONFIG_PROMISE_0100 FAILED with NoCamera"); + expect().assertFail(); + done(); + } + else { + if (!isEmpty(mCameraInputArray[0])) { + console.info(TAG + "Start to addInput"); + await mCameraSession.addInput(mCameraInputArray[0]); + } + + if (!isEmpty(mPreviewOutputArray[0])) { + console.info(TAG + "Start to addOutput mPreviewOutput"); + await mCameraSession.addOutput(mPreviewOutputArray[0]); + } + + await sleep(500); + + try { + await mCameraSession.commitConfig(); + } catch { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_CONFIG_PROMISE_0100 commitConfig with a error"); + expect().assertFail(); + } + + try { + await mCameraSession.beginConfig(); + } catch { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_CONFIG_PROMISE_0100 beginConfig with a error"); + expect().assertFail(); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_CONFIG_PROMISE_0100 PASSED"); + + if (!isEmpty(mCameraInputArray[0])) { + console.info(TAG + "Start to removeInput"); + await mCameraSession.removeInput(mCameraInputArray[0]); + } + + if (!isEmpty(mPreviewOutputArray[0])) { + console.info(TAG + "Start to removeOutput mPreviewOutput"); + await mCameraSession.removeOutput(mPreviewOutputArray[0]); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_CONFIG_PROMISE_0100 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_BEGIN_CONFIG_DUPLICATED_CALLBACK_0100 + * @tc.name : Check capture session begin config duplicated with callback or not + * @tc.desc : Check capture session begin config duplicated with callback or not + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_BEGIN_CONFIG_DUPLICATED_CALLBACK_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_BEGIN_CONFIG_DUPLICATED_CALLBACK_0100--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_BEGIN_CONFIG_DUPLICATED_CALLBACK_0100 FAILED with NoCamera"); + expect().assertFail(); + done(); + } + else { + mCameraSession.beginConfig(async (err) => { + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_BEGIN_CONFIG_DUPLICATED_CALLBACK_0100 FAILED"); + expect().assertFail(); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_BEGIN_CONFIG_DUPLICATED_CALLBACK_0100 PASSED : " + err.message); + } + }) + await sleep(500); + + mCameraSession.beginConfig(async (err) => { + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_BEGIN_CONFIG_DUPLICATED_CALLBACK_0100 FAILED"); + expect().assertFail(); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_BEGIN_CONFIG_DUPLICATED_CALLBACK_0100 PASSED : " + err.message); + } + }) + await sleep(500); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_BEGIN_CONFIG_DUPLICATED_CALLBACK_0100 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_BEGIN_CONFIG_DUPLICATED_PROMISE_0100 + * @tc.name : Check capture session begin config duplicated with promise or not + * @tc.desc : Check capture session begin config duplicated with promise or not + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_BEGIN_CONFIG_DUPLICATED_PROMISE_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_BEGIN_CONFIG_DUPLICATED_PROMISE_0100--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_BEGIN_CONFIG_DUPLICATED_PROMISE_0100 FAILED with NoCamera"); + expect().assertFail(); + done(); + } + else { + try { + await mCameraSession.beginConfig(); + } catch { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_BEGIN_CONFIG_DUPLICATED_PROMISE_0100 with a error, ingore it"); + } + try { + await mCameraSession.beginConfig(); + } catch { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_BEGIN_CONFIG_DUPLICATED_PROMISE_0100 with a error, ingore it"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_BEGIN_CONFIG_DUPLICATED_PROMISE_0100 PASSED"); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_BEGIN_CONFIG_DUPLICATED_PROMISE_0100 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_COMMIT_CONFIG_DUPLICATED_CALLBACK_0100 + * @tc.name : Check capture session begin config duplicated with callback or not + * @tc.desc : Check capture session begin config duplicated with callback or not + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_COMMIT_CONFIG_DUPLICATED_CALLBACK_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_COMMIT_CONFIG_DUPLICATED_CALLBACK_0100--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_COMMIT_CONFIG_DUPLICATED_CALLBACK_0100 FAILED with NoCamera"); + expect().assertFail(); + done(); + } + else { + mCameraSession.commitConfig(async (err) => { + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_COMMIT_CONFIG_DUPLICATED_CALLBACK_0100 FAILED"); + expect().assertFail(); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_COMMIT_CONFIG_DUPLICATED_CALLBACK_0100 PASSED : " + err.message); + } + }) + await sleep(500); + + mCameraSession.commitConfig(async (err) => { + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_COMMIT_CONFIG_DUPLICATED_CALLBACK_0100 FAILED"); + expect().assertFail(); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_COMMIT_CONFIG_DUPLICATED_CALLBACK_0100 PASSED : " + err.message); + } + }) + await sleep(500); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_COMMIT_CONFIG_DUPLICATED_CALLBACK_0100 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_COMMIT_CONFIG_DUPLICATED_PROMISE_0100 + * @tc.name : Check capture session begin config duplicated with promise or not + * @tc.desc : Check capture session begin config duplicated with promise or not + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_COMMIT_CONFIG_DUPLICATED_PROMISE_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_COMMIT_CONFIG_DUPLICATED_PROMISE_0100--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_COMMIT_CONFIG_DUPLICATED_PROMISE_0100 FAILED with NoCamera"); + expect().assertFail(); + done(); + } + else { + try { + await mCameraSession.commitConfig(); + } catch { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_COMMIT_CONFIG_DUPLICATED_PROMISE_0100 with a error, ingore it"); + } + try { + await mCameraSession.commitConfig(); + } catch { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_COMMIT_CONFIG_DUPLICATED_PROMISE_0100 with a error, ingore it"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_COMMIT_CONFIG_DUPLICATED_PROMISE_0100 PASSED"); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_COMMIT_CONFIG_DUPLICATED_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 + * @tc.desc : Check capture session add/remove input with callback or not + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_INPUT_CALLBACK_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_INPUT_CALLBACK_0100--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_INPUT_CALLBACK_0100 FAILED with NoCamera"); + expect().assertFail(); + done(); + } + else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_INPUT_CALLBACK_0100 start for camera[" + i + "]"); + + mCameraSession.addInput(mCameraInputArray[i], async (err) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_INPUT_CALLBACK_0100 callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_INPUT_CALLBACK_0100 PASSED"); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_INPUT_CALLBACK_0100 FAILED : " + err.message); + expect().assertFail(); + } + }) + await mCameraSession.addOutput(mPreviewOutputArray[i]); + await mCameraSession.addOutput(mPhotoOutputArray[i]); + await sleep(500); + + await commitCameraSessionConfig(); + await sleep(1); + await beginCameraSessionConfig(); + await sleep(1); + + mCameraSession.removeInput(mCameraInputArray[i], async (err) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_INPUT_CALLBACK_0100 callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_INPUT_CALLBACK_0100 PASSED"); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_INPUT_CALLBACK_0100 FAILED : " + err.message); + expect().assertFail(); + } + }) + await mCameraSession.removeOutput(mPreviewOutputArray[i]); + await mCameraSession.removeOutput(mPhotoOutputArray[i]); + await sleep(500); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_INPUT_CALLBACK_0100 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_INPUT_CALLBACK_0100 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_INPUT_PROMISE_0100 + * @tc.name : Check capture session can add input with promise or not + * @tc.desc : Check capture session can add input with promise or not + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_INPUT_PROMISE_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_INPUT_PROMISE_0100--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_INPUT_PROMISE_0100 FAILED with NoCamera"); + expect().assertFail(); + done(); + } + else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_INPUT_PROMISE_0100 start for camera[" + i + "]"); + + await mCameraSession.addInput(mCameraInputArray[i]); + await mCameraSession.addOutput(mPreviewOutputArray[i]); + await mCameraSession.addOutput(mPhotoOutputArray[i]); + await sleep(500); + + await commitCameraSessionConfig(); + await sleep(1); + await beginCameraSessionConfig(); + await sleep(1); + + await mCameraSession.removeInput(mCameraInputArray[i]); + await mCameraSession.removeOutput(mPreviewOutputArray[i]); + await mCameraSession.removeOutput(mPhotoOutputArray[i]); + await sleep(500); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_INPUT_PROMISE_0100 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_INPUT_PROMISE_0100 ends here"); + done(); + } + }) + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_OUTPUT_CALLBACK_0100 + * @tc.name : Check capture session add/remove output with callback or not for preview + * @tc.desc : Check capture session add/remove output with callback or not for preview + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_OUTPUT_CALLBACK_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_OUTPUT_CALLBACK_0100--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_OUTPUT_CALLBACK_0100 FAILED with NoCamera"); + expect().assertFail(); + done(); + } + else { + if (!isEmpty(mPreviewOutputArray[0])) { + mCameraSession.addOutput(mPreviewOutputArray[0], async (err) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_OUTPUT_CALLBACK_0100 add callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_OUTPUT_CALLBACK_0100 add PASSED"); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_OUTPUT_CALLBACK_0100 add FAILED : " + err.message); + expect().assertFail(); + } + }) + await mCameraSession.addOutput(mPhotoOutputArray[0]); + await mCameraSession.addInput(mCameraInputArray[0]); + await sleep(500); + + await commitCameraSessionConfig(); + await sleep(1); + await beginCameraSessionConfig(); + await sleep(1); + + await sleep(500); + + mCameraSession.removeOutput(mPreviewOutputArray[0], async (err) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_OUTPUT_CALLBACK_0100 remove callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_OUTPUT_CALLBACK_0100 remove PASSED"); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_OUTPUT_CALLBACK_0100 remove FAILED : " + err.message); + expect().assertFail(); + } + }) + await mCameraSession.removeOutput(mPhotoOutputArray[0]); + await mCameraSession.removeInput(mCameraInputArray[0]); + await sleep(500); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_OUTPUT_CALLBACK_0100 FAILED"); + expect().assertFail(); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_OUTPUT_CALLBACK_0100 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_OUTPUT_PROMISE_0100 + * @tc.name : Check capture session can add output with promise or not for preview + * @tc.desc : Check capture session can add output with promise or not for preview + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_OUTPUT_PROMISE_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_OUTPUT_PROMISE_0100--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_OUTPUT_PROMISE_0100 FAILED with NoCamera"); + expect().assertFail(); + done(); + } + else { + if (!isEmpty(mPreviewOutputArray[0])) { + await mCameraSession.addOutput(mPreviewOutputArray[0]); + await mCameraSession.addOutput(mPhotoOutputArray[0]); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_OUTPUT_PROMISE_0100 add PASSED"); + await mCameraSession.addInput(mCameraInputArray[0]); + await sleep(500); + + await commitCameraSessionConfig(); + await sleep(1); + await beginCameraSessionConfig(); + await sleep(1); + + await sleep(500); + + await mCameraSession.removeOutput(mPreviewOutputArray[0]); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_OUTPUT_PROMISE_0100 remove PASSED"); + await mCameraSession.removeOutput(mPhotoOutputArray[0]); + await mCameraSession.removeInput(mCameraInputArray[0]); + await sleep(500); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_OUTPUT_PROMISE_0100 FAILED"); + expect().assertFail(); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_OUTPUT_PROMISE_0100 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_OUTPUT_CALLBACK_0101 + * @tc.name : Check capture session add/remove output with callback or not for photo + * @tc.desc : Check capture session add/remove output with callback or not for photo + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_OUTPUT_CALLBACK_0101', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_OUTPUT_CALLBACK_0101--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_OUTPUT_CALLBACK_0101 FAILED with NoCamera"); + expect().assertFail(); + done(); + } + else { + if (!isEmpty(mPhotoOutputArray[0])) { + if (!isEmpty(mPreviewOutputArray[0])) { + console.info(TAG + "Start to addOutput mPreviewOutput"); + await mCameraSession.addOutput(mPreviewOutputArray[0]); + } + mCameraSession.addOutput(mPhotoOutputArray[0], async (err) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_OUTPUT_CALLBACK_0101 add callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_OUTPUT_CALLBACK_0101 add PASSED"); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_OUTPUT_CALLBACK_0101 add FAILED : " + err.message); + expect().assertFail(); + } + }) + await mCameraSession.addInput(mCameraInputArray[0]); + await sleep(500); + + await commitCameraSessionConfig(); + await sleep(1); + await beginCameraSessionConfig(); + await sleep(1); + + await sleep(500); + + if (!isEmpty(mPreviewOutputArray[0])) { + console.info(TAG + "Start to removeOutput mPreviewOutput"); + await mCameraSession.removeOutput(mPreviewOutputArray[0]); + } + mCameraSession.removeOutput(mPhotoOutputArray[0], async (err) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_OUTPUT_CALLBACK_0101 remove callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_OUTPUT_CALLBACK_0101 remove PASSED"); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_OUTPUT_CALLBACK_0101 remove FAILED : " + err.message); + expect().assertFail(); + } + }) + await mCameraSession.removeInput(mCameraInputArray[0]); + await sleep(500); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_OUTPUT_CALLBACK_0101 FAILED"); + expect().assertFail(); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_OUTPUT_CALLBACK_0101 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_OUTPUT_PROMISE_0101 + * @tc.name : Check capture session can add/remove output with promise or not for photo + * @tc.desc : Check capture session can add/remove output with promise or not for photo + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_OUTPUT_PROMISE_0101', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_OUTPUT_PROMISE_0101--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_OUTPUT_PROMISE_0101 FAILED with NoCamera"); + expect().assertFail(); + done(); + } + else { + if (!isEmpty(mPhotoOutputArray[0])) { + if (!isEmpty(mPreviewOutputArray[0])) { + console.info(TAG + "Start to addOutput mPreviewOutput"); + await mCameraSession.addOutput(mPreviewOutputArray[0]); + } + await mCameraSession.addOutput(mPhotoOutputArray[0]); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_OUTPUT_PROMISE_0101 add PASSED"); + await mCameraSession.addInput(mCameraInputArray[0]); + await sleep(500); + + await commitCameraSessionConfig(); + await sleep(1); + await beginCameraSessionConfig(); + await sleep(1); + + await sleep(500); + + if (!isEmpty(mPreviewOutputArray[0])) { + console.info(TAG + "Start to removeOutput mPreviewOutput"); + await mCameraSession.removeOutput(mPreviewOutputArray[0]); + } + await mCameraSession.removeOutput(mPhotoOutputArray[0]); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_OUTPUT_PROMISE_0101 remove PASSED"); + await mCameraSession.removeInput(mCameraInputArray[0]); + await sleep(500); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_OUTPUT_PROMISE_0101 FAILED"); + expect().assertFail(); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_OUTPUT_PROMISE_0101 ends here"); + done(); + } + }) + + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_STATUS_CALLBACK_0100 + * @tc.name : camera status callback on CaptureSession async api for focusStateChange + * @tc.desc : camera status callback on CaptureSession async api for focusStateChange + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_STATUS_CALLBACK_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_STATUS_CALLBACK_0100--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_STATUS_CALLBACK_0100 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + let nfyFlag = false; + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_STATUS_CALLBACK_0100 start for camera[" + i + "]"); + + await startCameraSession(i); + + mCameraSession.on('focusStateChange', async (err, data) => { + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_STATUS_CALLBACK_0100 callback"); + if (data != null || data != undefined) { + console.info(TAG + "SUB_MULTIMEDIA_CAMERA_SESSION_STATUS_CALLBACK_0100 PASSED: " + data); + nfyFlag = true; + } + } else { + expect().assertFail(); + console.info(TAG + "SUB_MULTIMEDIA_CAMERA_SESSION_STATUS_CALLBACK_0100 FAILED: " + err.message); + } + await sleep(1); + }) + + mCameraSession.setFocusMode(cameraObj.FocusMode.FOCUS_MODE_AUTO); + + await sleep(3000); + + if (nfyFlag == false) { + //expect().assertFail(); + //console.info(TAG + "SUB_MULTIMEDIA_CAMERA_SESSION_STATUS_CALLBACK_0100 FAILED without any nofity!"); + } + + await beginCameraSessionConfig(); + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_STATUS_CALLBACK_0100 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_STATUS_CALLBACK_0100 ends here"); + done(); + } + }) + + /** + * @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.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_STATUS_CALLBACK_0101', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_STATUS_CALLBACK_0101--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_STATUS_CALLBACK_0101 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + let nfyFlag = false; + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_STATUS_CALLBACK_0101 start for camera[" + i + "]"); + + await startCameraSession(i); + + mCameraSession.on('exposureStateChange', async (err, data) => { + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_STATUS_CALLBACK_0101 callback"); + if (data != null || data != undefined) { + console.info(TAG + "SUB_MULTIMEDIA_CAMERA_SESSION_STATUS_CALLBACK_0101 PASSED: " + data); + nfyFlag = true; + } + } else { + expect().assertFail(); + console.info(TAG + "SUB_MULTIMEDIA_CAMERA_SESSION_STATUS_CALLBACK_0101 FAILED: " + err.message); + } + 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(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_STATUS_CALLBACK_0101 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_STATUS_CALLBACK_0101 ends here"); + done(); + } + }) + + /** + * @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 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_STATUS_CALLBACK_0102', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_STATUS_CALLBACK_0102--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_STATUS_CALLBACK_0102 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; 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(i); + + 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 + * @tc.desc : Check capture session release with callback or not for preview + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_RELEASE_CALLBACK_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_RELEASE_CALLBACK_0100--------------"); + + await mCameraSession.release(async (err) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_RELEASE_CALLBACK_0100 callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_RELEASE_CALLBACK_0100 PASSED"); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_RELEASE_CALLBACK_0100 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + await await createCameraSessionInstance(); + await sleep(500); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_RELEASE_CALLBACK_0100 ends here"); + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_RELEASE_PROMISE_0100 + * @tc.name : Check capture session release with promise or not + * @tc.desc : Check capture session release with promise or not + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_RELEASE_PROMISE_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_RELEASE_PROMISE_0100--------------"); + + await mCameraSession.release() + await sleep(500); + + await await createCameraSessionInstance(); + await sleep(500); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_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/CameraSessionExposureTest.test.ets b/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraSessionExposureTest.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..3498f671020b8730ede6281654779f0145ae82c2 --- /dev/null +++ b/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraSessionExposureTest.test.ets @@ -0,0 +1,2812 @@ +/* + * 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. + */ + +// @ts-ignore + +import cameraObj from '@ohos.multimedia.camera'; +import image from '@ohos.multimedia.image'; +import media from '@ohos.multimedia.media' +import mediaLibrary from '@ohos.multimedia.mediaLibrary' +import fileio from '@ohos.fileio'; +import abilityAccessCtrl from '@ohos.abilityAccessCtrl' +import bundle from '@ohos.bundle' +import deviceInfo from '@ohos.deviceInfo'; +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'; + +const TAG = "CameraModuleTest: "; + +// Define global letiables +let mCameraManager; +let mCameraDevicesArray; +let mCameraSession; + +let mPhoteSurface; +let mVideoRecorder; +let mVideoSurface; +let mFileAsset; +let mFdPath; +let mFdNumber; + +// CAMERA-0 letiables +let mCameraInputArray; +let mPreviewOutputArray; +let mPhotoOutputArray; +let mVideoOutputArray; + +let mIsExposureModeSupportedArray; +let mExposureBiasRangeArray; +let mExposureBiasMaxArray; +let mExposureBiasMinArray; + +let mVideoProfileCfg = { + audioBitrate: 48000, + audioChannels: 2, + audioCodec: 'audio/mp4a-latm', + audioSampleRate: 48000, + durationTime: 1000, + fileFormat: 'mp4', + videoBitrate: 48000, + videoCodec: 'video/mp4v-es', + videoFrameWidth: 640, + videoFrameHeight: 480, + videoFrameRate: 30 +} + +let mVideoConfig = { + audioSourceType: 1, + videoSourceType: 0, + profile: mVideoProfileCfg, + url: 'file:///data/media/CameraSessionExposure.mp4', + orientationHint: 0, + location: { latitude: 30, longitude: 130 }, + maxSize: 100, + maxDuration: 500 +} + +let mPicWidthMax = 8192; +let mPicHeightMax = 8192; + +let mMETERINGPoint = { + x: mPicWidthMax / 2, + y: mPicHeightMax / 2, +} + +let mMETERINGPointLT = { + x: 0, + y: 0, +} + +let mMETERINGPointRT = { + x: mPicWidthMax, + y: 0, +} + +let mMETERINGPointLB = { + x: 0, + y: mPicHeightMax, +} + +let mMETERINGPointRB = { + x: mPicWidthMax, + y: mPicHeightMax, +} + +let mMETERINGPointInvalidLT = { + x: -1, + y: -1, +} + +let mMETERINGPointInvalidRT = { + x: (mPicWidthMax + 1), + y: -1, +} + +let mMETERINGPointInvalidLB = { + x: -1, + y: mPicHeightMax, +} + +let mMETERINGPointInvalidRB = { + x: (mPicWidthMax + 1), + y: (mPicHeightMax + 1), +} + +let mEnableCheckInvalidMETERINGPoint = false; + +export default function cameraSessionExposureTest(surfaceId: any) { + + function sleep(ms) { + console.info(TAG + "Entering sleep -> Promise constructor"); + return new Promise(resolve => setTimeout(resolve, ms)); + } + + function isEmpty(data) { + if (data == null || data == undefined) { + return true; + } + return false; + } + + async function getFd(pathName){ + let displayName = pathName; + const mediaTest = mediaLibrary.getMediaLibrary(); + let fileKeyObj = mediaLibrary.FileKey; + let mediaType = mediaLibrary.MediaType.VIDEO; + let publicPath = await mediaTest.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO); + let dataUri = await mediaTest.createAsset(mediaType, displayName, publicPath); + if (dataUri != undefined) { + let args = dataUri.id.toString(); + let fetchOp = { + selections: fileKeyObj.ID + "=?", + selectionArgs: [args], + } + let fetchFileResult = await mediaTest.getFileAssets(fetchOp); + mFileAsset = await fetchFileResult.getAllObject(); + mFdNumber = await mFileAsset[0].open('Rw'); + mFdPath = "fd://" + mFdNumber.toString(); + } + } + + async function closeFd() { + if (mFileAsset != null) { + await mFileAsset[0].close(mFdNumber).then(() => { + console.info('[mediaLibrary] case close fd success'); + }).catch((err) => { + console.info('[mediaLibrary] case close fd failed'); + }); + } else { + console.info('[mediaLibrary] case fileAsset is null'); + } + } + + async function applyPermission() { + let appInfo = await bundle.getApplicationInfo('com.open.harmony.multimedia.cameratest', 0, 100); + let atManager = abilityAccessCtrl.createAtManager(); + if (atManager != null) { + let tokenID = appInfo.accessTokenId; + console.info('[permission] case accessTokenID is ' + tokenID); + let permissionName1 = 'ohos.permission.CAMERA'; + let permissionName2 = 'ohos.permission.MICROPHONE'; + let permissionName3 = 'ohos.permission.MEDIA_LOCATION'; + let permissionName4 = 'ohos.permission.READ_MEDIA'; + let permissionName5 = 'ohos.permission.WRITE_MEDIA'; + await atManager.grantUserGrantedPermission(tokenID, permissionName1, 1).then((result) => { + console.info('[permission] case grantUserGrantedPermission success :' + result); + }).catch((err) => { + console.info('[permission] case grantUserGrantedPermission failed :' + err); + }); + await atManager.grantUserGrantedPermission(tokenID, permissionName2, 1).then((result) => { + console.info('[permission] case grantUserGrantedPermission success :' + result); + }).catch((err) => { + console.info('[permission] case grantUserGrantedPermission failed :' + err); + }); + await atManager.grantUserGrantedPermission(tokenID, permissionName3, 1).then((result) => { + console.info('[permission] case grantUserGrantedPermission success :' + result); + }).catch((err) => { + console.info('[permission] case grantUserGrantedPermission failed :' + err); + }); + await atManager.grantUserGrantedPermission(tokenID, permissionName4, 1).then((result) => { + console.info('[permission] case grantUserGrantedPermission success :' + result); + }).catch((err) => { + console.info('[permission] case grantUserGrantedPermission failed :' + err); + }); + await atManager.grantUserGrantedPermission(tokenID, permissionName5, 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 getPhotoReceiverSurface() { + console.log(TAG + 'Entering getPhotoReceiverSurface') + let receiver = image.createImageReceiver(640, 480, 4, 8) + 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)) + } else { + console.log(TAG + 'Photo receiver is created failed') + } + console.log(TAG + 'Exit getPhotoReceiverSurface') + } + + async function getVideoReceiveSurface() { + console.log(TAG + 'Entering getVideoReceiveSurface') + await getFd('CameraSessionExposure.mp4'); + mVideoConfig.url = mFdPath; + media.createVideoRecorder((err, recorder) => { + console.info(TAG + 'Entering create video receiver') + mVideoRecorder = recorder + console.info(TAG + 'videoRecorder is :' + JSON.stringify(mVideoRecorder)) + console.info(TAG + 'videoRecorder.prepare called.') + mVideoRecorder.prepare(mVideoConfig, (err) => { + console.info(TAG + 'videoRecorder.prepare success.') + mVideoRecorder.getInputSurface((err, id) => { + console.info(TAG + 'getInputSurface called') + mVideoSurface = id + console.info(TAG + 'getInputSurface surfaceId: ' + JSON.stringify(mVideoSurface)) + }) + }) + }) + console.log(TAG + 'Exit getVideoReceiveSurface') + } + + async function releaseVideoReceiveSurface() { + console.log(TAG + 'Entering releaseVideoReceiveSurface') + mVideoRecorder.release((err) => { + console.info(TAG + 'Entering release video receiver') + }) + await closeFd(); + console.log(TAG + 'Exit releaseVideoReceiveSurface') + } + + async function getCameraManagerInstance() { + console.info('Enter getCameraManagerInstance'); + + mCameraManager = await cameraObj.getCameraManager(null); + if (isEmpty(mCameraManager)) { + 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 + "getCameraSupportDevicesArray is: " + mCameraDevicesArray.length); + 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 createInputs() { + console.info('Enter createInputs'); + + if (isEmpty(mCameraDevicesArray)) { + console.info(TAG + "Entering createInputs FAILED with NoCamera"); + return false; + } + + mCameraInputArray = new Array(mCameraDevicesArray.length); + mIsExposureModeSupportedArray = new Array(mCameraDevicesArray.length); + mExposureBiasRangeArray = new Array(mCameraDevicesArray.length); + mExposureBiasMaxArray = new Array(mCameraDevicesArray.length); + mExposureBiasMinArray = new Array(mCameraDevicesArray.length); + + for (let i = 0; i < mCameraDevicesArray.length; i++) { + mCameraInputArray[i] = await mCameraManager.createCameraInput(mCameraDevicesArray[i]); + if (isEmpty(mCameraInputArray[i])) { + console.info(TAG + "createCameraInput FAILED"); + return false; + } + + mCameraInputArray[i].open(async (err) => { + console.info(TAG + "Entering mCameraInputArray open callback"); + if (!err) { + console.info(TAG + "Entering mCameraInputArray open PASSED "); + } else { + console.info(TAG + "Entering mCameraInputArray open FAILED : " + err.message); + } + }) + + await sleep(2000); + + console.info(i + 'th CameraInput is: ' + mCameraInputArray[i]); + } + + console.info('Exit createInputs'); + + return true; + } + + async function releaseInputs() { + console.info('Enter releaseInputs'); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering releaseInputs FAILED with NoCamera"); + return true; + } + + for (let i = 0; i < mCameraInputArray.length; i++) { + await mCameraInputArray[i].close(); + await mCameraInputArray[i].release(); + } + + console.info('Exit releaseInputs'); + + return true; + } + + async function createOutputs() { + console.info('Enter createOutputs'); + + mPreviewOutputArray = new Array(mCameraDevicesArray.length); + mPhotoOutputArray = new Array(mCameraDevicesArray.length); + mVideoOutputArray = new Array(mCameraDevicesArray.length); + + for (let i = 0; i < mCameraDevicesArray.length; i++) { + let cameraOutputCap = await mCameraManager.getSupportedOutputCapability(mCameraDevicesArray[i]); + if (!isEmpty(cameraOutputCap.previewProfiles)) { + console.info(TAG + "cameraOutputCap.previewProfiles.length: " + cameraOutputCap.previewProfiles.length); + for (let j = 0; j < cameraOutputCap.previewProfiles.length; j++) { + mPreviewOutputArray[i] = await mCameraManager.createPreviewOutput(cameraOutputCap.previewProfiles[j], surfaceId); + if (!isEmpty(mPreviewOutputArray[i])) { + break; + } + } + + if (isEmpty(mPreviewOutputArray[i])) { + console.info(TAG + "createPreviewOutput FAILED"); + } + } + + /* + if (!isEmpty(cameraOutputCap.photoProfiles)) { + console.info(TAG + "cameraOutputCap.photoProfiles.length: " + cameraOutputCap.photoProfiles.length); + + for (let j = 0; j < cameraOutputCap.photoProfiles.length; j++) { + mPhotoOutputArray[i] = await mCameraManager.createPhotoOutput(cameraOutputCap.photoProfiles[j], mPhoteSurface); + if (!isEmpty(mPhotoOutputArray[i])) { + break; + } + } + + if (isEmpty(mPhotoOutputArray[i])) { + console.info(TAG + "createPhotoOutput FAILED"); + } + + console.info(TAG + "createPhotoOutput: " + mPhotoOutputArray[i]); + } + + if (!isEmpty(cameraOutputCap.videoProfiles)) { + console.info(TAG + "cameraOutputCap.videoProfiles.length: " + cameraOutputCap.videoProfiles.length); + for (let j = 0; j < cameraOutputCap.videoProfiles.length; j++) { + mVideoOutputArray[i] = await mCameraManager.createVideoOutput(cameraOutputCap.videoProfiles[j], mVideoSurface); + if (!isEmpty(mVideoOutputArray[i])) { + break; + } + } + + if (isEmpty(mVideoOutputArray[i])) { + console.info(TAG + "createVideoOutput FAILED"); + } + + console.info(TAG + "createVideoOutput: " + mPhotoOutputArray[i]); + } + */ + } + + console.info('Exit createOutputs'); + + return true; + } + + async function releaseOutputs() { + for (let i = 0; i < mCameraDevicesArray.length; i++) { + if (!isEmpty(mPreviewOutputArray[i])) { + await mPreviewOutputArray[i].close(); + await mPreviewOutputArray[i].release(); + } + + /* + if (!isEmpty(mPhotoOutputArray[i])) { + await mPhotoOutputArray[i].close(); + await mPhotoOutputArray[i].release(); + } + + if (!isEmpty(mVideoOutputArray[i])) { + await mVideoOutputArray[i].close(); + await mVideoOutputArray[i].release(); + } + */ + } + + return true; + } + + async function startCameraSession(idx:any) { + console.info(TAG + "Enter startCameraSession"); + + if (!isEmpty(mCameraInputArray[idx])) { + console.info(TAG + "Start to addInput"); + await mCameraSession.addInput(mCameraInputArray[idx]); + } + + if (!isEmpty(mPreviewOutputArray[idx])) { + console.info(TAG + "Start to addOutput mPreviewOutput"); + await mCameraSession.addOutput(mPreviewOutputArray[idx]); + } + + /* + if (!isEmpty(mPhotoOutputArray[idx])) { + console.info(TAG + "Start to addOutput mPhotoOutput"); + await mCameraSession.addOutput(mPhotoOutputArray[idx]); + } + + if (!isEmpty(mVideoOutputArray[idx])) { + console.info(TAG + "Start to addOutput mVideoOutput"); + await mCameraSession.addOutput(mVideoOutputArray[idx]); + } + */ + + await commitCameraSessionConfig(); + await beginCameraSessionConfig(); + + /* + await mCameraSession.start(async (err) => { + console.info(TAG + "Entering mCameraSession start callback"); + if (!err) { + console.info(TAG + "Entering mCameraSession start PASSED "); + } else { + console.info(TAG + "Entering mCameraSession start FAILED : " + err.message); + } + }) + + await sleep(1000); + */ + console.info(TAG + "Exit startCameraSession"); + + return true; + } + + async function stopCameraSession(idx:any) { + console.info(TAG + "Enter stopCameraSession"); + /* + mCameraSession.stop(async (err) => { + console.info(TAG + "Entering mCameraSession stop callback"); + if (!err) { + console.info(TAG + "Entering mCameraSession stop PASSED "); + } else { + console.info(TAG + "Entering mCameraSession stop FAILED : " + err.message); + } + }) + + await sleep(1000); + */ + + if (!isEmpty(mCameraInputArray[idx])) { + console.info(TAG + "Start to removeInput input"); + await mCameraSession.removeInput(mCameraInputArray[idx]); + } + + if (!isEmpty(mPreviewOutputArray[idx])) { + console.info(TAG + "Start to removeOutput mPreviewOutput"); + await mCameraSession.removeOutput(mPreviewOutputArray[idx]); + } + + /* + if (!isEmpty(mPhotoOutputArray[idx])) { + console.info(TAG + "Start to removeOutput mPhotoOutput"); + await mCameraSession.removeOutput(mPhotoOutputArray[idx]); + } + + if (!isEmpty(mVideoOutputArray[idx])) { + console.info(TAG + "Start to removeOutput mVideoOutput"); + await mCameraSession.removeOutput(mVideoOutputArray[idx]); + } + */ + + console.info(TAG + "Exit stopCameraSession"); + + return true; + } + + describe('cameraSessionExposureTest', function () { + console.info(TAG + '----------cameraSessionExposureTest--------------') + + beforeAll(async function () { + sleep(100); + await applyPermission(); + await getPhotoReceiverSurface(); + await getVideoReceiveSurface(); + await getCameraManagerInstance(); + await getCameraSupportDevicesArray(); + await createCameraSessionInstance(); + await createInputs(); + await createOutputs(); + + console.info('Device type = ' + deviceInfo.deviceType); + + console.info('beforeAll case'); + }) + + beforeEach(function () { + sleep(1000); + console.info('beforeEach case'); + }) + + afterEach(async function () { + console.info('afterEach case'); + }) + + afterAll(function () { + releaseInputs(); + releaseOutputs(); + releaseVideoReceiveSurface(); + releaseCameraSessionInstance(); + sleep(1000); + console.info('afterAll case'); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_CALLBACK_0100 + * @tc.name : Check capture session support exposure locked mode with callback or not + * @tc.desc : Check capture session support exposure locked mode with callback or not + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_CALLBACK_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_CALLBACK_0100--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_CALLBACK_0100 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_CALLBACK_0100 start for camera[" + i + "]"); + + await startCameraSession(i); + + mIsExposureModeSupportedArray[i] = false; + + mCameraSession.isExposureModeSupported(cameraObj.ExposureMode.EXPOSURE_MODE_LOCKED, async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_CALLBACK_0100 callback"); + if (!err) { + if (data != null || data != undefined) { + mIsExposureModeSupportedArray[i] = data; + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_CALLBACK_0100 PASSED with isExposureModeSupported is: " + data); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_CALLBACK_0100 FAILED with isExposureModeSupported is: " + data); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_CALLBACK_0100 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(1000); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_CALLBACK_0100 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_CALLBACK_0100 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_PROMISE_0100 + * @tc.name : Check capture session support exposure locked mode with promise or not + * @tc.desc : Check capture session support exposure locked mode with promise or not + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_PROMISE_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_PROMISE_0100--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_PROMISE_0100 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_PROMISE_0100 start for camera[" + i + "]"); + + await startCameraSession(i); + + let isExposureModeSupported = await mCameraSession.isExposureModeSupported(cameraObj.ExposureMode.EXPOSURE_MODE_LOCKED); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_PROMISE_0100 finish"); + if (isExposureModeSupported != null || isExposureModeSupported != undefined) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_PROMISE_0100 PASSED with isExposureModeSupported is: " + isExposureModeSupported); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_PROMISE_0100 FAILED with isExposureModeSupported is: " + isExposureModeSupported); + expect().assertFail(); + } + + await sleep(1000); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_PROMISE_0100 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_PROMISE_0100 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_CALLBACK_0100 + * @tc.name : Check capture session set exposure locked mode with callback + * @tc.desc : Check capture session set exposure locked mode with callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_CALLBACK_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_CALLBACK_0100--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_CALLBACK_0100 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_CALLBACK_0100 start for camera[" + i + "]"); + + await startCameraSession(i); + + if (mIsExposureModeSupportedArray[i] == true) { + mCameraSession.setExposureMode(cameraObj.ExposureMode.EXPOSURE_MODE_LOCKED, async (err) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_CALLBACK_0100 callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_CALLBACK_0100 PASSED with ExposureMode is: " + cameraObj.ExposureMode.EXPOSURE_MODE_LOCKED); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_CALLBACK_0100 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + mCameraSession.getExposureMode(async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_CALLBACK_0100 callback"); + if (!err) { + if (data == cameraObj.ExposureMode.EXPOSURE_MODE_LOCKED) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_CALLBACK_0100 PASSED with ExposureMode is: " + data); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_CALLBACK_0100 FAILED with ExposureMode is: " + data); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_CALLBACK_0100 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_CALLBACK_0100 not support"); + } + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_CALLBACK_0100 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_CALLBACK_0100 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_PROMISE_0100 + * @tc.name : Check capture session set exposure locked mode with promise + * @tc.desc : Check capture session set exposure locked mode with promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_PROMISE_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_PROMISE_0100--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_PROMISE_0100 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_PROMISE_0100 start for camera[" + i + "]"); + + await startCameraSession(i); + + if (mIsExposureModeSupportedArray[i] == true) { + await mCameraSession.setExposureMode(cameraObj.ExposureMode.EXPOSURE_MODE_LOCKED); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_PROMISE_0100 finish"); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_PROMISE_0100 PASSED with ExposureMode is: " + cameraObj.ExposureMode.EXPOSURE_MODE_LOCKED); + await sleep(500); + + let exposureMode = await mCameraSession.getExposureMode(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_PROMISE_0100 finish"); + if (exposureMode == cameraObj.ExposureMode.EXPOSURE_MODE_LOCKED) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_PROMISE_0100 PASSED with ExposureMode is: " + exposureMode); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_PROMISE_0100 FAILED with ExposureMode is: " + exposureMode); + expect().assertFail(); + } + await sleep(500); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_PROMISE_0100 not support"); + } + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_PROMISE_0100 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_PROMISE_0100 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_CALLBACK_0101 + * @tc.name : Check capture session support exposure auto mode with callback or not + * @tc.desc : Check capture session support exposure auto mode with callback or not + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_CALLBACK_0101', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_CALLBACK_0101--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_CALLBACK_0101 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_CALLBACK_0101 start for camera[" + i + "]"); + + await startCameraSession(i); + + mIsExposureModeSupportedArray[i] = false; + + mCameraSession.isExposureModeSupported(cameraObj.ExposureMode.EXPOSURE_MODE_AUTO, async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_CALLBACK_0101 callback"); + if (!err) { + if (data != null || data != undefined) { + mIsExposureModeSupportedArray[i] = data; + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_CALLBACK_0101 PASSED with isExposureModeSupported is: " + data); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_CALLBACK_0101 FAILED with isExposureModeSupported is: " + data); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_CALLBACK_0101 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(1000); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_CALLBACK_0101 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_CALLBACK_0101 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_PROMISE_0101 + * @tc.name : Check capture session support exposure auto mode with promise or not + * @tc.desc : Check capture session support exposure auto mode with promise or not + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_PROMISE_0101', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_PROMISE_0101--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_PROMISE_0101 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_PROMISE_0101 start for camera[" + i + "]"); + + await startCameraSession(i); + + let isExposureModeSupported = await mCameraSession.isExposureModeSupported(cameraObj.ExposureMode.EXPOSURE_MODE_AUTO); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_PROMISE_0101 finish"); + if (isExposureModeSupported != null || isExposureModeSupported != undefined) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_PROMISE_0101 PASSED with isExposureModeSupported is: " + isExposureModeSupported); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_PROMISE_0101 FAILED with isExposureModeSupported is: " + isExposureModeSupported); + expect().assertFail(); + } + + await sleep(1000); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_PROMISE_0101 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_PROMISE_0101 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_CALLBACK_0101 + * @tc.name : Check capture session set exposure auto mode with callback + * @tc.desc : Check capture session set exposure auto mode with callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_CALLBACK_0101', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_CALLBACK_0101--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_CALLBACK_0101 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_CALLBACK_0101 start for camera[" + i + "]"); + + await startCameraSession(i); + + if (mIsExposureModeSupportedArray[i] == true) { + mCameraSession.setExposureMode(cameraObj.ExposureMode.EXPOSURE_MODE_AUTO, async (err) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_CALLBACK_0101 callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_CALLBACK_0101 PASSED with ExposureMode is: " + cameraObj.ExposureMode.EXPOSURE_MODE_AUTO); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_CALLBACK_0101 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + mCameraSession.getExposureMode(async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_CALLBACK_0101 callback"); + if (!err) { + if (data == cameraObj.ExposureMode.EXPOSURE_MODE_AUTO) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_CALLBACK_0101 PASSED with ExposureMode is: " + data); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_CALLBACK_0101 FAILED with ExposureMode is: " + data); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_CALLBACK_0101 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_CALLBACK_0101 not support"); + } + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_CALLBACK_0101 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_CALLBACK_0101 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_PROMISE_0101 + * @tc.name : Check capture session set exposure auto mode with promise + * @tc.desc : Check capture session set exposure auto mode with promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_PROMISE_0101', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_PROMISE_0101--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_PROMISE_0101 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_PROMISE_0101 start for camera[" + i + "]"); + + await startCameraSession(i); + + if (mIsExposureModeSupportedArray[i] == true) { + await mCameraSession.setExposureMode(cameraObj.ExposureMode.EXPOSURE_MODE_AUTO); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_PROMISE_0101 finish"); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_PROMISE_0101 PASSED with ExposureMode is: " + cameraObj.ExposureMode.EXPOSURE_MODE_AUTO); + await sleep(500); + + let exposureMode = await mCameraSession.getExposureMode(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_PROMISE_0101 finish"); + if (exposureMode == cameraObj.ExposureMode.EXPOSURE_MODE_AUTO) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_PROMISE_0101 PASSED with ExposureMode is: " + exposureMode); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_PROMISE_0101 FAILED with ExposureMode is: " + exposureMode); + expect().assertFail(); + } + await sleep(500); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_PROMISE_0101 not support"); + } + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_PROMISE_0101 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_PROMISE_0101 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_CALLBACK_0102 + * @tc.name : Check capture session support exposure continuous auto mode with callback or not + * @tc.desc : Check capture session support exposure continuous auto mode with callback or not + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_CALLBACK_0102', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_CALLBACK_0102--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_CALLBACK_0102 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_CALLBACK_0102 start for camera[" + i + "]"); + + await startCameraSession(i); + + mIsExposureModeSupportedArray[i] = false; + + mCameraSession.isExposureModeSupported(cameraObj.ExposureMode.EXPOSURE_MODE_CONTINUOUS_AUTO, async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_CALLBACK_0102 callback"); + if (!err) { + if (data != null || data != undefined) { + mIsExposureModeSupportedArray[i] = data; + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_CALLBACK_0102 PASSED with isExposureModeSupported is: " + data); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_CALLBACK_0102 FAILED with isExposureModeSupported is: " + data); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_CALLBACK_0102 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(1000); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_CALLBACK_0102 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_CALLBACK_0102 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_PROMISE_0102 + * @tc.name : Check capture session support exposure continuous auto mode with promise or not + * @tc.desc : Check capture session support exposure continuous auto mode with promise or not + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_PROMISE_0101', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_PROMISE_0102--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_PROMISE_0101 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_PROMISE_0102 start for camera[" + i + "]"); + + await startCameraSession(i); + + let isExposureModeSupported = await mCameraSession.isExposureModeSupported(cameraObj.ExposureMode.EXPOSURE_MODE_CONTINUOUS_AUTO); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_PROMISE_0102 finish"); + if (isExposureModeSupported != null || isExposureModeSupported != undefined) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_PROMISE_0102 PASSED with isExposureModeSupported is: " + isExposureModeSupported); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_PROMISE_0102 FAILED with isExposureModeSupported is: " + isExposureModeSupported); + expect().assertFail(); + } + + await sleep(1000); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_PROMISE_0102 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_PROMISE_0102 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_CALLBACK_0102 + * @tc.name : Check capture session set exposure continuous auto mode with callback + * @tc.desc : Check capture session set exposure continuous auto mode with callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_CALLBACK_0102', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_CALLBACK_0102--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_CALLBACK_0102 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_CALLBACK_0102 start for camera[" + i + "]"); + + await startCameraSession(i); + + if (mIsExposureModeSupportedArray[i] == true) { + mCameraSession.setExposureMode(cameraObj.ExposureMode.EXPOSURE_MODE_CONTINUOUS_AUTO, async (err) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_CALLBACK_0102 callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_CALLBACK_0102 PASSED with ExposureMode is: " + cameraObj.ExposureMode.EXPOSURE_MODE_CONTINUOUS_AUTO); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_CALLBACK_0102 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + mCameraSession.getExposureMode(async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_CALLBACK_0102 callback"); + if (!err) { + if (data == cameraObj.ExposureMode.EXPOSURE_MODE_CONTINUOUS_AUTO) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_CALLBACK_0102 PASSED with ExposureMode is: " + data); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_CALLBACK_0102 FAILED with ExposureMode is: " + data); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_CALLBACK_0102 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_CALLBACK_0102 not support"); + } + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_CALLBACK_0102 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_CALLBACK_0102 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_PROMISE_0102 + * @tc.name : Check capture session set exposure continuous auto mode with promise + * @tc.desc : Check capture session set exposure continuous auto mode with promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_PROMISE_0102', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_PROMISE_0102--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_PROMISE_0102 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_PROMISE_0102 start for camera[" + i + "]"); + + await startCameraSession(i); + + if (mIsExposureModeSupportedArray[i] == true) { + await mCameraSession.setExposureMode(cameraObj.ExposureMode.EXPOSURE_MODE_CONTINUOUS_AUTO); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_PROMISE_0102 finish"); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_PROMISE_0102 PASSED with ExposureMode is: " + cameraObj.ExposureMode.EXPOSURE_MODE_CONTINUOUS_AUTO); + await sleep(500); + + let exposureMode = await mCameraSession.getExposureMode(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_PROMISE_0102 finish"); + if (exposureMode == cameraObj.ExposureMode.EXPOSURE_MODE_CONTINUOUS_AUTO) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_PROMISE_0102 PASSED with ExposureMode is: " + exposureMode); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_PROMISE_0102 FAILED with ExposureMode is: " + exposureMode); + expect().assertFail(); + } + await sleep(500); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_PROMISE_0102 not support"); + } + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_PROMISE_0102 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_PROMISE_0102 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0100 + * @tc.name : Check capture session set METERING point with callback + * @tc.desc : Check capture session set METERING point with callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0100--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0100 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0100 start for camera[" + i + "]"); + + await startCameraSession(i); + + mCameraSession.setMeteringPoint(mMETERINGPoint, async (err) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0100 callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0100 PASSED with METERINGPoint is: " + mMETERINGPoint.x + ", " + mMETERINGPoint.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0100 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + mCameraSession.getMeteringPoint(async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0100 callback"); + if (!err) { + if ((data.x == mMETERINGPoint.x) && (data.y == mMETERINGPoint.y)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0100 PASSED with METERINGPoint is: " + data.x + ", " + data.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0100 FAILED with METERINGPoint is: " + data.x + ", " + data.y); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0100 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0100 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0100 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0100 + * @tc.name : Check capture session set METERING point with promise + * @tc.desc : Check capture session set METERING point with promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0100--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0100 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0100 start for camera[" + i + "]"); + + await startCameraSession(i); + + await mCameraSession.setMeteringPoint(mMETERINGPoint); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0100 finish"); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0100 PASSED with METERINGPoint is: " + mMETERINGPoint.x + ", " + mMETERINGPoint.y); + await sleep(500); + + let METERINGPoint = await mCameraSession.getMeteringPoint(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0100 finish"); + if ((METERINGPoint.x == mMETERINGPoint.x) && (METERINGPoint.y == mMETERINGPoint.y)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0100 PASSED with METERINGPoint is: " + METERINGPoint.x + ", " + METERINGPoint.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0100 FAILED with METERINGPoint is: " + METERINGPoint.x + ", " + METERINGPoint.y); + expect().assertFail(); + } + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0100 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0100 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0101 + * @tc.name : Check capture session set METERING point with callback(left-top point) + * @tc.desc : Check capture session set METERING point with callback(left-top point) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0101', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0101--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0101 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0101 start for camera[" + i + "]"); + + await startCameraSession(i); + + mCameraSession.setMeteringPoint(mMETERINGPointLT, async (err) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0101 callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0101 PASSED with METERINGPoint is: " + mMETERINGPointLT.x + ", " + mMETERINGPointLT.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0101 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + mCameraSession.getMeteringPoint(async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0101 callback"); + if (!err) { + if ((data.x == mMETERINGPointLT.x) && (data.y == mMETERINGPointLT.y)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0101 PASSED with METERINGPoint is: " + data.x + ", " + data.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0101 FAILED with METERINGPoint is: " + data.x + ", " + data.y); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0101 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0101 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0101 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0101 + * @tc.name : Check capture session set METERING point with promise(left-top point) + * @tc.desc : Check capture session set METERING point with promise(left-top point) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0101', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0101--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0101 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0101 start for camera[" + i + "]"); + + await startCameraSession(i); + + await mCameraSession.setMeteringPoint(mMETERINGPointLT); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0101 finish"); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0101 PASSED with METERINGPoint is: " + mMETERINGPointLT.x + ", " + mMETERINGPointLT.y); + await sleep(500); + + let METERINGPoint = await mCameraSession.getMeteringPoint(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0101 finish"); + if ((METERINGPoint.x == mMETERINGPointLT.x) && (METERINGPoint.y == mMETERINGPointLT.y)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0101 PASSED with METERINGPoint is: " + METERINGPoint.x + ", " + METERINGPoint.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0101 FAILED with METERINGPoint is: " + METERINGPoint.x + ", " + METERINGPoint.y); + expect().assertFail(); + } + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0101 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0101 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0102 + * @tc.name : Check capture session set METERING point with callback(right-top point) + * @tc.desc : Check capture session set METERING point with callback(right-top point) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0102', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0102--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0102 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0102 start for camera[" + i + "]"); + + await startCameraSession(i); + + mCameraSession.setMeteringPoint(mMETERINGPointRT, async (err) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0102 callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0102 PASSED with METERINGPoint is: " + mMETERINGPointRT.x + ", " + mMETERINGPointRT.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0102 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + mCameraSession.getMeteringPoint(async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0102 callback"); + if (!err) { + if ((data.x == mMETERINGPointRT.x) && (data.y == mMETERINGPointRT.y)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0102 PASSED with METERINGPoint is: " + data.x + ", " + data.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0102 FAILED with METERINGPoint is: " + data.x + ", " + data.y); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0102 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0102 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0102 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0102 + * @tc.name : Check capture session set METERING point with promise(right-top point) + * @tc.desc : Check capture session set METERING point with promise(right-top point) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0102', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0102--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0102 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0102 start for camera[" + i + "]"); + + await startCameraSession(i); + + await mCameraSession.setMeteringPoint(mMETERINGPointRT); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0102 finish"); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0102 PASSED with METERINGPoint is: " + mMETERINGPointRT.x + ", " + mMETERINGPointRT.y); + await sleep(500); + + let METERINGPoint = await mCameraSession.getMeteringPoint(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0102 finish"); + if ((METERINGPoint.x == mMETERINGPointRT.x) && (METERINGPoint.y == mMETERINGPointRT.y)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0102 PASSED with METERINGPoint is: " + METERINGPoint.x + ", " + METERINGPoint.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0102 FAILED with METERINGPoint is: " + METERINGPoint.x + ", " + METERINGPoint.y); + expect().assertFail(); + } + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0102 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0102 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0103 + * @tc.name : Check capture session set METERING point with callback(left-bottom point) + * @tc.desc : Check capture session set METERING point with callback(left-bottom point) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0103', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0103--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0103 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0103 start for camera[" + i + "]"); + + await startCameraSession(i); + + mCameraSession.setMeteringPoint(mMETERINGPointLB, async (err) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0103 callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0103 PASSED with METERINGPoint is: " + mMETERINGPointLB.x + ", " + mMETERINGPointRB.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0103 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + mCameraSession.getMeteringPoint(async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0103 callback"); + if (!err) { + if ((data.x == mMETERINGPointLB.x) && (data.y == mMETERINGPointLB.y)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0103 PASSED with METERINGPoint is: " + data.x + ", " + data.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0103 FAILED with METERINGPoint is: " + data.x + ", " + data.y); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0103 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0103 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0103 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0103 + * @tc.name : Check capture session set METERING point with promise(left-bottom point) + * @tc.desc : Check capture session set METERING point with promise(left-bottom point) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0103', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0103--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0103 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0103 start for camera[" + i + "]"); + + await startCameraSession(i); + + await mCameraSession.setMeteringPoint(mMETERINGPointLB); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0103 finish"); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0103 PASSED with METERINGPoint is: " + mMETERINGPointLB.x + ", " + mMETERINGPointRB.y); + await sleep(500); + + let METERINGPoint = await mCameraSession.getMeteringPoint(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0103 finish"); + if ((METERINGPoint.x == mMETERINGPointLB.x) && (METERINGPoint.y == mMETERINGPointLB.y)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0103 PASSED with METERINGPoint is: " + METERINGPoint.x + ", " + METERINGPoint.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0103 FAILED with METERINGPoint is: " + METERINGPoint.x + ", " + METERINGPoint.y); + expect().assertFail(); + } + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0103 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0103 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0104 + * @tc.name : Check capture session set METERING point with callback(right-bottom point) + * @tc.desc : Check capture session set METERING point with callback(right-bottom point) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0104', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0104--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0104 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0104 start for camera[" + i + "]"); + + await startCameraSession(i); + + mCameraSession.setMeteringPoint(mMETERINGPointRB, async (err) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0104 callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0104 PASSED with METERINGPoint is: " + mMETERINGPointRB.x + ", " + mMETERINGPointRB.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0104 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + mCameraSession.getMeteringPoint(async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0104 callback"); + if (!err) { + if ((data.x == mMETERINGPointRB.x) && (data.y == mMETERINGPointRB.y)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0104 PASSED with METERINGPoint is: " + data.x + ", " + data.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0104 FAILED with METERINGPoint is: " + data.x + ", " + data.y); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0104 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0104 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0104 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0104 + * @tc.name : Check capture session set METERING point with promise(right-bottom point) + * @tc.desc : Check capture session set METERING point with promise(right-bottom point) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0104', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0104--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0104 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0104 start for camera[" + i + "]"); + + await startCameraSession(i); + + await mCameraSession.setMeteringPoint(mMETERINGPointRB); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0104 finish"); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0104 PASSED with METERINGPoint is: " + mMETERINGPointRB.x + ", " + mMETERINGPointRB.y); + await sleep(500); + + let METERINGPoint = await mCameraSession.getMeteringPoint(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0104 finish"); + if ((METERINGPoint.x == mMETERINGPointRB.x) && (METERINGPoint.y == mMETERINGPointRB.y)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0104 PASSED with METERINGPoint is: " + METERINGPoint.x + ", " + METERINGPoint.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0104 FAILED with METERINGPoint is: " + METERINGPoint.x + ", " + METERINGPoint.y); + expect().assertFail(); + } + + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0104 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0104 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0105 + * @tc.name : Check capture session set METERING point with callback(left-top invalid point) + * @tc.desc : Check capture session set METERING point with callback(left-top invalid point) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0105', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0105--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0105 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0105 start for camera[" + i + "]"); + + await startCameraSession(i); + + mCameraSession.setMeteringPoint(mMETERINGPointInvalidLT, async (err) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0105 callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0105 PASSED with METERINGPoint is: " + mMETERINGPointInvalidLT.x + ", " + mMETERINGPointInvalidLT.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0105 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + mCameraSession.getMeteringPoint(async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0105 callback"); + if (!err) { + if (((data.x != mMETERINGPointInvalidLT.x) && (data.y != mMETERINGPointInvalidLT.y)) || (mEnableCheckInvalidMETERINGPoint == false)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0105 PASSED with METERINGPoint is: " + data.x + ", " + data.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0105 FAILED with METERINGPoint is: " + data.x + ", " + data.y); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0105 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0105 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0105 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0105 + * @tc.name : Check capture session set METERING point with promise(left-top invalid point) + * @tc.desc : Check capture session set METERING point with promise(left-top invalid point) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0105', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0105--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0105 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0105 start for camera[" + i + "]"); + + await startCameraSession(i); + + await mCameraSession.setMeteringPoint(mMETERINGPointInvalidLT); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0105 finish"); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0105 PASSED with METERINGPoint is: " + mMETERINGPointInvalidLT.x + ", " + mMETERINGPointInvalidLT.y); + await sleep(500); + + let METERINGPoint = await mCameraSession.getMeteringPoint(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0105 finish"); + if (((METERINGPoint.x != mMETERINGPointInvalidLT.x) && (METERINGPoint.y != mMETERINGPointInvalidLT.y)) || (mEnableCheckInvalidMETERINGPoint == false)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0105 PASSED with METERINGPoint is: " + METERINGPoint.x + ", " + METERINGPoint.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0105 FAILED with METERINGPoint is: " + METERINGPoint.x + ", " + METERINGPoint.y); + expect().assertFail(); + } + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0105 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0105 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0106 + * @tc.name : Check capture session set METERING point with callback(right-top invalid point) + * @tc.desc : Check capture session set METERING point with callback(right-top invalid point) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0106', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0106--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0106 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0106 start for camera[" + i + "]"); + + await startCameraSession(i); + + mCameraSession.setMeteringPoint(mMETERINGPointInvalidRT, async (err) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0106 callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0106 PASSED with METERINGPoint is: " + mMETERINGPointInvalidRT.x + ", " + mMETERINGPointInvalidRT.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0106 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + mCameraSession.getMeteringPoint(async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0106 callback"); + if (!err) { + if (((data.x != mMETERINGPointInvalidRT.x) && (data.y != mMETERINGPointInvalidRT.y)) || (mEnableCheckInvalidMETERINGPoint == false)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0106 PASSED with METERINGPoint is: " + data.x + ", " + data.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0106 FAILED with METERINGPoint is: " + data.x + ", " + data.y); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0106 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0106 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0106 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0106 + * @tc.name : Check capture session set METERING point with promise(right-top invalid point) + * @tc.desc : Check capture session set METERING point with promise(right-top invalid point) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0106', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0106--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0106 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0106 start for camera[" + i + "]"); + + await startCameraSession(i); + + await mCameraSession.setMeteringPoint(mMETERINGPointInvalidRT); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0106 finish"); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0106 PASSED with METERINGPoint is: " + mMETERINGPointInvalidRT.x + ", " + mMETERINGPointInvalidRT.y); + await sleep(500); + + let METERINGPoint = await mCameraSession.getMeteringPoint(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0106 finish"); + if (((METERINGPoint.x != mMETERINGPointInvalidRT.x) && (METERINGPoint.y != mMETERINGPointInvalidRT.y)) || (mEnableCheckInvalidMETERINGPoint == false)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0106 PASSED with METERINGPoint is: " + METERINGPoint.x + ", " + METERINGPoint.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0106 FAILED with METERINGPoint is: " + METERINGPoint.x + ", " + METERINGPoint.y); + expect().assertFail(); + } + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0106 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0106 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0107 + * @tc.name : Check capture session set METERING point with callback(left-bottom invalid point) + * @tc.desc : Check capture session set METERING point with callback(left-bottom invalid point) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0107', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0107--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0107 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0107 start for camera[" + i + "]"); + + await startCameraSession(i); + + mCameraSession.setMeteringPoint(mMETERINGPointInvalidLB, async (err) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0107 callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0107 PASSED with METERINGPoint is: " + mMETERINGPointInvalidLB.x + ", " + mMETERINGPointInvalidRB.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0107 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + mCameraSession.getMeteringPoint(async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0107 callback"); + if (!err) { + if (((data.x != mMETERINGPointInvalidLB.x) && (data.y != mMETERINGPointInvalidLB.y)) || (mEnableCheckInvalidMETERINGPoint == false)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0107 PASSED with METERINGPoint is: " + data.x + ", " + data.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0107 FAILED with METERINGPoint is: " + data.x + ", " + data.y); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0107 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0107 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0107 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0107 + * @tc.name : Check capture session set METERING point with promise(left-bottom invalid point) + * @tc.desc : Check capture session set METERING point with promise(left-bottom invalid point) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0107', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0107--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0107 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0107 start for camera[" + i + "]"); + + await startCameraSession(i); + + await mCameraSession.setMeteringPoint(mMETERINGPointInvalidLB); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0107 finish"); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0107 PASSED with METERINGPoint is: " + mMETERINGPointInvalidLB.x + ", " + mMETERINGPointInvalidRB.y); + await sleep(500); + + let METERINGPoint = await mCameraSession.getMeteringPoint(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0107 finish"); + if (((METERINGPoint.x != mMETERINGPointInvalidLB.x) && (METERINGPoint.y != mMETERINGPointInvalidLB.y)) || (mEnableCheckInvalidMETERINGPoint == false)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0107 PASSED with METERINGPoint is: " + METERINGPoint.x + ", " + METERINGPoint.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0107 FAILED with METERINGPoint is: " + METERINGPoint.x + ", " + METERINGPoint.y); + expect().assertFail(); + } + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0107 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0107 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0108 + * @tc.name : Check capture session set METERING point with callback(right-bottom invalid point) + * @tc.desc : Check capture session set METERING point with callback(right-bottom invalid point) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0108', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0108--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0108 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0108 start for camera[" + i + "]"); + + await startCameraSession(i); + + mCameraSession.setMeteringPoint(mMETERINGPointInvalidRB, async (err) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0108 callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0108 PASSED with METERINGPoint is: " + mMETERINGPointInvalidRB.x + ", " + mMETERINGPointInvalidRB.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0108 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + mCameraSession.getMeteringPoint(async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0108 callback"); + if (!err) { + if (((data.x != mMETERINGPointInvalidRB.x) && (data.y != mMETERINGPointInvalidRB.y)) || (mEnableCheckInvalidMETERINGPoint == false)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0108 PASSED with METERINGPoint is: " + data.x + ", " + data.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0108 FAILED with METERINGPoint is: " + data.x + ", " + data.y); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0108 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0108 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_CALLBACK_0108 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0108 + * @tc.name : Check capture session set METERING point with promise(right-bottom invalid point) + * @tc.desc : Check capture session set METERING point with promise(right-bottom invalid point) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0108', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0108--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0108 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0108 start for camera[" + i + "]"); + + await startCameraSession(i); + + await mCameraSession.setMeteringPoint(mMETERINGPointInvalidRB); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0108 finish"); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0108 PASSED with METERINGPoint is: " + mMETERINGPointInvalidRB.x + ", " + mMETERINGPointInvalidRB.y); + await sleep(500); + + let METERINGPoint = await mCameraSession.getMeteringPoint(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0108 finish"); + if (((METERINGPoint.x != mMETERINGPointInvalidRB.x) && (METERINGPoint.y != mMETERINGPointInvalidRB.y)) || (mEnableCheckInvalidMETERINGPoint == false)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0108 PASSED with METERINGPoint is: " + METERINGPoint.x + ", " + METERINGPoint.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0108 FAILED with METERINGPoint is: " + METERINGPoint.x + ", " + METERINGPoint.y); + expect().assertFail(); + } + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0108 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0108 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_GET_EXPOSURE_BIAS_RANGE_CALLBACK_0100 + * @tc.name : Check capture session get exposure bias range with callback + * @tc.desc : Check capture session get exposure bias range with callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_GET_EXPOSURE_BIAS_RANGE_CALLBACK_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_GET_EXPOSURE_BIAS_RANGE_CALLBACK_0100--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_GET_EXPOSURE_BIAS_RANGE_CALLBACK_0100 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_GET_EXPOSURE_BIAS_RANGE_CALLBACK_0100 start for camera[" + i + "]"); + + await startCameraSession(i); + + mCameraSession.getExposureBiasRange(async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_GET_EXPOSURE_BIAS_RANGE_CALLBACK_0100 callback"); + if (!err) { + if (data.length > 0) { + mExposureBiasRangeArray[i] = data; + console.info(TAG + i + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_GET_EXPOSURE_BIAS_RANGE_CALLBACK_0100 PASSED with ExposureBiasRange length is: " + data.length); + for (let j = 0; j < mExposureBiasRangeArray[i].length; j++) { + console.info(TAG + j + "th, exposure bias is: " + data[j] + ", " + mExposureBiasRangeArray[i][j]); + + if ((mExposureBiasMaxArray[i] == undefined) || (mExposureBiasMaxArray[i] < mExposureBiasRangeArray[i][j])) { + mExposureBiasMaxArray[i] = mExposureBiasRangeArray[i][j] + } + + if ((mExposureBiasMinArray[i] == undefined) || (mExposureBiasMinArray[i] > mExposureBiasRangeArray[i][j])) { + mExposureBiasMinArray[i] = mExposureBiasRangeArray[i][j] + } + } + + console.info(TAG + "Exposure bias max is: " + mExposureBiasMaxArray[i] + ", min is: " + mExposureBiasMinArray[i]); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_GET_EXPOSURE_BIAS_RANGE_CALLBACK_0100 FAILED with ExposureBiasRange length is: " + data.length); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_GET_EXPOSURE_BIAS_RANGE_CALLBACK_0100 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_GET_EXPOSURE_BIAS_RANGE_CALLBACK_0100 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_GET_EXPOSURE_BIAS_RANGE_CALLBACK_0100 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_GET_EXPOSURE_BIAS_RANGE_PROMISE_0100 + * @tc.name : Check capture session get exposure bias range with promise + * @tc.desc : Check capture session get exposure bias range with promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_GET_EXPOSURE_BIAS_RANGE_PROMISE_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_GET_EXPOSURE_BIAS_RANGE_PROMISE_0100--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_GET_EXPOSURE_BIAS_RANGE_PROMISE_0100 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_GET_EXPOSURE_BIAS_RANGE_PROMISE_0100 start for camera[" + i + "]"); + + await startCameraSession(i); + + let exposureBiasRange = await mCameraSession.getExposureBiasRange(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_GET_EXPOSURE_BIAS_RANGE_PROMISE_0100 finish"); + if (exposureBiasRange.length > 0) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_GET_EXPOSURE_BIAS_RANGE_PROMISE_0100 PASSED with ExposureBiasRange length is: " + exposureBiasRange.length); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_GET_EXPOSURE_BIAS_RANGE_PROMISE_0100 FAILED with ExposureBiasRange length is: " + exposureBiasRange.length); + expect().assertFail(); + } + + for (let j = 0; j < exposureBiasRange.length; j++) { + console.info(TAG + j + "th, exposure bias is: " + exposureBiasRange[j]); + } + + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_GET_EXPOSURE_BIAS_RANGE_PROMISE_0100 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_GET_EXPOSURE_BIAS_RANGE_PROMISE_0100 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0100 + * @tc.name : Check capture session set exposure bias with callback + * @tc.desc : Check capture session set exposure bias with callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0100--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0100 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0100 start for camera[" + i + "]"); + + await startCameraSession(i); + + mCameraSession.setExposureBias(mExposureBiasRangeArray[i][0], async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0100 callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0100 PASSED with ExposureBias is: " + mExposureBiasRangeArray[i][0]); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0100 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + mCameraSession.getExposureValue(async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0100 callback"); + if (!err) { + if (data == mExposureBiasRangeArray[i][0]) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0100 PASSED with ExposureValue is: " + data); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0100 FAILED with ExposureValue is: " + data); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0100 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0100 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0100 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0100 + * @tc.name : Check capture session set exposure bias with promise + * @tc.desc : Check capture session set exposure bias with promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0100--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0100 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0100 start for camera[" + i + "]"); + + await startCameraSession(i); + + await mCameraSession.setExposureBias(mExposureBiasRangeArray[i][0]); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0100 finish"); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0100 PASSED with ExposureBias is: " + mExposureBiasRangeArray[i][0]); + await sleep(500); + + let exposureValue = await mCameraSession.getExposureValue(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0100 finish"); + if (exposureValue == mExposureBiasRangeArray[i][0]) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0100 PASSED with ExposureValue is: " + exposureValue); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0100 FAILED with ExposureValue is: " + exposureValue); + expect().assertFail(); + } + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0100 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0100 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0101 + * @tc.name : Check capture session set exposure bias with callback(invalid value, min - 1) + * @tc.desc : Check capture session set exposure bias with callback(invalid value, min - 1) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0101', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0101--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0101 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0101 start for camera[" + i + "]"); + + await startCameraSession(i); + + mCameraSession.setExposureBias(mExposureBiasMinArray[i] - 1, async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0101 callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0101 PASSED with ExposureBias is: " + (mExposureBiasMinArray[i] - 1)); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0101 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + mCameraSession.getExposureValue(async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0101 callback"); + if (!err) { + if (data != (mExposureBiasMinArray[i] - 1)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0101 PASSED with ExposureValue is: " + data); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0101 FAILED with ExposureValue is: " + data); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0101 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0101 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0101 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0101 + * @tc.name : Check capture session set exposure bias with promise(invalid value, min - 1) + * @tc.desc : Check capture session set exposure bias with promise(invalid value, min - 1) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0101', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0101--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0101 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0101 start for camera[" + i + "]"); + + await startCameraSession(i); + + await mCameraSession.setExposureBias(mExposureBiasMinArray[i] - 1); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0101 finish"); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0101 PASSED with ExposureBias is: " + (mExposureBiasMinArray[i] - 1)); + await sleep(500); + + let exposureValue = await mCameraSession.getExposureValue(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0101 finish"); + if (exposureValue != (mExposureBiasMinArray[i] - 1)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0101 PASSED with ExposureValue is: " + exposureValue); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0101 FAILED with ExposureValue is: " + exposureValue); + expect().assertFail(); + } + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0101 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0101 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0102 + * @tc.name : Check capture session set exposure bias with callback(invalid value, min - 0.1) + * @tc.desc : Check capture session set exposure bias with callback(invalid value, min - 0.1) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0102', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0102--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0102 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0102 start for camera[" + i + "]"); + + await startCameraSession(i); + + mCameraSession.setExposureBias(mExposureBiasMinArray[i] - 0.1, async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0102 callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0102 PASSED with ExposureBias is: " + (mExposureBiasMinArray[i] - 0.1)); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0102 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + mCameraSession.getExposureValue(async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0102 callback"); + if (!err) { + if (data != (mExposureBiasMinArray[i] - 0.1)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0102 PASSED with ExposureValue is: " + data); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0102 FAILED with ExposureValue is: " + data); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0102 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0102 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0102 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0102 + * @tc.name : Check capture session set exposure bias with promise(invalid value, min - 0.1) + * @tc.desc : Check capture session set exposure bias with promise(invalid value, min - 0.1) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0102', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0102--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0102 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0102 start for camera[" + i + "]"); + + await startCameraSession(i); + + await mCameraSession.setExposureBias(mExposureBiasMinArray[i] - 0.1); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0102 finish"); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0102 PASSED with ExposureBias is: " + (mExposureBiasMinArray[i] - 0.1)); + await sleep(500); + + let exposureValue = await mCameraSession.getExposureValue(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0102 finish"); + if (exposureValue != (mExposureBiasMinArray[i] - 0.1)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0102 PASSED with ExposureValue is: " + exposureValue); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0102 FAILED with ExposureValue is: " + exposureValue); + expect().assertFail(); + } + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0102 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0102 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0103 + * @tc.name : Check capture session set exposure bias with callback(invalid value, max + 1) + * @tc.desc : Check capture session set exposure bias with callback(invalid value, max + 1) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0103', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0103--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0103 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0103 start for camera[" + i + "]"); + + await startCameraSession(i); + + mCameraSession.setExposureBias(mExposureBiasMaxArray[i] + 1, async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0103 callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0103 PASSED with ExposureBias is: " + (mExposureBiasMaxArray[i] + 1)); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0103 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + mCameraSession.getExposureValue(async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0103 callback"); + if (!err) { + if (data != (mExposureBiasMaxArray[i] + 1)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0103 PASSED with ExposureValue is: " + data); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0103 FAILED with ExposureValue is: " + data); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0103 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0103 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0103 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0103 + * @tc.name : Check capture session set exposure bias with promise(invalid value, max + 1) + * @tc.desc : Check capture session set exposure bias with promise(invalid value, max + 1) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0103', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0103--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0103 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0103 start for camera[" + i + "]"); + + await startCameraSession(i); + + await mCameraSession.setExposureBias(mExposureBiasMaxArray[i] + 1); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0103 finish"); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0103 PASSED with ExposureBias is: " + (mExposureBiasMaxArray[i] + 1)); + await sleep(500); + + let exposureValue = await mCameraSession.getExposureValue(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0103 finish"); + if (exposureValue != (mExposureBiasMaxArray[i] + 1)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0103 PASSED with ExposureValue is: " + exposureValue); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0103 FAILED with ExposureValue is: " + exposureValue); + expect().assertFail(); + } + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0103 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0103 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0104 + * @tc.name : Check capture session set exposure bias with callback(invalid value, max + 0.1) + * @tc.desc : Check capture session set exposure bias with callback(invalid value, max + 0.1) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0104', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0104--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0104 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0104 start for camera[" + i + "]"); + + await startCameraSession(i); + + mCameraSession.setExposureBias(mExposureBiasMaxArray[i] + 0.1, async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0104 callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0104 PASSED with ExposureBias is: " + (mExposureBiasMaxArray[i] + 0.1)); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0104 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + mCameraSession.getExposureValue(async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0104 callback"); + if (!err) { + if (data != (mExposureBiasMaxArray[i] + 0.1)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0104 PASSED with ExposureValue is: " + data); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0104 FAILED with ExposureValue is: " + data); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0104 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0104 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_CALLBACK_0104 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0104 + * @tc.name : Check capture session set exposure bias with promise(invalid value, max + 0.1) + * @tc.desc : Check capture session set exposure bias with promise(invalid value, max + 0.1) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0104', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0104--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0104 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0104 start for camera[" + i + "]"); + + await startCameraSession(i); + + await mCameraSession.setExposureBias(mExposureBiasMaxArray[i] + 0.1); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0104 finish"); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0104 PASSED with ExposureBias is: " + (mExposureBiasMaxArray[i] + 0.1)); + await sleep(500); + + let exposureValue = await mCameraSession.getExposureValue(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0104 finish"); + if (exposureValue != (mExposureBiasMaxArray[i] + 0.1)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0104 PASSED with ExposureValue is: " + exposureValue); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0104 FAILED with ExposureValue is: " + exposureValue); + expect().assertFail(); + } + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0104 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0104 ends here"); + done(); + } + }) + + }) +} \ No newline at end of file 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 new file mode 100755 index 0000000000000000000000000000000000000000..9017eecb5d3976f81233d952b782e48263818e7a --- /dev/null +++ b/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraSessionFlashTest.test.ets @@ -0,0 +1,1529 @@ +/* + * 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. + */ + +// @ts-ignore + +import cameraObj from '@ohos.multimedia.camera'; +import image from '@ohos.multimedia.image'; +import media from '@ohos.multimedia.media' +import mediaLibrary from '@ohos.multimedia.mediaLibrary' +import fileio from '@ohos.fileio'; +import abilityAccessCtrl from '@ohos.abilityAccessCtrl' +import bundle from '@ohos.bundle' +import deviceInfo from '@ohos.deviceInfo'; +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'; + +const TAG = "CameraModuleTest: "; + +// Define global letiables +let mCameraManager; +let mCameraDevicesArray; +let mCameraSession; + +let mPhoteSurface; +let mVideoRecorder; +let mVideoSurface; +let mFileAsset; +let mFdPath; +let mFdNumber; + +// CAMERA-0 letiables +let mCameraInputArray; +let mPreviewOutputArray; +let mPhotoOutputArray; +let mVideoOutputArray; + +let mHasFlashArray; +let mIsFlashModeSupportedArray; + +let mVideoProfileCfg = { + audioBitrate: 48000, + audioChannels: 2, + audioCodec: 'audio/mp4a-latm', + audioSampleRate: 48000, + durationTime: 1000, + fileFormat: 'mp4', + videoBitrate: 48000, + videoCodec: 'video/mp4v-es', + videoFrameWidth: 640, + videoFrameHeight: 480, + videoFrameRate: 30 +} + +let mVideoConfig = { + audioSourceType: 1, + videoSourceType: 0, + profile: mVideoProfileCfg, + url: 'file:///data/media/CameraSessionFlush.mp4', + orientationHint: 0, + location: { latitude: 30, longitude: 130 }, + maxSize: 100, + maxDuration: 500 +} + +let mPicWidthMax = 8192; +let mPicHeightMax = 8192; + +export default function cameraSessionFlashTest(surfaceId: any) { + + function sleep(ms) { + console.info(TAG + "Entering sleep -> Promise constructor"); + return new Promise(resolve => setTimeout(resolve, ms)); + } + + function isEmpty(data) { + if (data == null || data == undefined) { + return true; + } + return false; + } + + async function getFd(pathName){ + let displayName = pathName; + const mediaTest = mediaLibrary.getMediaLibrary(); + let fileKeyObj = mediaLibrary.FileKey; + let mediaType = mediaLibrary.MediaType.VIDEO; + let publicPath = await mediaTest.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO); + let dataUri = await mediaTest.createAsset(mediaType, displayName, publicPath); + if (dataUri != undefined) { + let args = dataUri.id.toString(); + let fetchOp = { + selections: fileKeyObj.ID + "=?", + selectionArgs: [args], + } + let fetchFileResult = await mediaTest.getFileAssets(fetchOp); + mFileAsset = await fetchFileResult.getAllObject(); + mFdNumber = await mFileAsset[0].open('Rw'); + mFdPath = "fd://" + mFdNumber.toString(); + } + } + + async function closeFd() { + if (mFileAsset != null) { + await mFileAsset[0].close(mFdNumber).then(() => { + console.info('[mediaLibrary] case close fd success'); + }).catch((err) => { + console.info('[mediaLibrary] case close fd failed'); + }); + } else { + console.info('[mediaLibrary] case fileAsset is null'); + } + } + + async function applyPermission() { + let appInfo = await bundle.getApplicationInfo('com.open.harmony.multimedia.cameratest', 0, 100); + let atManager = abilityAccessCtrl.createAtManager(); + if (atManager != null) { + let tokenID = appInfo.accessTokenId; + console.info('[permission] case accessTokenID is ' + tokenID); + let permissionName1 = 'ohos.permission.CAMERA'; + let permissionName2 = 'ohos.permission.MICROPHONE'; + let permissionName3 = 'ohos.permission.MEDIA_LOCATION'; + let permissionName4 = 'ohos.permission.READ_MEDIA'; + let permissionName5 = 'ohos.permission.WRITE_MEDIA'; + await atManager.grantUserGrantedPermission(tokenID, permissionName1, 1).then((result) => { + console.info('[permission] case grantUserGrantedPermission success :' + result); + }).catch((err) => { + console.info('[permission] case grantUserGrantedPermission failed :' + err); + }); + await atManager.grantUserGrantedPermission(tokenID, permissionName2, 1).then((result) => { + console.info('[permission] case grantUserGrantedPermission success :' + result); + }).catch((err) => { + console.info('[permission] case grantUserGrantedPermission failed :' + err); + }); + await atManager.grantUserGrantedPermission(tokenID, permissionName3, 1).then((result) => { + console.info('[permission] case grantUserGrantedPermission success :' + result); + }).catch((err) => { + console.info('[permission] case grantUserGrantedPermission failed :' + err); + }); + await atManager.grantUserGrantedPermission(tokenID, permissionName4, 1).then((result) => { + console.info('[permission] case grantUserGrantedPermission success :' + result); + }).catch((err) => { + console.info('[permission] case grantUserGrantedPermission failed :' + err); + }); + await atManager.grantUserGrantedPermission(tokenID, permissionName5, 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 getPhotoReceiverSurface() { + console.log(TAG + 'Entering getPhotoReceiverSurface') + let receiver = image.createImageReceiver(640, 480, 4, 8) + 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)) + } else { + console.log(TAG + 'Photo receiver is created failed') + } + console.log(TAG + 'Exit getPhotoReceiverSurface') + } + + async function getVideoReceiveSurface() { + console.log(TAG + 'Entering getVideoReceiveSurface') + await getFd('CameraSessionFlush.mp4'); + mVideoConfig.url = mFdPath; + media.createVideoRecorder((err, recorder) => { + console.info(TAG + 'Entering create video receiver') + mVideoRecorder = recorder + console.info(TAG + 'videoRecorder is :' + JSON.stringify(mVideoRecorder)) + console.info(TAG + 'videoRecorder.prepare called.') + mVideoRecorder.prepare(mVideoConfig, (err) => { + console.info(TAG + 'videoRecorder.prepare success.') + }) + mVideoRecorder.getInputSurface((err, id) => { + console.info(TAG + 'getInputSurface called') + mVideoSurface = id + console.info(TAG + 'getInputSurface surfaceId: ' + JSON.stringify(mVideoSurface)) + }) + }) + console.log(TAG + 'Exit getVideoReceiveSurface') + } + + async function releaseVideoReceiveSurface() { + console.log(TAG + 'Entering releaseVideoReceiveSurface') + mVideoRecorder.release((err) => { + console.info(TAG + 'Entering release video receiver') + }) + await closeFd(); + + await sleep(100); + console.log(TAG + 'Exit releaseVideoReceiveSurface') + } + + async function mgetCameraManagerInstance() { + console.info('Enter mgetCameraManagerInstance'); + + mCameraManager = await cameraObj.getCameraManager(null); + if (isEmpty(mCameraManager)) { + console.info(TAG + "getCameraManager FAILED"); + return false; + } + + console.info('Exit mgetCameraManagerInstance'); + + 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 + "getCameraSupportDevicesArray is: " + mCameraDevicesArray.length); + 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 createInputs() { + console.info('Enter createInputs'); + + if (isEmpty(mCameraDevicesArray)) { + console.info(TAG + "Entering createInputs FAILED with NoCamera"); + return false; + } + + mCameraInputArray = new Array(mCameraDevicesArray.length); + mHasFlashArray = new Array(mCameraDevicesArray.length); + mIsFlashModeSupportedArray = new Array(mCameraDevicesArray.length); + + for (let i = 0; i < mCameraDevicesArray.length; i++) { + mCameraInputArray[i] = await mCameraManager.createCameraInput(mCameraDevicesArray[i]); + if (isEmpty(mCameraInputArray[i])) { + console.info(TAG + "createCameraInput FAILED"); + return false; + } + + mCameraInputArray[i].open(async (err) => { + console.info(TAG + "Entering mCameraInputArray open callback"); + if (!err) { + console.info(TAG + "Entering mCameraInputArray open PASSED "); + } else { + console.info(TAG + "Entering mCameraInputArray open FAILED : " + err.message); + } + }) + + await sleep(100); + + console.info(i + 'th CameraInput is: ' + mCameraInputArray[i]); + } + + console.info('Exit createInputs'); + + return true; + } + + async function releaseInputs() { + console.info('Enter releaseInputs'); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering releaseInputs FAILED with NoCamera"); + return true; + } + + for (let i = 0; i < mCameraInputArray.length; i++) { + await mCameraInputArray[i].close(); + await mCameraInputArray[i].release(); + } + + console.info('Exit releaseInputs'); + + return true; + } + + async function createOutputs() { + console.info('Enter createOutputs'); + + mPreviewOutputArray = new Array(mCameraDevicesArray.length); + mPhotoOutputArray = new Array(mCameraDevicesArray.length); + mVideoOutputArray = new Array(mCameraDevicesArray.length); + + for (let i = 0; i < mCameraDevicesArray.length; i++) { + let cameraOutputCap = await mCameraManager.getSupportedOutputCapability(mCameraDevicesArray[i]); + if (!isEmpty(cameraOutputCap.previewProfiles)) { + console.info(TAG + "cameraOutputCap.previewProfiles.length: " + cameraOutputCap.previewProfiles.length); + for (let j = 0; j < cameraOutputCap.previewProfiles.length; j++) { + mPreviewOutputArray[i] = await mCameraManager.createPreviewOutput(cameraOutputCap.previewProfiles[j], surfaceId); + if (!isEmpty(mPreviewOutputArray[i])) { + break; + } + } + + if (isEmpty(mPreviewOutputArray[i])) { + console.info(TAG + "createPreviewOutput FAILED"); + } + } + + /* + if (!isEmpty(cameraOutputCap.photoProfiles)) { + console.info(TAG + "cameraOutputCap.photoProfiles.length: " + cameraOutputCap.photoProfiles.length); + + for (let j = 0; j < cameraOutputCap.photoProfiles.length; j++) { + mPhotoOutputArray[i] = await mCameraManager.createPhotoOutput(cameraOutputCap.photoProfiles[j], mPhoteSurface); + if (!isEmpty(mPhotoOutputArray[i])) { + break; + } + } + + if (isEmpty(mPhotoOutputArray[i])) { + console.info(TAG + "createPhotoOutput FAILED"); + } + + console.info(TAG + "createPhotoOutput: " + mPhotoOutputArray[i]); + } + + if (!isEmpty(cameraOutputCap.videoProfiles)) { + console.info(TAG + "cameraOutputCap.videoProfiles.length: " + cameraOutputCap.videoProfiles.length); + for (let j = 0; j < cameraOutputCap.videoProfiles.length; j++) { + mVideoOutputArray[i] = await mCameraManager.createVideoOutput(cameraOutputCap.videoProfiles[j], mVideoSurface); + if (!isEmpty(mVideoOutputArray[i])) { + break; + } + } + + if (isEmpty(mVideoOutputArray[i])) { + console.info(TAG + "createVideoOutput FAILED"); + } + + console.info(TAG + "createVideoOutput: " + mPhotoOutputArray[i]); + } + */ + } + + console.info('Exit createOutputs'); + + return true; + } + + async function releaseOutputs() { + for (let i = 0; i < mCameraDevicesArray.length; i++) { + if (!isEmpty(mPreviewOutputArray[i])) { + await mPreviewOutputArray[i].close(); + await mPreviewOutputArray[i].release(); + } + + /* + if (!isEmpty(mPhotoOutputArray[i])) { + await mPhotoOutputArray[i].close(); + await mPhotoOutputArray[i].release(); + } + + if (!isEmpty(mVideoOutputArray[i])) { + await mVideoOutputArray[i].close(); + await mVideoOutputArray[i].release(); + } + */ + } + + return true; + } + + async function startCameraSession(idx:any) { + console.info(TAG + "Enter startCameraSession"); + + if (!isEmpty(mCameraInputArray[idx])) { + console.info(TAG + "Start to addInput"); + await mCameraSession.addInput(mCameraInputArray[idx]); + } + + if (!isEmpty(mPreviewOutputArray[idx])) { + console.info(TAG + "Start to addOutput mPreviewOutput"); + await mCameraSession.addOutput(mPreviewOutputArray[idx]); + } + + /* + if (!isEmpty(mPhotoOutputArray[idx])) { + console.info(TAG + "Start to addOutput mPhotoOutput"); + await mCameraSession.addOutput(mPhotoOutputArray[idx]); + } + + if (!isEmpty(mVideoOutputArray[idx])) { + console.info(TAG + "Start to addOutput mVideoOutput"); + await mCameraSession.addOutput(mVideoOutputArray[idx]); + } + */ + + await commitCameraSessionConfig(); + await beginCameraSessionConfig(); + + /* + await mCameraSession.start(async (err) => { + console.info(TAG + "Entering mCameraSession start callback"); + if (!err) { + console.info(TAG + "Entering mCameraSession start PASSED "); + } else { + console.info(TAG + "Entering mCameraSession start FAILED : " + err.message); + } + }) + + await sleep(1000); + */ + console.info(TAG + "Exit startCameraSession"); + + return true; + } + + async function stopCameraSession(idx:any) { + console.info(TAG + "Enter stopCameraSession"); + /* + mCameraSession.stop(async (err) => { + console.info(TAG + "Entering mCameraSession stop callback"); + if (!err) { + console.info(TAG + "Entering mCameraSession stop PASSED "); + } else { + console.info(TAG + "Entering mCameraSession stop FAILED : " + err.message); + } + }) + + await sleep(1000); + */ + + if (!isEmpty(mCameraInputArray[idx])) { + console.info(TAG + "Start to removeInput input"); + await mCameraSession.removeInput(mCameraInputArray[idx]); + } + + if (!isEmpty(mPreviewOutputArray[idx])) { + console.info(TAG + "Start to removeOutput mPreviewOutput"); + await mCameraSession.removeOutput(mPreviewOutputArray[idx]); + } + + /* + if (!isEmpty(mPhotoOutputArray[idx])) { + console.info(TAG + "Start to removeOutput mPhotoOutput"); + await mCameraSession.removeOutput(mPhotoOutputArray[idx]); + } + + if (!isEmpty(mVideoOutputArray[idx])) { + console.info(TAG + "Start to removeOutput mVideoOutput"); + await mCameraSession.removeOutput(mVideoOutputArray[idx]); + } + */ + + console.info(TAG + "Exit stopCameraSession"); + + return true; + } + + describe('cameraSessionFlashTest', function () { + console.info(TAG + '----------cameraSessionFlashTest--------------') + + beforeAll(async function () { + sleep(100); + await applyPermission(); + await getPhotoReceiverSurface(); + await getVideoReceiveSurface(); + await mgetCameraManagerInstance(); + await getCameraSupportDevicesArray(); + await createCameraSessionInstance(); + await createInputs(); + await createOutputs(); + + console.info('Device type = ' + deviceInfo.deviceType); + + console.info('beforeAll case'); + }) + + beforeEach(function () { + sleep(1000); + console.info('beforeEach case'); + }) + + afterEach(async function () { + console.info('afterEach case'); + }) + + afterAll(function () { + releaseInputs(); + releaseOutputs(); + releaseVideoReceiveSurface(); + releaseCameraSessionInstance(); + sleep(1000); + console.info('afterAll case'); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_HAS_FLASH_CALLBACK_0100 + * @tc.name : Check capture session has flash with callback or not + * @tc.desc : Check capture session has flash with callback or not + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_HAS_FLASH_CALLBACK_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_HAS_FLASH_CALLBACK_0100--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_HAS_FLASH_CALLBACK_0100 FAILED with NoCamera"); + expect().assertFail(); + done(); + } + else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_HAS_FLASH_CALLBACK_0100 start for camera[" + i + "]"); + + await startCameraSession(i); + mHasFlashArray[i] = false; + + mCameraSession.hasFlash(async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_HAS_FLASH_CALLBACK_0100 callback"); + if (!err) { + if (data != null || data != undefined) { + mHasFlashArray[i] = data; + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_HAS_FLASH_CALLBACK_0100 PASSED with hasFlash is: " + data); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_HAS_FLASH_CALLBACK_0100 FAILED with hasFlash is: " + data); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_HAS_FLASH_CALLBACK_0100 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(1000); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_HAS_FLASH_CALLBACK_0100 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_HAS_FLASH_CALLBACK_0100 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_HAS_FLASH_PROMISE_0100 + * @tc.name : Check capture session has flash with promise or not + * @tc.desc : Check capture session has flash with promise or not + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_HAS_FLASH_PROMISE_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_HAS_FLASH_PROMISE_0100--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_HAS_FLASH_PROMISE_0100 FAILED with NoCamera"); + expect().assertFail(); + done(); + } + else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_HAS_FLASH_PROMISE_0100 start for camera[" + i + "]"); + + await startCameraSession(i); + + let hasFlashPromise = await mCameraSession.hasFlash(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_HAS_FLASH_PROMISE_0100 finish"); + if (hasFlashPromise != null || hasFlashPromise != undefined) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_HAS_FLASH_PROMISE_0100 PASSED with hasFlash is: " + hasFlashPromise); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_HAS_FLASH_PROMISE_0100 FAILED with hasFlash is: " + hasFlashPromise); + expect().assertFail(); + } + await sleep(1000); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_HAS_FLASH_PROMISE_0100 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_HAS_FLASH_PROMISE_0100 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_CALLBACK_0100 + * @tc.name : Check capture session support flash close mode with callback or not + * @tc.desc : Check capture session support flash close mode with callback or not + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_CALLBACK_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_CALLBACK_0100--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_CALLBACK_0100 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_CALLBACK_0100 start for camera[" + i + "]"); + + await startCameraSession(i); + + mIsFlashModeSupportedArray[i] = false; + + if (mHasFlashArray[i] == true) { + mCameraSession.isFlashModeSupported(cameraObj.FlashMode.FLASH_MODE_CLOSE, async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_CALLBACK_0100 callback"); + if (!err) { + if (data != null || data != undefined) { + mIsFlashModeSupportedArray[i] = data; + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_CALLBACK_0100 PASSED with isFlashModeSupported is: " + data); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_CALLBACK_0100 FAILED with isFlashModeSupported is: " + data); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_CALLBACK_0100 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(1000); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_CALLBACK_0100 not support"); + } + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_CALLBACK_0100 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_CALLBACK_0100 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0100 + * @tc.name : Check capture session support flash close mode with promise or not + * @tc.desc : Check capture session support flash close mode with promise or not + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0100--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0100 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0100 start for camera[" + i + "]"); + + await startCameraSession(i); + + if (mHasFlashArray[i] == true) { + let isFlashModeSupported = await mCameraSession.isFlashModeSupported(cameraObj.FlashMode.FLASH_MODE_CLOSE); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0100 finish"); + if (isFlashModeSupported != null || isFlashModeSupported != undefined) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0100 PASSED with isFlashModeSupported is: " + isFlashModeSupported); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0100 FAILED with isFlashModeSupported is: " + isFlashModeSupported); + expect().assertFail(); + } + + await sleep(1000); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0100 not support"); + } + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0100 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0100 ends here"); + done(); + } + + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0100 + * @tc.name : Check capture session set flash close mode with callback + * @tc.desc : Check capture session set flash close mode with callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0100--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0100 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0100 start for camera[" + i + "]"); + + await startCameraSession(i); + + if ((mHasFlashArray[i] == true) && (mIsFlashModeSupportedArray[i] == true)) { + mCameraSession.setFlashMode(cameraObj.FlashMode.FLASH_MODE_CLOSE, async (err) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0100 callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0100 PASSED with FlashMode is: " + cameraObj.FlashMode.FLASH_MODE_CLOSE); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0100 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + mCameraSession.getFlashMode(async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0100 callback"); + if (!err) { + if (data == cameraObj.FlashMode.FLASH_MODE_CLOSE) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0100 PASSED with FlaseMode is: " + data); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0100 FAILED with FlaseMode is: " + data); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0100 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0100 not support"); + } + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0100 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0100 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0100 + * @tc.name : Check capture session set flash close mode with promise + * @tc.desc : Check capture session set flash close mode with promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0100--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0100 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0100 start for camera[" + i + "]"); + + await startCameraSession(i); + + if ((mHasFlashArray[i] == true) && (mIsFlashModeSupportedArray[i] == true)) { + await mCameraSession.setFlashMode(cameraObj.FlashMode.FLASH_MODE_CLOSE); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0100 finish"); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0100 PASSED with FlashMode is: " + cameraObj.FlashMode.FLASH_MODE_CLOSE); + await sleep(500); + + let flashMode = await mCameraSession.getFlashMode(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0100 finish"); + if (flashMode == cameraObj.FlashMode.FLASH_MODE_CLOSE) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0100 PASSED with FlaseMode is: " + flashMode); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0100 FAILED with FlaseMode is: " + flashMode); + expect().assertFail(); + } + await sleep(500); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0100 not support"); + } + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0100 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0100 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_CALLBACK_0101 + * @tc.name : Check capture session support flash open mode with callback or not + * @tc.desc : Check capture session support flash open mode with callback or not + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_CALLBACK_0101', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_CALLBACK_0101--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_CALLBACK_0101 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_CALLBACK_0101 start for camera[" + i + "]"); + + await startCameraSession(i); + + mIsFlashModeSupportedArray[i] = false; + + if (mHasFlashArray[i] == true) { + mCameraSession.isFlashModeSupported(cameraObj.FlashMode.FLASH_MODE_OPEN, async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_CALLBACK_0101 callback"); + if (!err) { + if (data != null || data != undefined) { + mIsFlashModeSupportedArray[i] = data; + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_CALLBACK_0101 PASSED with isFlashModeSupported is: " + data); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_CALLBACK_0101 FAILED with isFlashModeSupported is: " + data); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_CALLBACK_0101 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(1000); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_CALLBACK_0101 not support"); + } + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_CALLBACK_0101 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_CALLBACK_0101 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0101 + * @tc.name : Check capture session support flash open mode with promise or not + * @tc.desc : Check capture session support flash open mode with promise or not + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0101', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0101--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0101 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0101 start for camera[" + i + "]"); + + await startCameraSession(i); + + if (mHasFlashArray[i] == true) { + let isFlashModeSupported = await mCameraSession.isFlashModeSupported(cameraObj.FlashMode.FLASH_MODE_OPEN); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0101 finish"); + if (isFlashModeSupported != null || isFlashModeSupported != undefined) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0101 PASSED with isFlashModeSupported is: " + isFlashModeSupported); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0101 FAILED with isFlashModeSupported is: " + isFlashModeSupported); + expect().assertFail(); + } + + await sleep(1000); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0101 not support"); + } + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0101 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0101 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0101 + * @tc.name : Check capture session set flash open mode with callback + * @tc.desc : Check capture session set flash open mode with callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0101', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0101--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0101 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0101 start for camera[" + i + "]"); + + await startCameraSession(i); + + if ((mHasFlashArray[i] == true) && (mIsFlashModeSupportedArray[i] == true)) { + mCameraSession.setFlashMode(cameraObj.FlashMode.FLASH_MODE_OPEN, async (err) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0101 callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0101 PASSED with FlashMode is: " + cameraObj.FlashMode.FLASH_MODE_OPEN); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0101 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + mCameraSession.getFlashMode(async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0101 callback"); + if (!err) { + if (data == cameraObj.FlashMode.FLASH_MODE_OPEN) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0101 PASSED with FlaseMode is: " + data); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0101 FAILED with FlaseMode is: " + data); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0101 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0101 not support"); + } + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0101 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0101 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0101 + * @tc.name : Check capture session set flash open mode with promise + * @tc.desc : Check capture session set flash open mode with promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0101', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0101--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0101 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0101 start for camera[" + i + "]"); + + await startCameraSession(i); + + if ((mHasFlashArray[i] == true) && (mIsFlashModeSupportedArray[i] == true)) { + await mCameraSession.setFlashMode(cameraObj.FlashMode.FLASH_MODE_OPEN); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0101 finish"); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0101 PASSED with FlashMode is: " + cameraObj.FlashMode.FLASH_MODE_OPEN); + await sleep(500); + + let flashMode = await mCameraSession.getFlashMode(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0101 finish"); + if (flashMode == cameraObj.FlashMode.FLASH_MODE_OPEN) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0101 PASSED with FlaseMode is: " + flashMode); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0101 FAILED with FlaseMode is: " + flashMode); + expect().assertFail(); + } + await sleep(500); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0101 not support"); + } + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0101 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0101 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_CALLBACK_0102 + * @tc.name : Check capture session support flash auto mode with callback or not + * @tc.desc : Check capture session support flash auto mode with callback or not + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_CALLBACK_0102', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_CALLBACK_0102--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_CALLBACK_0102 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_CALLBACK_0102 start for camera[" + i + "]"); + + await startCameraSession(i); + + mIsFlashModeSupportedArray[i] = false; + + if (mHasFlashArray[i] == true) { + mCameraSession.isFlashModeSupported(cameraObj.FlashMode.FLASH_MODE_AUTO, async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_CALLBACK_0102 callback"); + if (!err) { + if (data != null || data != undefined) { + mIsFlashModeSupportedArray[i] = data; + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_CALLBACK_0102 PASSED with isFlashModeSupported is: " + data); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_CALLBACK_0102 FAILED with isFlashModeSupported is: " + data); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_CALLBACK_0102 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(1000); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_CALLBACK_0102 not support"); + } + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_CALLBACK_0102 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_CALLBACK_0102 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0102 + * @tc.name : Check capture session support flash auto mode with promise or not + * @tc.desc : Check capture session support flash auto mode with promise or not + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0102', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0102--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0102 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0102 start for camera[" + i + "]"); + + await startCameraSession(i); + + if (mHasFlashArray[i] == true) { + let isFlashModeSupported = await mCameraSession.isFlashModeSupported(cameraObj.FlashMode.FLASH_MODE_AUTO); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0102 finish"); + if (isFlashModeSupported != null || isFlashModeSupported != undefined) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0102 PASSED with isFlashModeSupported is: " + isFlashModeSupported); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0102 FAILED with isFlashModeSupported is: " + isFlashModeSupported); + expect().assertFail(); + } + + await sleep(1000); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0102 not support"); + } + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0102 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0102 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0102 + * @tc.name : Check capture session set flash auto mode with callback + * @tc.desc : Check capture session set flash auto mode with callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0102', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0102--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0102 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0102 start for camera[" + i + "]"); + + await startCameraSession(i); + + if ((mHasFlashArray[i] == true) && (mIsFlashModeSupportedArray[i] == true)) { + mCameraSession.setFlashMode(cameraObj.FlashMode.FLASH_MODE_AUTO, async (err) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0102 callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0102 PASSED with FlashMode is: " + cameraObj.FlashMode.FLASH_MODE_AUTO); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0102 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + mCameraSession.getFlashMode(async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0102 callback"); + if (!err) { + if (data == cameraObj.FlashMode.FLASH_MODE_AUTO) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0102 PASSED with FlaseMode is: " + data); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0102 FAILED with FlaseMode is: " + data); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0102 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0102 not support"); + } + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0102 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0102 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0102 + * @tc.name : Check capture session set flash auto mode with promise + * @tc.desc : Check capture session set flash auto mode with promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0102', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0102--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0102 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0102 start for camera[" + i + "]"); + + await startCameraSession(i); + + if ((mHasFlashArray[i] == true) && (mIsFlashModeSupportedArray[i] == true)) { + await mCameraSession.setFlashMode(cameraObj.FlashMode.FLASH_MODE_AUTO); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0102 finish"); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0102 PASSED with FlashMode is: " + cameraObj.FlashMode.FLASH_MODE_AUTO); + await sleep(500); + + let flashMode = await mCameraSession.getFlashMode(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0102 finish"); + if (flashMode == cameraObj.FlashMode.FLASH_MODE_AUTO) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0102 PASSED with FlaseMode is: " + flashMode); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0102 FAILED with FlaseMode is: " + flashMode); + expect().assertFail(); + } + await sleep(500); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0102 not support"); + } + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0102 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0102 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_CALLBACK_0103 + * @tc.name : Check capture session support flash always open mode with callback or not + * @tc.desc : Check capture session support flash always open mode with callback or not + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_CALLBACK_0103', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_CALLBACK_0103--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_CALLBACK_0103 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_CALLBACK_0103 start for camera[" + i + "]"); + + await startCameraSession(i); + + mIsFlashModeSupportedArray[i] = false; + + if (mHasFlashArray[i] == true) { + mCameraSession.isFlashModeSupported(cameraObj.FlashMode.FLASH_MODE_ALWAYS_OPEN, async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_CALLBACK_0103 callback"); + if (!err) { + if (data != null || data != undefined) { + mIsFlashModeSupportedArray[i] = data; + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_CALLBACK_0103 PASSED with isFlashModeSupported is: " + data); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_CALLBACK_0103 FAILED with isFlashModeSupported is: " + data); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_CALLBACK_0103 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(1000); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_CALLBACK_0103 not support"); + } + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_CALLBACK_0103 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_CALLBACK_0103 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0103 + * @tc.name : Check capture session support flash always open mode with promise or not + * @tc.desc : Check capture session support flash always open mode with promise or not + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0103', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0103--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0103 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0103 start for camera[" + i + "]"); + + await startCameraSession(i); + + if (mHasFlashArray[i] == true) { + let isFlashModeSupported = await mCameraSession.isFlashModeSupported(cameraObj.FlashMode.FLASH_MODE_ALWAYS_OPEN); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0103 finish"); + if (isFlashModeSupported != null || isFlashModeSupported != undefined) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0103 PASSED with hasFlash is: " + isFlashModeSupported); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0103 FAILED with hasFlash is: " + isFlashModeSupported); + expect().assertFail(); + } + + await sleep(1000); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0103 not support"); + } + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0103 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0103 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0103 + * @tc.name : Check capture session set flash always open mode with callback + * @tc.desc : Check capture session set flash always open mode with callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0103', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0103--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0103 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0103 start for camera[" + i + "]"); + + await startCameraSession(i); + + if ((mHasFlashArray[i] == true) && (mIsFlashModeSupportedArray[i] == true)) { + mCameraSession.setFlashMode(cameraObj.FlashMode.FLASH_MODE_ALWAYS_OPEN, async (err) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0103 callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0103 PASSED with FlashMode is: " + cameraObj.FlashMode.FLASH_MODE_ALWAYS_OPEN); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0103 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + mCameraSession.getFlashMode(async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0103 callback"); + if (!err) { + if (data == cameraObj.FlashMode.FLASH_MODE_ALWAYS_OPEN) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0103 PASSED with FlaseMode is: " + data); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0103 FAILED with FlaseMode is: " + data); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0103 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0103 not support"); + } + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0103 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_CALLBACK_0103 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0103 + * @tc.name : Check capture session set flash always open mode with promise + * @tc.desc : Check capture session set flash always open mode with promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0103', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0103--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0103 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0103 start for camera[" + i + "]"); + + await startCameraSession(i); + + if ((mHasFlashArray[i] == true) && (mIsFlashModeSupportedArray[i] == true)) { + await mCameraSession.setFlashMode(cameraObj.FlashMode.FLASH_MODE_ALWAYS_OPEN); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0103 finish"); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0103 PASSED with FlashMode is: " + cameraObj.FlashMode.FLASH_MODE_ALWAYS_OPEN); + await sleep(500); + + let flashMode = await mCameraSession.getFlashMode(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0103 finish"); + if (flashMode == cameraObj.FlashMode.FLASH_MODE_ALWAYS_OPEN) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0103 PASSED with FlaseMode is: " + flashMode); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0103 FAILED with FlaseMode is: " + flashMode); + expect().assertFail(); + } + + await sleep(500); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0103 not support"); + } + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0103 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0103 ends here"); + done(); + } + }) + + }) +} \ No newline at end of file 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 new file mode 100755 index 0000000000000000000000000000000000000000..5afed1a5152bf1a3765e53048f36ecf3ba12a75d --- /dev/null +++ b/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraSessionFocusTest.test.ets @@ -0,0 +1,2463 @@ +/* + * 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. + */ + +// @ts-ignore + +import cameraObj from '@ohos.multimedia.camera'; +import image from '@ohos.multimedia.image'; +import media from '@ohos.multimedia.media' +import mediaLibrary from '@ohos.multimedia.mediaLibrary' +import fileio from '@ohos.fileio'; +import abilityAccessCtrl from '@ohos.abilityAccessCtrl' +import bundle from '@ohos.bundle' +import deviceInfo from '@ohos.deviceInfo'; +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'; + +const TAG = "CameraModuleTest: "; + +// Define global letiables +let mCameraManager; +let mCameraDevicesArray; +let mCameraSession; + +let mPhoteSurface; +let mVideoRecorder; +let mVideoSurface; +let mFileAsset; +let mFdPath; +let mFdNumber; + +// CAMERA-0 letiables +let mCameraInputArray; +let mPreviewOutputArray; +let mPhotoOutputArray; +let mVideoOutputArray; + +let mIsFocusModeSupportedArray; + +let mVideoProfileCfg = { + audioBitrate: 48000, + audioChannels: 2, + audioCodec: 'audio/mp4a-latm', + audioSampleRate: 48000, + durationTime: 1000, + fileFormat: 'mp4', + videoBitrate: 48000, + videoCodec: 'video/mp4v-es', + videoFrameWidth: 640, + videoFrameHeight: 480, + videoFrameRate: 30 +} + +let mVideoConfig = { + audioSourceType: 1, + videoSourceType: 0, + profile: mVideoProfileCfg, + url: 'file:///data/media/CameraSessionFocus.mp4', + orientationHint: 0, + location: { latitude: 30, longitude: 130 }, + maxSize: 100, + maxDuration: 500 +} + +let mPicWidthMax = 8192; +let mPicHeightMax = 8192; + +let mFocusPoint = { + x: mPicWidthMax / 2, + y: mPicHeightMax / 2, +} + +let mFocusPointLT = { + x: 0, + y: 0, +} + +let mFocusPointRT = { + x: mPicWidthMax , + y: 0, +} + +let mFocusPointLB = { + x: 0, + y: mPicHeightMax, +} + +let mFocusPointRB = { + x: mPicWidthMax, + y: mPicHeightMax, +} + +let mFocusPointInvalidLT = { + x: -1, + y: -1, +} + +let mFocusPointInvalidRT = { + x: (mPicWidthMax + 1), + y: -1, +} + +let mFocusPointInvalidLB = { + x: -1, + y: (mPicHeightMax + 1), +} + +let mFocusPointInvalidRB = { + x: (mPicWidthMax + 1), + y: (mPicHeightMax + 1), +} + +let mEnableCheckInvalidFocusPoint = false; + +export default function cameraSessionFocusTest(surfaceId: any) { + + function sleep(ms) { + console.info(TAG + "Entering sleep -> Promise constructor"); + return new Promise(resolve => setTimeout(resolve, ms)); + } + + function isEmpty(data) { + if (data == null || data == undefined) { + return true; + } + return false; + } + + async function getFd(pathName){ + let displayName = pathName; + const mediaTest = mediaLibrary.getMediaLibrary(); + let fileKeyObj = mediaLibrary.FileKey; + let mediaType = mediaLibrary.MediaType.VIDEO; + let publicPath = await mediaTest.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO); + let dataUri = await mediaTest.createAsset(mediaType, displayName, publicPath); + if (dataUri != undefined) { + let args = dataUri.id.toString(); + let fetchOp = { + selections: fileKeyObj.ID + "=?", + selectionArgs: [args], + } + let fetchFileResult = await mediaTest.getFileAssets(fetchOp); + mFileAsset = await fetchFileResult.getAllObject(); + mFdNumber = await mFileAsset[0].open('Rw'); + mFdPath = "fd://" + mFdNumber.toString(); + } + } + + async function closeFd() { + if (mFileAsset != null) { + await mFileAsset[0].close(mFdNumber).then(() => { + console.info('[mediaLibrary] case close fd success'); + }).catch((err) => { + console.info('[mediaLibrary] case close fd failed'); + }); + } else { + console.info('[mediaLibrary] case fileAsset is null'); + } + } + + async function applyPermission() { + let appInfo = await bundle.getApplicationInfo('com.open.harmony.multimedia.cameratest', 0, 100); + let atManager = abilityAccessCtrl.createAtManager(); + if (atManager != null) { + let tokenID = appInfo.accessTokenId; + console.info('[permission] case accessTokenID is ' + tokenID); + let permissionName1 = 'ohos.permission.CAMERA'; + let permissionName2 = 'ohos.permission.MICROPHONE'; + let permissionName3 = 'ohos.permission.MEDIA_LOCATION'; + let permissionName4 = 'ohos.permission.READ_MEDIA'; + let permissionName5 = 'ohos.permission.WRITE_MEDIA'; + await atManager.grantUserGrantedPermission(tokenID, permissionName1, 1).then((result) => { + console.info('[permission] case grantUserGrantedPermission success :' + result); + }).catch((err) => { + console.info('[permission] case grantUserGrantedPermission failed :' + err); + }); + await atManager.grantUserGrantedPermission(tokenID, permissionName2, 1).then((result) => { + console.info('[permission] case grantUserGrantedPermission success :' + result); + }).catch((err) => { + console.info('[permission] case grantUserGrantedPermission failed :' + err); + }); + await atManager.grantUserGrantedPermission(tokenID, permissionName3, 1).then((result) => { + console.info('[permission] case grantUserGrantedPermission success :' + result); + }).catch((err) => { + console.info('[permission] case grantUserGrantedPermission failed :' + err); + }); + await atManager.grantUserGrantedPermission(tokenID, permissionName4, 1).then((result) => { + console.info('[permission] case grantUserGrantedPermission success :' + result); + }).catch((err) => { + console.info('[permission] case grantUserGrantedPermission failed :' + err); + }); + await atManager.grantUserGrantedPermission(tokenID, permissionName5, 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 getPhotoReceiverSurface() { + console.log(TAG + 'Entering getPhotoReceiverSurface') + let receiver = image.createImageReceiver(640, 480, 4, 8) + 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)) + } else { + console.log(TAG + 'Photo receiver is created failed') + } + console.log(TAG + 'Exit getPhotoReceiverSurface') + } + + async function getVideoReceiveSurface() { + console.log(TAG + 'Entering getVideoReceiveSurface') + await getFd('CameraSessionFocus.mp4'); + mVideoConfig.url = mFdPath; + media.createVideoRecorder((err, recorder) => { + console.info(TAG + 'Entering create video receiver') + mVideoRecorder = recorder + console.info(TAG + 'videoRecorder is :' + JSON.stringify(mVideoRecorder)) + console.info(TAG + 'videoRecorder.prepare called.') + mVideoRecorder.prepare(mVideoConfig, (err) => { + console.info(TAG + 'videoRecorder.prepare success.') + }) + mVideoRecorder.getInputSurface((err, id) => { + console.info(TAG + 'getInputSurface called') + mVideoSurface = id + console.info(TAG + 'getInputSurface surfaceId: ' + JSON.stringify(mVideoSurface)) + }) + }) + console.log(TAG + 'Exit getVideoReceiveSurface') + } + + async function releaseVideoReceiveSurface() { + console.log(TAG + 'Entering releaseVideoReceiveSurface') + mVideoRecorder.release((err) => { + console.info(TAG + 'Entering release video receiver') + }) + await closeFd(); + + await sleep(100); + console.log(TAG + 'Exit releaseVideoReceiveSurface') + } + + async function getCameraManagerInstance() { + console.info('Enter getCameraManagerInstance'); + + mCameraManager = await cameraObj.getCameraManager(null); + if (isEmpty(mCameraManager)) { + 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 + "getCameraSupportDevicesArray is: " + mCameraDevicesArray.length); + 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, data) => { + 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 createInputs() { + console.info('Enter createInputs'); + + if (isEmpty(mCameraDevicesArray)) { + console.info(TAG + "Entering createInputs FAILED with NoCamera"); + return false; + } + + mCameraInputArray = new Array(mCameraDevicesArray.length); + mIsFocusModeSupportedArray = new Array(mCameraDevicesArray.length); + + for (let i = 0; i < mCameraDevicesArray.length; i++) { + mCameraInputArray[i] = await mCameraManager.createCameraInput(mCameraDevicesArray[i]); + if (isEmpty(mCameraInputArray[i])) { + console.info(TAG + "createCameraInput FAILED"); + return false; + } + + mCameraInputArray[i].open(async (err) => { + console.info(TAG + "Entering mCameraInputArray open callback"); + if (!err) { + console.info(TAG + "Entering mCameraInputArray open PASSED "); + } else { + console.info(TAG + "Entering mCameraInputArray open FAILED : " + err.message); + } + }) + + await sleep(2000); + + console.info(i + 'th CameraInput is: ' + mCameraInputArray[i]); + } + + console.info('Exit createInputs'); + + return true; + } + + async function releaseInputs() { + console.info('Enter releaseInputs'); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering releaseInputs FAILED with NoCamera"); + return true; + } + + for (let i = 0; i < mCameraInputArray.length; i++) { + await mCameraInputArray[i].close(); + await mCameraInputArray[i].release(); + } + + console.info('Exit releaseInputs'); + + return true; + } + + async function createOutputs() { + console.info('Enter createOutputs'); + + mPreviewOutputArray = new Array(mCameraDevicesArray.length); + mPhotoOutputArray = new Array(mCameraDevicesArray.length); + mVideoOutputArray = new Array(mCameraDevicesArray.length); + + for (let i = 0; i < mCameraDevicesArray.length; i++) { + let cameraOutputCap = await mCameraManager.getSupportedOutputCapability(mCameraDevicesArray[i]); + if (!isEmpty(cameraOutputCap.previewProfiles)) { + console.info(TAG + "cameraOutputCap.previewProfiles.length: " + cameraOutputCap.previewProfiles.length); + for (let j = 0; j < cameraOutputCap.previewProfiles.length; j++) { + mPreviewOutputArray[i] = await mCameraManager.createPreviewOutput(cameraOutputCap.previewProfiles[j], surfaceId); + if (!isEmpty(mPreviewOutputArray[i])) { + break; + } + } + + if (isEmpty(mPreviewOutputArray[i])) { + console.info(TAG + "createPreviewOutput FAILED"); + } + } + + /* + if (!isEmpty(cameraOutputCap.photoProfiles)) { + console.info(TAG + "cameraOutputCap.photoProfiles.length: " + cameraOutputCap.photoProfiles.length); + + for (let j = 0; j < cameraOutputCap.photoProfiles.length; j++) { + mPhotoOutputArray[i] = await mCameraManager.createPhotoOutput(cameraOutputCap.photoProfiles[j], mPhoteSurface); + if (!isEmpty(mPhotoOutputArray[i])) { + break; + } + } + + if (isEmpty(mPhotoOutputArray[i])) { + console.info(TAG + "createPhotoOutput FAILED"); + } + + console.info(TAG + "createPhotoOutput: " + mPhotoOutputArray[i]); + } + + if (!isEmpty(cameraOutputCap.videoProfiles)) { + console.info(TAG + "cameraOutputCap.videoProfiles.length: " + cameraOutputCap.videoProfiles.length); + for (let j = 0; j < cameraOutputCap.videoProfiles.length; j++) { + mVideoOutputArray[i] = await mCameraManager.createVideoOutput(cameraOutputCap.videoProfiles[j], mVideoSurface); + if (!isEmpty(mVideoOutputArray[i])) { + break; + } + } + + if (isEmpty(mVideoOutputArray[i])) { + console.info(TAG + "createVideoOutput FAILED"); + } + + console.info(TAG + "createVideoOutput: " + mPhotoOutputArray[i]); + } + */ + } + + console.info('Exit createOutputs'); + + return true; + } + + async function releaseOutputs() { + for (let i = 0; i < mCameraDevicesArray.length; i++) { + if (!isEmpty(mPreviewOutputArray[i])) { + await mPreviewOutputArray[i].close(); + await mPreviewOutputArray[i].release(); + } + + /* + if (!isEmpty(mPhotoOutputArray[i])) { + await mPhotoOutputArray[i].close(); + await mPhotoOutputArray[i].release(); + } + + if (!isEmpty(mVideoOutputArray[i])) { + await mVideoOutputArray[i].close(); + await mVideoOutputArray[i].release(); + } + */ + } + + return true; + } + + async function startCameraSession(idx:any) { + console.info(TAG + "Enter startCameraSession"); + + if (!isEmpty(mCameraInputArray[idx])) { + console.info(TAG + "Start to addInput"); + await mCameraSession.addInput(mCameraInputArray[idx]); + } + + if (!isEmpty(mPreviewOutputArray[idx])) { + console.info(TAG + "Start to addOutput mPreviewOutput"); + await mCameraSession.addOutput(mPreviewOutputArray[idx]); + } + + /* + if (!isEmpty(mPhotoOutputArray[idx])) { + console.info(TAG + "Start to addOutput mPhotoOutput"); + await mCameraSession.addOutput(mPhotoOutputArray[idx]); + } + + if (!isEmpty(mVideoOutputArray[idx])) { + console.info(TAG + "Start to addOutput mVideoOutput"); + await mCameraSession.addOutput(mVideoOutputArray[idx]); + } + */ + + await commitCameraSessionConfig(); + await beginCameraSessionConfig(); + + /* + await mCameraSession.start(async (err) => { + console.info(TAG + "Entering mCameraSession start callback"); + if (!err) { + console.info(TAG + "Entering mCameraSession start PASSED "); + } else { + console.info(TAG + "Entering mCameraSession start FAILED : " + err.message); + } + }) + + await sleep(1000); + */ + console.info(TAG + "Exit startCameraSession"); + + return true; + } + + async function stopCameraSession(idx:any) { + console.info(TAG + "Enter stopCameraSession"); + /* + mCameraSession.stop(async (err) => { + console.info(TAG + "Entering mCameraSession stop callback"); + if (!err) { + console.info(TAG + "Entering mCameraSession stop PASSED "); + } else { + console.info(TAG + "Entering mCameraSession stop FAILED : " + err.message); + } + }) + + await sleep(1000); + */ + + if (!isEmpty(mCameraInputArray[idx])) { + console.info(TAG + "Start to removeInput input"); + await mCameraSession.removeInput(mCameraInputArray[idx]); + } + + if (!isEmpty(mPreviewOutputArray[idx])) { + console.info(TAG + "Start to removeOutput mPreviewOutput"); + await mCameraSession.removeOutput(mPreviewOutputArray[idx]); + } + + /* + if (!isEmpty(mPhotoOutputArray[idx])) { + console.info(TAG + "Start to removeOutput mPhotoOutput"); + await mCameraSession.removeOutput(mPhotoOutputArray[idx]); + } + + if (!isEmpty(mVideoOutputArray[idx])) { + console.info(TAG + "Start to removeOutput mVideoOutput"); + await mCameraSession.removeOutput(mVideoOutputArray[idx]); + } + */ + + console.info(TAG + "Exit stopCameraSession"); + + return true; + } + + describe('cameraSessionFocusTest', function () { + console.info(TAG + '----------cameraSessionFocusTest--------------') + + beforeAll(async function () { + sleep(100); + await applyPermission(); + await getPhotoReceiverSurface(); + await getVideoReceiveSurface(); + await getCameraManagerInstance(); + await getCameraSupportDevicesArray(); + await createCameraSessionInstance(); + await createInputs(); + await createOutputs(); + + console.info('Device type = ' + deviceInfo.deviceType); + + console.info('beforeAll case'); + }) + + beforeEach(function () { + sleep(5000); + console.info('beforeEach case'); + }) + + afterEach(async function () { + console.info('afterEach case'); + }) + + afterAll(function () { + releaseInputs(); + releaseOutputs(); + releaseVideoReceiveSurface(); + releaseCameraSessionInstance(); + sleep(1000); + console.info('afterAll case'); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_CALLBACK_0100 + * @tc.name : Check capture session support focus manual mode with callback or not + * @tc.desc : Check capture session support focus manual mode with callback or not + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_CALLBACK_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_CALLBACK_0100--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_CALLBACK_0100 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_CALLBACK_0100 start for camera[" + i + "]"); + + await startCameraSession(i); + + mIsFocusModeSupportedArray[i] = false; + + mCameraSession.isFocusModeSupported(cameraObj.FocusMode.FOCUS_MODE_MANUAL, async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_CALLBACK_0100 callback"); + if (!err) { + if (data != null || data != undefined) { + mIsFocusModeSupportedArray[i] = data; + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_CALLBACK_0100 PASSED with isFocusModeSupported is: " + data); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_CALLBACK_0100 FAILED with isFocusModeSupported is: " + data); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_CALLBACK_0100 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(1000); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_CALLBACK_0100 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_CALLBACK_0100 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0100 + * @tc.name : Check capture session support focus manual mode with promise or not + * @tc.desc : Check capture session support focus manual mode with promise or not + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0100--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0100 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0100 start for camera[" + i + "]"); + + await startCameraSession(i); + + let isFocusModeSupported = await mCameraSession.isFocusModeSupported(cameraObj.FocusMode.FOCUS_MODE_MANUAL); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0100 finish"); + if (isFocusModeSupported != null || isFocusModeSupported != undefined) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0100 PASSED with isFocusModeSupported is: " + isFocusModeSupported); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0100 FAILED with isFocusModeSupported is: " + isFocusModeSupported); + expect().assertFail(); + } + + await sleep(1000); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0100 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0100 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0100 + * @tc.name : Check capture session set focus manual mode with callback + * @tc.desc : Check capture session set focus manual mode with callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0100--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0100 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0100 start for camera[" + i + "]"); + + await startCameraSession(i); + + if (mIsFocusModeSupportedArray[i] == true) { + mCameraSession.setFocusMode(cameraObj.FocusMode.FOCUS_MODE_MANUAL, async (err) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0100 callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0100 PASSED with FocusMode is: " + cameraObj.FocusMode.FOCUS_MODE_MANUAL); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0100 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + mCameraSession.getFocusMode(async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0100 callback"); + if (!err) { + if (data == cameraObj.FocusMode.FOCUS_MODE_MANUAL) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0100 PASSED with FocusMode is: " + data); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0100 FAILED with FocusMode is: " + data); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0100 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0100 not support"); + } + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0100 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0100 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0100 + * @tc.name : Check capture session set focus manual mode with promise + * @tc.desc : Check capture session set focus manual mode with promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0100--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0100 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0100 start for camera[" + i + "]"); + + await startCameraSession(i); + + if (mIsFocusModeSupportedArray[i] == true) { + await mCameraSession.setFocusMode(cameraObj.FocusMode.FOCUS_MODE_MANUAL); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0100 finish"); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0100 PASSED with FocusMode is: " + cameraObj.FocusMode.FOCUS_MODE_MANUAL); + await sleep(500); + + let focusMode = await mCameraSession.getFocusMode(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0100 finish"); + if (focusMode == cameraObj.FocusMode.FOCUS_MODE_MANUAL) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0100 PASSED with FocusMode is: " + focusMode); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0100 FAILED with FocusMode is: " + focusMode); + expect().assertFail(); + } + await sleep(500); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0100 not support"); + } + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0100 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0100 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_CALLBACK_0101 + * @tc.name : Check capture session support focus continuous auto mode with callback or not + * @tc.desc : Check capture session support focus continuous auto mode with callback or not + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_CALLBACK_0101', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_CALLBACK_0101--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_CALLBACK_0101 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_CALLBACK_0101 start for camera[" + i + "]"); + + await startCameraSession(i); + + mIsFocusModeSupportedArray[i] = false; + + mCameraSession.isFocusModeSupported(cameraObj.FocusMode.FOCUS_MODE_CONTINUOUS_AUTO, async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_CALLBACK_0101 callback"); + if (!err) { + if (data != null || data != undefined) { + mIsFocusModeSupportedArray[i] = data; + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_CALLBACK_0101 PASSED with isFocusModeSupported is: " + data); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_CALLBACK_0101 FAILED with isFocusModeSupported is: " + data); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_CALLBACK_0101 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(1000); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_CALLBACK_0101 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_CALLBACK_0101 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0101 + * @tc.name : Check capture session support focus continuous auto mode with promise or not + * @tc.desc : Check capture session support focus continuous auto mode with promise or not + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0101', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0101--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0101 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0101 start for camera[" + i + "]"); + + await startCameraSession(i); + + let isFocusModeSupported = await mCameraSession.isFocusModeSupported(cameraObj.FocusMode.FOCUS_MODE_CONTINUOUS_AUTO); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0101 finish"); + if (isFocusModeSupported != null || isFocusModeSupported != undefined) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0101 PASSED with isFocusModeSupported is: " + isFocusModeSupported); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0101 FAILED with isFocusModeSupported is: " + isFocusModeSupported); + expect().assertFail(); + } + + await sleep(1000); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0101 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0101 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0101 + * @tc.name : Check capture session set focus continuous auto mode with callback + * @tc.desc : Check capture session set focus continuous auto mode with callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0101', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0101--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0101 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0101 start for camera[" + i + "]"); + + await startCameraSession(i); + + if (mIsFocusModeSupportedArray[i] == true) { + mCameraSession.setFocusMode(cameraObj.FocusMode.FOCUS_MODE_CONTINUOUS_AUTO, async (err) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0101 callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0101 PASSED with FocusMode is: " + cameraObj.FocusMode.FOCUS_MODE_CONTINUOUS_AUTO); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0101 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + mCameraSession.getFocusMode(async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0101 callback"); + if (!err) { + if (data == cameraObj.FocusMode.FOCUS_MODE_CONTINUOUS_AUTO) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0101 PASSED with FocusMode is: " + data); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0101 FAILED with FocusMode is: " + data); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0101 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0101 not support"); + } + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0101 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0101 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0101 + * @tc.name : Check capture session set focus continuous auto mode with promise + * @tc.desc : Check capture session set focus continuous auto mode with promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0101', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0101--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0101 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0101 start for camera[" + i + "]"); + + await startCameraSession(i); + + if (mIsFocusModeSupportedArray[i] == true) { + await mCameraSession.setFocusMode(cameraObj.FocusMode.FOCUS_MODE_CONTINUOUS_AUTO); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0101 finish"); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0101 PASSED with FocusMode is: " + cameraObj.FocusMode.FOCUS_MODE_CONTINUOUS_AUTO); + await sleep(500); + + let focusMode = await mCameraSession.getFocusMode(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0101 finish"); + if (focusMode == cameraObj.FocusMode.FOCUS_MODE_CONTINUOUS_AUTO) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0101 PASSED with FocusMode is: " + focusMode); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0101 FAILED with FocusMode is: " + focusMode); + expect().assertFail(); + } + await sleep(500); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0101 not support"); + } + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0101 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0101 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_CALLBACK_0102 + * @tc.name : Check capture session support focus auto mode with callback or not + * @tc.desc : Check capture session support focus auto mode with callback or not + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_CALLBACK_0102', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_CALLBACK_0102--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_CALLBACK_0102 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_CALLBACK_0102 start for camera[" + i + "]"); + + await startCameraSession(i); + + mIsFocusModeSupportedArray[i] = false; + + mCameraSession.isFocusModeSupported(cameraObj.FocusMode.FOCUS_MODE_AUTO, async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_CALLBACK_0102 callback"); + if (!err) { + if (data != null || data != undefined) { + mIsFocusModeSupportedArray[i] = data; + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_CALLBACK_0102 PASSED with isFocusModeSupported is: " + data); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_CALLBACK_0102 FAILED with isFocusModeSupported is: " + data); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_CALLBACK_0102 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(1000); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_CALLBACK_0102 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_CALLBACK_0102 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0102 + * @tc.name : Check capture session support focus auto mode with promise or not + * @tc.desc : Check capture session support focus auto mode with promise or not + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0102', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0102--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0102 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0102 start for camera[" + i + "]"); + + await startCameraSession(i); + + let isFocusModeSupported = await mCameraSession.isFocusModeSupported(cameraObj.FocusMode.FOCUS_MODE_AUTO); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0102 finish"); + if (isFocusModeSupported != null || isFocusModeSupported != undefined) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0102 PASSED with isFocusModeSupported is: " + isFocusModeSupported); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0102 FAILED with isFocusModeSupported is: " + isFocusModeSupported); + expect().assertFail(); + } + + await sleep(1000); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0102 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0102 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0102 + * @tc.name : Check capture session set focus auto mode with callback + * @tc.desc : Check capture session set focus auto mode with callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0102', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0102--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0102 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0102 start for camera[" + i + "]"); + + await startCameraSession(i); + + if (mIsFocusModeSupportedArray[i] == true) { + mCameraSession.setFocusMode(cameraObj.FocusMode.FOCUS_MODE_AUTO, async (err) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0102 callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0102 PASSED with FocusMode is: " + cameraObj.FocusMode.FOCUS_MODE_AUTO); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0102 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + mCameraSession.getFocusMode(async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0102 callback"); + if (!err) { + if (data == cameraObj.FocusMode.FOCUS_MODE_AUTO) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0102 PASSED with FocusMode is: " + data); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0102 FAILED with FocusMode is: " + data); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0102 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0102 not support"); + } + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0102 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0102 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0102 + * @tc.name : Check capture session set focus auto mode with promise + * @tc.desc : Check capture session set focus auto mode with promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0102', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0102--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0102 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0102 start for camera[" + i + "]"); + + await startCameraSession(i); + + if (mIsFocusModeSupportedArray[i] == true) { + await mCameraSession.setFocusMode(cameraObj.FocusMode.FOCUS_MODE_AUTO); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0102 finish"); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0102 PASSED with FocusMode is: " + cameraObj.FocusMode.FOCUS_MODE_AUTO); + await sleep(500); + + let focusMode = await mCameraSession.getFocusMode(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0102 finish"); + if (focusMode == cameraObj.FocusMode.FOCUS_MODE_AUTO) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0102 PASSED with FocusMode is: " + focusMode); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0102 FAILED with FocusMode is: " + focusMode); + expect().assertFail(); + } + await sleep(500); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0102 not support"); + } + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0102 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0102 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_CALLBACK_0103 + * @tc.name : Check capture session support focus locked mode with callback or not + * @tc.desc : Check capture session support focus locked mode with callback or not + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_CALLBACK_0103', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_CALLBACK_0103--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_CALLBACK_0103 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_CALLBACK_0103 start for camera[" + i + "]"); + + await startCameraSession(i); + + mIsFocusModeSupportedArray[i] = false; + + mCameraSession.isFocusModeSupported(cameraObj.FocusMode.FOCUS_MODE_LOCKED, async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_CALLBACK_0103 callback"); + if (!err) { + if (data != null || data != undefined) { + mIsFocusModeSupportedArray[i] = data; + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_CALLBACK_0103 PASSED with isFocusModeSupported is: " + data); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_CALLBACK_0103 FAILED with isFocusModeSupported is: " + data); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_CALLBACK_0103 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(1000); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_CALLBACK_0103 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_CALLBACK_0103 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0103 + * @tc.name : Check capture session support focus locked mode with promise or not + * @tc.desc : Check capture session support focus locked mode with promise or not + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0103', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0103--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0103 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0103 start for camera[" + i + "]"); + + await startCameraSession(i); + + let isFocusModeSupported = await mCameraSession.isFocusModeSupported(cameraObj.FocusMode.FOCUS_MODE_LOCKED); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0103 finish"); + if (isFocusModeSupported != null || isFocusModeSupported != undefined) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0103 PASSED with isFocusModeSupported is: " + isFocusModeSupported); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0103 FAILED with isFocusModeSupported is: " + isFocusModeSupported); + expect().assertFail(); + } + + await sleep(1000); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0103 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0103 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0103 + * @tc.name : Check capture session set focus locked mode with callback + * @tc.desc : Check capture session set focus locked mode with callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0103', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0103--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0103 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0103 start for camera[" + i + "]"); + + await startCameraSession(i); + + if (mIsFocusModeSupportedArray[i] == true) { + mCameraSession.setFocusMode(cameraObj.FocusMode.FOCUS_MODE_LOCKED, async (err) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0103 callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0103 PASSED with FocusMode is: " + cameraObj.FocusMode.FOCUS_MODE_LOCKED); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0103 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + mCameraSession.getFocusMode(async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0103 callback"); + if (!err) { + if (data == cameraObj.FocusMode.FOCUS_MODE_LOCKED) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0103 PASSED with FocusMode is: " + data); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0103 FAILED with FocusMode is: " + data); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0103 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0103 not support"); + } + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0103 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_CALLBACK_0103 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0103 + * @tc.name : Check capture session set focus locked mode with promise + * @tc.desc : Check capture session set focus locked mode with promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0103', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0103--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0103 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0103 start for camera[" + i + "]"); + + await startCameraSession(i); + + if (mIsFocusModeSupportedArray[i] == true) { + await mCameraSession.setFocusMode(cameraObj.FocusMode.FOCUS_MODE_LOCKED); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0103 finish"); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0103 PASSED with FocusMode is: " + cameraObj.FocusMode.FOCUS_MODE_LOCKED); + await sleep(500); + + let focusMode = await mCameraSession.getFocusMode(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0103 finish"); + if (focusMode == cameraObj.FocusMode.FOCUS_MODE_LOCKED) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0103 PASSED with FocusMode is: " + focusMode); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0103 FAILED with FocusMode is: " + focusMode); + expect().assertFail(); + } + await sleep(1000); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0103 not support"); + } + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0103 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0103 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0100 + * @tc.name : Check capture session set focus point with callback + * @tc.desc : Check capture session set focus point with callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0100--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0100 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0100 start for camera[" + i + "]"); + + await startCameraSession(i); + + mCameraSession.setFocusPoint(mFocusPoint, async (err) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0100 callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0100 PASSED with FocusPoint is: " + mFocusPoint.x + ", " + mFocusPoint.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0100 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + mCameraSession.getFocusPoint(async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0100 callback"); + if (!err) { + if ((data.x == mFocusPoint.x) && (data.y == mFocusPoint.y)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0100 PASSED with FocusPoint is: " + data.x + ", " + data.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0100 FAILED with FocusPoint is: " + data.x + ", " + data.y); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0100 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0100 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0100 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0100 + * @tc.name : Check capture session set focus point with promise + * @tc.desc : Check capture session set focus point with promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0100--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0100 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0100 start for camera[" + i + "]"); + + await startCameraSession(i); + + await mCameraSession.setFocusPoint(mFocusPoint); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0100 finish"); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0100 PASSED with FocusPoint is: " + mFocusPoint.x + ", " + mFocusPoint.y); + await sleep(500); + + let focusPoint = await mCameraSession.getFocusPoint(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0100 finish"); + if ((focusPoint.x == mFocusPoint.x) && (focusPoint.y == mFocusPoint.y)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0100 PASSED with FocusPoint is: " + focusPoint.x + ", " + focusPoint.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0100 FAILED with FocusPoint is: " + focusPoint.x + ", " + focusPoint.y); + expect().assertFail(); + } + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0100 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0100 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0101 + * @tc.name : Check capture session set focus point with callback(left-top point) + * @tc.desc : Check capture session set focus point with callback(left-top point) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0101', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0101--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0101 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0101 start for camera[" + i + "]"); + + await startCameraSession(i); + + mCameraSession.setFocusPoint(mFocusPointLT, async (err) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0101 callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0101 PASSED with FocusPoint is: " + mFocusPointLT.x + ", " + mFocusPointLT.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0101 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + mCameraSession.getFocusPoint(async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0101 callback"); + if (!err) { + if ((data.x == mFocusPointLT.x) && (data.y == mFocusPointLT.y)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0101 PASSED with FocusPoint is: " + data.x + ", " + data.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0101 FAILED with FocusPoint is: " + data.x + ", " + data.y); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0101 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0101 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0101 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0101 + * @tc.name : Check capture session set focus point with promise(left-top point) + * @tc.desc : Check capture session set focus point with promise(left-top point) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0101', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0101--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0101 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0101 start for camera[" + i + "]"); + + await startCameraSession(i); + + await mCameraSession.setFocusPoint(mFocusPointLT); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0101 finish"); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0101 PASSED with FocusPoint is: " + mFocusPointLT.x + ", " + mFocusPointLT.y); + await sleep(500); + + let focusPoint = await mCameraSession.getFocusPoint(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0101 finish"); + if ((focusPoint.x == mFocusPointLT.x) && (focusPoint.y == mFocusPointLT.y)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0101 PASSED with FocusPoint is: " + focusPoint.x + ", " + focusPoint.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0101 FAILED with FocusPoint is: " + focusPoint.x + ", " + focusPoint.y); + expect().assertFail(); + } + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0101 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0101 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0102 + * @tc.name : Check capture session set focus point with callback(right-top point) + * @tc.desc : Check capture session set focus point with callback(right-top point) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0102', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0102--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0102 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0102 start for camera[" + i + "]"); + + await startCameraSession(i); + + mCameraSession.setFocusPoint(mFocusPointRT, async (err) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0102 callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0102 PASSED with FocusPoint is: " + mFocusPointRT.x + ", " + mFocusPointRT.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0102 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + mCameraSession.getFocusPoint(async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0102 callback"); + if (!err) { + if ((data.x == mFocusPointRT.x) && (data.y == mFocusPointRT.y)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0102 PASSED with FocusPoint is: " + data.x + ", " + data.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0102 FAILED with FocusPoint is: " + data.x + ", " + data.y); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0102 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0102 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0102 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0102 + * @tc.name : Check capture session set focus point with promise(right-top point) + * @tc.desc : Check capture session set focus point with promise(right-top point) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0102', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0102--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0102 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0102 start for camera[" + i + "]"); + + await startCameraSession(i); + + await mCameraSession.setFocusPoint(mFocusPointRT); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0102 finish"); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0102 PASSED with FocusPoint is: " + mFocusPointRT.x + ", " + mFocusPointRT.y); + await sleep(500); + + let focusPoint = await mCameraSession.getFocusPoint(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0102 finish"); + if ((focusPoint.x == mFocusPointRT.x) && (focusPoint.y == mFocusPointRT.y)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0102 PASSED with FocusPoint is: " + focusPoint.x + ", " + focusPoint.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0102 FAILED with FocusPoint is: " + focusPoint.x + ", " + focusPoint.y); + expect().assertFail(); + } + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0102 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0102 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0103 + * @tc.name : Check capture session set focus point with callback(left-bottom point) + * @tc.desc : Check capture session set focus point with callback(left-bottom point) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0103', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0103--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0103 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0103 start for camera[" + i + "]"); + + await startCameraSession(i); + + mCameraSession.setFocusPoint(mFocusPointLB, async (err) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0103 callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0103 PASSED with FocusPoint is: " + mFocusPointLB.x + ", " + mFocusPointLB.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0103 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + mCameraSession.getFocusPoint(async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0103 callback"); + if (!err) { + if ((data.x == mFocusPointLB.x) && (data.y == mFocusPointLB.y)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0103 PASSED with FocusPoint is: " + data.x + ", " + data.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0103 FAILED with FocusPoint is: " + data.x + ", " + data.y); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0103 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0103 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0103 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0103 + * @tc.name : Check capture session set focus point with promise(left-bottom point) + * @tc.desc : Check capture session set focus point with promise(left-bottom point) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0103', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0103--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0103 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0103 start for camera[" + i + "]"); + + await startCameraSession(i); + + await mCameraSession.setFocusPoint(mFocusPointLB); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0103 finish"); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0103 PASSED with FocusPoint is: " + mFocusPointLB.x + ", " + mFocusPointLB.y); + await sleep(500); + + let focusPoint = await mCameraSession.getFocusPoint(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0103 finish"); + if ((focusPoint.x == mFocusPointLB.x) && (focusPoint.y == mFocusPointLB.y)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0103 PASSED with FocusPoint is: " + focusPoint.x + ", " + focusPoint.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0103 FAILED with FocusPoint is: " + focusPoint.x + ", " + focusPoint.y); + expect().assertFail(); + } + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0103 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0103 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0104 + * @tc.name : Check capture session set focus point with callback(right-bottom point) + * @tc.desc : Check capture session set focus point with callback(right-bottom point) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0104', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0104--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0104 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0104 start for camera[" + i + "]"); + + await startCameraSession(i); + + mCameraSession.setFocusPoint(mFocusPointRB, async (err) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0104 callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0104 PASSED with FocusPoint is: " + mFocusPointRB.x + ", " + mFocusPointRB.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0104 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + mCameraSession.getFocusPoint(async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0104 callback"); + if (!err) { + if ((data.x == mFocusPointRB.x) && (data.y == mFocusPointRB.y)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0104 PASSED with FocusPoint is: " + data.x + ", " + data.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0104 FAILED with FocusPoint is: " + data.x + ", " + data.y); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0104 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0104 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0104 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0104 + * @tc.name : Check capture session set focus point with promise(right-bottom point) + * @tc.desc : Check capture session set focus point with promise(right-bottom point) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0104', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0104--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0104 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0104 start for camera[" + i + "]"); + + await startCameraSession(i); + + await mCameraSession.setFocusPoint(mFocusPointRB); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0104 finish"); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0104 PASSED with FocusPoint is: " + mFocusPointRB.x + ", " + mFocusPointRB.y); + await sleep(500); + + let focusPoint = await mCameraSession.getFocusPoint(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0104 finish"); + if ((focusPoint.x == mFocusPointRB.x) && (focusPoint.y == mFocusPointRB.y)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0104 PASSED with FocusPoint is: " + focusPoint.x + ", " + focusPoint.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0104 FAILED with FocusPoint is: " + focusPoint.x + ", " + focusPoint.y); + expect().assertFail(); + } + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0104 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0104 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0105 + * @tc.name : Check capture session set focus point with callback(left-top invalid point) + * @tc.desc : Check capture session set focus point with callback(left-top invalid point) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0105', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0105--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0105 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0105 start for camera[" + i + "]"); + + await startCameraSession(i); + + mCameraSession.setFocusPoint(mFocusPointInvalidLT, async (err) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0105 callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0105 PASSED with FocusPoint is: " + mFocusPointInvalidLT.x + ", " + mFocusPointInvalidLT.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0105 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + mCameraSession.getFocusPoint(async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0105 callback"); + if (!err) { + if (((data.x != mFocusPointInvalidLT.x) && (data.y != mFocusPointInvalidLT.y)) || (mEnableCheckInvalidFocusPoint == false)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0105 PASSED with FocusPoint is: " + data.x + ", " + data.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0105 FAILED with FocusPoint is: " + data.x + ", " + data.y); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0105 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0105 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0105 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0105 + * @tc.name : Check capture session set focus point with promise(left-top invalid point) + * @tc.desc : Check capture session set focus point with promise(left-top invalid point) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0105', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0105--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0105 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0105 start for camera[" + i + "]"); + + await startCameraSession(i); + + await mCameraSession.setFocusPoint(mFocusPointInvalidLT); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0105 finish"); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0105 PASSED with FocusPoint is: " + mFocusPointInvalidLT.x + ", " + mFocusPointInvalidLT.y); + await sleep(500); + + let focusPoint = await mCameraSession.getFocusPoint(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0105 finish"); + if (((focusPoint.x != mFocusPointInvalidLT.x) && (focusPoint.y != mFocusPointInvalidLT.y)) || (mEnableCheckInvalidFocusPoint == false)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0105 PASSED with FocusPoint is: " + focusPoint.x + ", " + focusPoint.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0105 FAILED with FocusPoint is: " + focusPoint.x + ", " + focusPoint.y); + expect().assertFail(); + } + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0105 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0105 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0106 + * @tc.name : Check capture session set focus point with callback(right-top invalid point) + * @tc.desc : Check capture session set focus point with callback(right-top invalid point) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0106', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0106--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0106 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0106 start for camera[" + i + "]"); + + await startCameraSession(i); + + mCameraSession.setFocusPoint(mFocusPointInvalidRT, async (err) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0106 callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0106 PASSED with FocusPoint is: " + mFocusPointInvalidRT.x + ", " + mFocusPointInvalidRT.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0106 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + mCameraSession.getFocusPoint(async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0106 callback"); + if (!err) { + if (((data.x != mFocusPointInvalidRT.x) && (data.y != mFocusPointInvalidRT.y)) || (mEnableCheckInvalidFocusPoint == false)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0106 PASSED with FocusPoint is: " + data.x + ", " + data.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0106 FAILED with FocusPoint is: " + data.x + ", " + data.y); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0106 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0106 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0106 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0106 + * @tc.name : Check capture session set focus point with promise(right-top invalid point) + * @tc.desc : Check capture session set focus point with promise(right-top invalid point) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0106', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0106--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0106 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0106 start for camera[" + i + "]"); + + await startCameraSession(i); + + await mCameraSession.setFocusPoint(mFocusPointInvalidRT); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0106 finish"); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0106 PASSED with FocusPoint is: " + mFocusPointInvalidRT.x + ", " + mFocusPointInvalidRT.y); + await sleep(500); + + let focusPoint = await mCameraSession.getFocusPoint(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0106 finish"); + if (((focusPoint.x != mFocusPointInvalidRT.x) && (focusPoint.y != mFocusPointInvalidRT.y)) || (mEnableCheckInvalidFocusPoint == false)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0106 PASSED with FocusPoint is: " + focusPoint.x + ", " + focusPoint.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0106 FAILED with FocusPoint is: " + focusPoint.x + ", " + focusPoint.y); + expect().assertFail(); + } + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0106 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0106 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0107 + * @tc.name : Check capture session set focus point with callback(left-bottom invalid point) + * @tc.desc : Check capture session set focus point with callback(left-bottom invalid point) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0107', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0107--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0107 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0107 start for camera[" + i + "]"); + + await startCameraSession(i); + + mCameraSession.setFocusPoint(mFocusPointInvalidLB, async (err) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0107 callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0107 PASSED with FocusPoint is: " + mFocusPointInvalidLB.x + ", " + mFocusPointInvalidLB.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0107 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + mCameraSession.getFocusPoint(async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0107 callback"); + if (!err) { + if (((data.x != mFocusPointInvalidLB.x) && (data.y != mFocusPointInvalidLB.y)) || (mEnableCheckInvalidFocusPoint == false)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0107 PASSED with FocusPoint is: " + data.x + ", " + data.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0107 FAILED with FocusPoint is: " + data.x + ", " + data.y); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0107 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0107 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0107 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0107 + * @tc.name : Check capture session set focus point with promise(left-bottom invalid point) + * @tc.desc : Check capture session set focus point with promise(left-bottom invalid point) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0107', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0107--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0107 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0107 start for camera[" + i + "]"); + + await startCameraSession(i); + + await mCameraSession.setFocusPoint(mFocusPointInvalidLB); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0107 finish"); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0107 PASSED with FocusPoint is: " + mFocusPointInvalidLB.x + ", " + mFocusPointInvalidLB.y); + await sleep(500); + + let focusPoint = await mCameraSession.getFocusPoint(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0107 finish"); + if (((focusPoint.x != mFocusPointInvalidLB.x) && (focusPoint.y != mFocusPointInvalidLB.y)) || (mEnableCheckInvalidFocusPoint == false)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0107 PASSED with FocusPoint is: " + focusPoint.x + ", " + focusPoint.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0107 FAILED with FocusPoint is: " + focusPoint.x + ", " + focusPoint.y); + expect().assertFail(); + } + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0107 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0107 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0108 + * @tc.name : Check capture session set focus point with callback(right-bottom invalid point) + * @tc.desc : Check capture session set focus point with callback(right-bottom invalid point) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0108', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0108--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0108 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0108 start for camera[" + i + "]"); + + await startCameraSession(i); + + mCameraSession.setFocusPoint(mFocusPointInvalidRB, async (err) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0108 callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0108 PASSED with FocusPoint is: " + mFocusPointInvalidRB.x + ", " + mFocusPointInvalidRB.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0108 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + mCameraSession.getFocusPoint(async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0108 callback"); + if (!err) { + if (((data.x != mFocusPointInvalidRB.x) && (data.y != mFocusPointInvalidRB.y)) || (mEnableCheckInvalidFocusPoint == false)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0108 PASSED with FocusPoint is: " + data.x + ", " + data.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0108 FAILED with FocusPoint is: " + data.x + ", " + data.y); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0108 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0108 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_CALLBACK_0108 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0108 + * @tc.name : Check capture session set focus point with promise(right-bottom invalid point) + * @tc.desc : Check capture session set focus point with promise(right-bottom invalid point) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0108', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0108--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0108 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0108 start for camera[" + i + "]"); + + await startCameraSession(i); + + await mCameraSession.setFocusPoint(mFocusPointInvalidRB); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0108 finish"); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0108 PASSED with FocusPoint is: " + mFocusPointInvalidRB.x + ", " + mFocusPointInvalidRB.y); + await sleep(500); + + let focusPoint = await mCameraSession.getFocusPoint(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0108 finish"); + if (((focusPoint.x != mFocusPointInvalidRB.x) && (focusPoint.y != mFocusPointInvalidRB.y)) || (mEnableCheckInvalidFocusPoint == false)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0108 PASSED with FocusPoint is: " + focusPoint.x + ", " + focusPoint.y); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0108 FAILED with FocusPoint is: " + focusPoint.x + ", " + focusPoint.y); + expect().assertFail(); + } + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0108 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0108 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_GET_FOCAL_LENGTH_CALLBACK_0100 + * @tc.name : Check capture session get focal length with callback + * @tc.desc : Check capture session get focal length with callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_GET_FOCAL_LENGTH_CALLBACK_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_GET_FOCAL_LENGTH_CALLBACK_0100--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_GET_FOCAL_LENGTH_CALLBACK_0100 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_GET_FOCAL_LENGTH_CALLBACK_0100 start for camera[" + i + "]"); + + await startCameraSession(i); + + mCameraSession.getFocalLength(async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_GET_FOCAL_LENGTH_CALLBACK_0100 callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_GET_FOCAL_LENGTH_CALLBACK_0100 PASSED with FocalLength is: " + data); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_GET_FOCAL_LENGTH_CALLBACK_0100 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(1000); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_GET_FOCAL_LENGTH_CALLBACK_0100 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_GET_FOCAL_LENGTH_CALLBACK_0100 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_GET_FOCAL_LENGTH_PROMISE_0100 + * @tc.name : Check capture session get focal length with promise + * @tc.desc : Check capture session get focal length with promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_GET_FOCAL_LENGTH_PROMISE_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_GET_FOCAL_LENGTH_PROMISE_0100--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_GET_FOCAL_LENGTH_PROMISE_0100 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_GET_FOCAL_LENGTH_PROMISE_0100 start for camera[" + i + "]"); + + await startCameraSession(i); + + let focalLength = await mCameraSession.getFocalLength(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_GET_FOCAL_LENGTH_PROMISE_0100 finish"); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_GET_FOCAL_LENGTH_PROMISE_0100 PASSED with FocalLength is: " + focalLength); + + await sleep(1000); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_GET_FOCAL_LENGTH_PROMISE_0100 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_GET_FOCAL_LENGTH_PROMISE_0100 ends here"); + done(); + } + }) + + }) +} \ No newline at end of file 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 new file mode 100755 index 0000000000000000000000000000000000000000..6f1fe08971abb93d966ca0a544689fa68ee3fdb6 --- /dev/null +++ b/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraSessionVideoStabilizationTest.test.ets @@ -0,0 +1,1705 @@ +/* + * 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. + */ + +// @ts-ignore + +import cameraObj from '@ohos.multimedia.camera'; +import image from '@ohos.multimedia.image'; +import media from '@ohos.multimedia.media' +import mediaLibrary from '@ohos.multimedia.mediaLibrary' +import fileio from '@ohos.fileio'; +import abilityAccessCtrl from '@ohos.abilityAccessCtrl' +import bundle from '@ohos.bundle' +import deviceInfo from '@ohos.deviceInfo'; +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'; + +const TAG = "CameraModuleTest: "; + +// Define global letiables +let mCameraManager; +let mCameraDevicesArray; +let mCameraSession; + +let mPhoteSurface; +let mVideoRecorder; +let mVideoSurface; +let mFileAsset; +let mFdPath; +let mFdNumber; + +// CAMERA-0 letiables +let mCameraInputArray; +let mPreviewOutputArray; +let mPhotoOutputArray; +let mVideoOutputArray; + +let mIsVideoStabilizationModeSupportedArray; + +let mVideoProfileCfg = { + audioBitrate: 48000, + audioChannels: 2, + audioCodec: 'audio/mp4a-latm', + audioSampleRate: 48000, + durationTime: 1000, + fileFormat: 'mp4', + videoBitrate: 48000, + videoCodec: 'video/mp4v-es', + videoFrameWidth: 640, + videoFrameHeight: 480, + videoFrameRate: 30 +} + +let mVideoConfig = { + audioSourceType: 1, + videoSourceType: 0, + profile: mVideoProfileCfg, + url: 'file:///data/media/CameraSessionVideoStabilization.mp4', + orientationHint: 0, + location: { latitude: 30, longitude: 130 }, + maxSize: 100, + maxDuration: 500 +} + +let mPicWidthMax = 8192; +let mPicHeightMax = 8192; + +export default function cameraSessionVideoStabilizationTest(surfaceId: any) { + + function sleep(ms) { + console.info(TAG + "Entering sleep -> Promise constructor"); + return new Promise(resolve => setTimeout(resolve, ms)); + } + + function isEmpty(data) { + if (data == null || data == undefined) { + return true; + } + return false; + } + + async function getFd(pathName){ + let displayName = pathName; + const mediaTest = mediaLibrary.getMediaLibrary(); + let fileKeyObj = mediaLibrary.FileKey; + let mediaType = mediaLibrary.MediaType.VIDEO; + let publicPath = await mediaTest.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO); + let dataUri = await mediaTest.createAsset(mediaType, displayName, publicPath); + if (dataUri != undefined) { + let args = dataUri.id.toString(); + let fetchOp = { + selections: fileKeyObj.ID + "=?", + selectionArgs: [args], + } + let fetchFileResult = await mediaTest.getFileAssets(fetchOp); + mFileAsset = await fetchFileResult.getAllObject(); + mFdNumber = await mFileAsset[0].open('Rw'); + mFdPath = "fd://" + mFdNumber.toString(); + } + } + + async function closeFd() { + if (mFileAsset != null) { + await mFileAsset[0].close(mFdNumber).then(() => { + console.info('[mediaLibrary] case close fd success'); + }).catch((err) => { + console.info('[mediaLibrary] case close fd failed'); + }); + } else { + console.info('[mediaLibrary] case fileAsset is null'); + } + } + + async function applyPermission() { + let appInfo = await bundle.getApplicationInfo('com.open.harmony.multimedia.cameratest', 0, 100); + let atManager = abilityAccessCtrl.createAtManager(); + if (atManager != null) { + let tokenID = appInfo.accessTokenId; + console.info('[permission] case accessTokenID is ' + tokenID); + let permissionName1 = 'ohos.permission.CAMERA'; + let permissionName2 = 'ohos.permission.MICROPHONE'; + let permissionName3 = 'ohos.permission.MEDIA_LOCATION'; + let permissionName4 = 'ohos.permission.READ_MEDIA'; + let permissionName5 = 'ohos.permission.WRITE_MEDIA'; + await atManager.grantUserGrantedPermission(tokenID, permissionName1, 1).then((result) => { + console.info('[permission] case grantUserGrantedPermission success :' + result); + }).catch((err) => { + console.info('[permission] case grantUserGrantedPermission failed :' + err); + }); + await atManager.grantUserGrantedPermission(tokenID, permissionName2, 1).then((result) => { + console.info('[permission] case grantUserGrantedPermission success :' + result); + }).catch((err) => { + console.info('[permission] case grantUserGrantedPermission failed :' + err); + }); + await atManager.grantUserGrantedPermission(tokenID, permissionName3, 1).then((result) => { + console.info('[permission] case grantUserGrantedPermission success :' + result); + }).catch((err) => { + console.info('[permission] case grantUserGrantedPermission failed :' + err); + }); + await atManager.grantUserGrantedPermission(tokenID, permissionName4, 1).then((result) => { + console.info('[permission] case grantUserGrantedPermission success :' + result); + }).catch((err) => { + console.info('[permission] case grantUserGrantedPermission failed :' + err); + }); + await atManager.grantUserGrantedPermission(tokenID, permissionName5, 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 getPhotoReceiverSurface() { + console.log(TAG + 'Entering getPhotoReceiverSurface') + let receiver = image.createImageReceiver(640, 480, 4, 8) + 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)) + } else { + console.log(TAG + 'Photo receiver is created failed') + } + console.log(TAG + 'Exit getPhotoReceiverSurface') + } + + async function getVideoReceiveSurface() { + console.log(TAG + 'Entering getVideoReceiveSurface') + await getFd('CameraSessionVideoStabilization.mp4'); + mVideoConfig.url = mFdPath; + media.createVideoRecorder((err, recorder) => { + console.info(TAG + 'Entering create video receiver') + mVideoRecorder = recorder + console.info(TAG + 'videoRecorder is :' + JSON.stringify(mVideoRecorder)) + console.info(TAG + 'videoRecorder.prepare called.') + mVideoRecorder.prepare(mVideoConfig, (err) => { + console.info(TAG + 'videoRecorder.prepare success.') + }) + mVideoRecorder.getInputSurface((err, id) => { + console.info(TAG + 'getInputSurface called') + mVideoSurface = id + console.info(TAG + 'getInputSurface surfaceId: ' + JSON.stringify(mVideoSurface)) + }) + }) + console.log(TAG + 'Exit getVideoReceiveSurface') + } + + async function releaseVideoReceiveSurface() { + console.log(TAG + 'Entering releaseVideoReceiveSurface') + mVideoRecorder.release((err) => { + console.info(TAG + 'Entering release video receiver') + }) + await closeFd(); + + await sleep(100); + console.log(TAG + 'Exit releaseVideoReceiveSurface') + } + + async function getCameraManagerInstance() { + console.info('Enter getCameraManagerInstance'); + + mCameraManager = await cameraObj.getCameraManager(null); + if (isEmpty(mCameraManager)) { + 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 + "getCameraSupportDevicesArray is: " + mCameraDevicesArray.length); + 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 createInputs() { + console.info('Enter createInputs'); + + if (isEmpty(mCameraDevicesArray)) { + console.info(TAG + "Entering createInputs FAILED with NoCamera"); + return false; + } + + mCameraInputArray = new Array(mCameraDevicesArray.length); + mIsVideoStabilizationModeSupportedArray = new Array(mCameraDevicesArray.length); + + for (let i = 0; i < mCameraDevicesArray.length; i++) { + mCameraInputArray[i] = await mCameraManager.createCameraInput(mCameraDevicesArray[i]); + if (isEmpty(mCameraInputArray[i])) { + console.info(TAG + "createCameraInput FAILED"); + return false; + } + + mCameraInputArray[i].open(async (err) => { + console.info(TAG + "Entering mCameraInputArray open callback"); + if (!err) { + console.info(TAG + "Entering mCameraInputArray open PASSED "); + } else { + console.info(TAG + "Entering mCameraInputArray open FAILED : " + err.message); + } + }) + + await sleep(2000); + + console.info(i + 'th CameraInput is: ' + mCameraInputArray[i]); + } + + console.info('Exit createInputs'); + + return true; + } + + async function releaseInputs() { + console.info('Enter releaseInputs'); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering releaseInputs FAILED with NoCamera"); + return true; + } + + for (let i = 0; i < mCameraInputArray.length; i++) { + await mCameraInputArray[i].close(); + await mCameraInputArray[i].release(); + } + + console.info('Exit releaseInputs'); + + return true; + } + + async function createOutputs() { + console.info('Enter createOutputs'); + + mPreviewOutputArray = new Array(mCameraDevicesArray.length); + mPhotoOutputArray = new Array(mCameraDevicesArray.length); + mVideoOutputArray = new Array(mCameraDevicesArray.length); + + for (let i = 0; i < mCameraDevicesArray.length; i++) { + let cameraOutputCap = await mCameraManager.getSupportedOutputCapability(mCameraDevicesArray[i]); + if (!isEmpty(cameraOutputCap.previewProfiles)) { + console.info(TAG + "cameraOutputCap.previewProfiles.length: " + cameraOutputCap.previewProfiles.length); + for (let j = 0; j < cameraOutputCap.previewProfiles.length; j++) { + mPreviewOutputArray[i] = await mCameraManager.createPreviewOutput(cameraOutputCap.previewProfiles[j], surfaceId); + if (!isEmpty(mPreviewOutputArray[i])) { + break; + } + } + + if (isEmpty(mPreviewOutputArray[i])) { + console.info(TAG + "createPreviewOutput FAILED"); + } + } + + /* + if (!isEmpty(cameraOutputCap.photoProfiles)) { + console.info(TAG + "cameraOutputCap.photoProfiles.length: " + cameraOutputCap.photoProfiles.length); + + for (let j = 0; j < cameraOutputCap.photoProfiles.length; j++) { + mPhotoOutputArray[i] = await mCameraManager.createPhotoOutput(cameraOutputCap.photoProfiles[j], mPhoteSurface); + if (!isEmpty(mPhotoOutputArray[i])) { + break; + } + } + + if (isEmpty(mPhotoOutputArray[i])) { + console.info(TAG + "createPhotoOutput FAILED"); + } + + console.info(TAG + "createPhotoOutput: " + mPhotoOutputArray[i]); + } + + if (!isEmpty(cameraOutputCap.videoProfiles)) { + console.info(TAG + "cameraOutputCap.videoProfiles.length: " + cameraOutputCap.videoProfiles.length); + for (let j = 0; j < cameraOutputCap.videoProfiles.length; j++) { + mVideoOutputArray[i] = await mCameraManager.createVideoOutput(cameraOutputCap.videoProfiles[j], mVideoSurface); + if (!isEmpty(mVideoOutputArray[i])) { + break; + } + } + + if (isEmpty(mVideoOutputArray[i])) { + console.info(TAG + "createVideoOutput FAILED"); + } + + console.info(TAG + "createVideoOutput: " + mPhotoOutputArray[i]); + } + */ + } + + console.info('Exit createOutputs'); + + return true; + } + + async function releaseOutputs() { + for (let i = 0; i < mCameraDevicesArray.length; i++) { + if (!isEmpty(mPreviewOutputArray[i])) { + await mPreviewOutputArray[i].close(); + await mPreviewOutputArray[i].release(); + } + + /* + if (!isEmpty(mPhotoOutputArray[i])) { + await mPhotoOutputArray[i].close(); + await mPhotoOutputArray[i].release(); + } + + if (!isEmpty(mVideoOutputArray[i])) { + await mVideoOutputArray[i].close(); + await mVideoOutputArray[i].release(); + } + */ + } + + return true; + } + + async function startCameraSession(idx:any) { + console.info(TAG + "Enter startCameraSession"); + + if (!isEmpty(mCameraInputArray[idx])) { + console.info(TAG + "Start to addInput"); + await mCameraSession.addInput(mCameraInputArray[idx]); + } + + if (!isEmpty(mPreviewOutputArray[idx])) { + console.info(TAG + "Start to addOutput mPreviewOutput"); + await mCameraSession.addOutput(mPreviewOutputArray[idx]); + } + + /* + if (!isEmpty(mPhotoOutputArray[idx])) { + console.info(TAG + "Start to addOutput mPhotoOutput"); + await mCameraSession.addOutput(mPhotoOutputArray[idx]); + } + + if (!isEmpty(mVideoOutputArray[idx])) { + console.info(TAG + "Start to addOutput mVideoOutput"); + await mCameraSession.addOutput(mVideoOutputArray[idx]); + } + */ + + await commitCameraSessionConfig(); + await beginCameraSessionConfig(); + + /* + await mCameraSession.start(async (err) => { + console.info(TAG + "Entering mCameraSession start callback"); + if (!err) { + console.info(TAG + "Entering mCameraSession start PASSED "); + } else { + console.info(TAG + "Entering mCameraSession start FAILED : " + err.message); + } + }) + + await sleep(1000); + */ + console.info(TAG + "Exit startCameraSession"); + + return true; + } + + async function stopCameraSession(idx:any) { + console.info(TAG + "Enter stopCameraSession"); + /* + mCameraSession.stop(async (err) => { + console.info(TAG + "Entering mCameraSession stop callback"); + if (!err) { + console.info(TAG + "Entering mCameraSession stop PASSED "); + } else { + console.info(TAG + "Entering mCameraSession stop FAILED : " + err.message); + } + }) + + await sleep(1000); + */ + + if (!isEmpty(mCameraInputArray[idx])) { + console.info(TAG + "Start to removeInput input"); + await mCameraSession.removeInput(mCameraInputArray[idx]); + } + + if (!isEmpty(mPreviewOutputArray[idx])) { + console.info(TAG + "Start to removeOutput mPreviewOutput"); + await mCameraSession.removeOutput(mPreviewOutputArray[idx]); + } + + /* + if (!isEmpty(mPhotoOutputArray[idx])) { + console.info(TAG + "Start to removeOutput mPhotoOutput"); + await mCameraSession.removeOutput(mPhotoOutputArray[idx]); + } + + if (!isEmpty(mVideoOutputArray[idx])) { + console.info(TAG + "Start to removeOutput mVideoOutput"); + await mCameraSession.removeOutput(mVideoOutputArray[idx]); + } + */ + + console.info(TAG + "Exit stopCameraSession"); + + return true; + } + + describe('cameraSessionVideoStabilizationTest', function () { + console.info(TAG + '----------cameraSessionVideoStabilizationTest--------------') + + beforeAll(async function () { + sleep(100); + await applyPermission(); + await getPhotoReceiverSurface(); + await getVideoReceiveSurface(); + await getCameraManagerInstance(); + await getCameraSupportDevicesArray(); + await createCameraSessionInstance(); + await createInputs(); + await createOutputs(); + + console.info('Device type = ' + deviceInfo.deviceType); + + console.info('beforeAll case'); + }) + + beforeEach(function () { + sleep(5000); + console.info('beforeEach case'); + }) + + afterEach(async function () { + console.info('afterEach case'); + }) + + afterAll(function () { + releaseInputs(); + releaseOutputs(); + releaseVideoReceiveSurface(); + releaseCameraSessionInstance(); + sleep(1000); + console.info('afterAll case'); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0100 + * @tc.name : Check capture session support video stabilization off mode with callback or not + * @tc.desc : Check capture session support video stabilization off mode with callback or not + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0100--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0100 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0100 start for camera[" + i + "]"); + + await startCameraSession(i); + + mIsVideoStabilizationModeSupportedArray[i] = false; + + mCameraSession.isVideoStabilizationModeSupported(cameraObj.VideoStabilizationMode.OFF, async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0100 callback"); + if (!err) { + if (data != null || data != undefined) { + mIsVideoStabilizationModeSupportedArray[i] = data; + if ((deviceInfo.deviceType != 'default') && (data == false)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0100 FAILED with isVideoStabilizationModeSupported is: " + data); + expect().assertFail(); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0100 PASSED with isVideoStabilizationModeSupported is: " + data); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0100 FAILED with isVideoStabilizationModeSupported is: " + data); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0100 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(1000); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0100 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0100 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0100 + * @tc.name : Check capture session support video stabilization off mode with promise or not + * @tc.desc : Check capture session support video stabilization off mode with promise or not + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0100--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0100 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0100 start for camera[" + i + "]"); + + await startCameraSession(i); + + let isVideoStabilizationModeSupported = await mCameraSession.isVideoStabilizationModeSupported(cameraObj.VideoStabilizationMode.OFF); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0100 finish"); + if (isVideoStabilizationModeSupported != null || isVideoStabilizationModeSupported != undefined) { + if ((deviceInfo.deviceType != 'default') && (isVideoStabilizationModeSupported == false)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0100 FAILED with isVideoStabilizationModeSupported is: " + isVideoStabilizationModeSupported); + expect().assertFail(); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0100 PASSED with isVideoStabilizationModeSupported is: " + isVideoStabilizationModeSupported); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0100 FAILED with isVideoStabilizationModeSupported is: " + isVideoStabilizationModeSupported); + expect().assertFail(); + } + + await sleep(1000); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0100 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0100 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0100 + * @tc.name : Check capture session set video stabilization off mode with callback + * @tc.desc : Check capture session set video stabilization off mode with callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0100--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0100 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0100 start for camera[" + i + "]"); + + await startCameraSession(i); + + if (mIsVideoStabilizationModeSupportedArray[i] == true) { + mCameraSession.setVideoStabilizationMode(cameraObj.VideoStabilizationMode.OFF, async (err) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0100 callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0100 PASSED with VideoStabilizationMode is: " + cameraObj.VideoStabilizationMode.OFF); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0100 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + mCameraSession.getActiveVideoStabilizationMode(async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0100 callback"); + if (!err) { + if (data == cameraObj.VideoStabilizationMode.OFF) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0100 PASSED with VideoStabilizationMode is: " + data); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0100 FAILED with VideoStabilizationMode is: " + data); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0100 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + } else { + if (deviceInfo.deviceType != 'default') { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0100 FAILED"); + expect().assertFail(); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0100 PASSED"); + } + } + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0100 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0100 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0100 + * @tc.name : Check capture session set video stabilization off mode with promise + * @tc.desc : Check capture session set video stabilization off mode with promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0100--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0100 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0100 start for camera[" + i + "]"); + + await startCameraSession(i); + + if (mIsVideoStabilizationModeSupportedArray[i] == true) { + await mCameraSession.setVideoStabilizationMode(cameraObj.VideoStabilizationMode.OFF); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0100 finish"); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0100 PASSED with VideoStabilizationMode is: " + cameraObj.VideoStabilizationMode.OFF); + await sleep(500); + + let vdeoStabilizationMode = await mCameraSession.getActiveVideoStabilizationMode(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0100 finish"); + if (vdeoStabilizationMode == cameraObj.VideoStabilizationMode.OFF) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0100 PASSED with VideoStabilizationMode is: " + vdeoStabilizationMode); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0100 FAILED with VideoStabilizationMode is: " + vdeoStabilizationMode); + expect().assertFail(); + } + await sleep(500); + } else { + if (deviceInfo.deviceType != 'default') { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0100 FAILED"); + expect().assertFail(); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0100 PASSED"); + } + } + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0100 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0100 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0101 + * @tc.name : Check capture session support video stabilization low mode with callback or not + * @tc.desc : Check capture session support video stabilization low mode with callback or not + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0101', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0101--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0101 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0101 start for camera[" + i + "]"); + + await startCameraSession(i); + + mIsVideoStabilizationModeSupportedArray[i] = false; + + mCameraSession.isVideoStabilizationModeSupported(cameraObj.VideoStabilizationMode.LOW, async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0101 callback"); + if (!err) { + if (data != null || data != undefined) { + mIsVideoStabilizationModeSupportedArray[i] = data; + if ((deviceInfo.deviceType != 'default') && (data == false)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0101 FAILED with isVideoStabilizationModeSupported is: " + data); + expect().assertFail(); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0101 PASSED with isVideoStabilizationModeSupported is: " + data); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0101 FAILED with isVideoStabilizationModeSupported is: " + data); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0101 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(1000); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0101 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0101 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0101 + * @tc.name : Check capture session support video stabilization low mode with promise or not + * @tc.desc : Check capture session support video stabilization low mode with promise or not + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0101', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0101--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0101 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0101 start for camera[" + i + "]"); + + await startCameraSession(i); + + let isVideoStabilizationModeSupported = await mCameraSession.isVideoStabilizationModeSupported(cameraObj.VideoStabilizationMode.LOW); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0101 finish"); + if (isVideoStabilizationModeSupported != null || isVideoStabilizationModeSupported != undefined) { + if ((deviceInfo.deviceType != 'default') && (isVideoStabilizationModeSupported == false)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0101 FAILED with isVideoStabilizationModeSupported is: " + isVideoStabilizationModeSupported); + expect().assertFail(); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0101 PASSED with isVideoStabilizationModeSupported is: " + isVideoStabilizationModeSupported); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0101 FAILED with isVideoStabilizationModeSupported is: " + isVideoStabilizationModeSupported); + expect().assertFail(); + } + + await sleep(1000); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0101 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0101 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0101 + * @tc.name : Check capture session set video stabilization low mode with callback + * @tc.desc : Check capture session set video stabilization low mode with callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0101', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0101--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0101 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0101 start for camera[" + i + "]"); + + await startCameraSession(i); + + if (mIsVideoStabilizationModeSupportedArray[i] == true) { + mCameraSession.setVideoStabilizationMode(cameraObj.VideoStabilizationMode.LOW, async (err) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0101 callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0101 PASSED with VideoStabilizationMode is: " + cameraObj.VideoStabilizationMode.LOW); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0101 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + mCameraSession.getActiveVideoStabilizationMode(async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0101 callback"); + if (!err) { + if (data == cameraObj.VideoStabilizationMode.LOW) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0101 PASSED with VideoStabilizationMode is: " + data); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0101 FAILED with VideoStabilizationMode is: " + data); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0101 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + } else { + if (deviceInfo.deviceType != 'default') { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0101 FAILED"); + expect().assertFail(); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0101 PASSED"); + } + } + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0101 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0101 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0101 + * @tc.name : Check capture session set video stabilization low mode with promise + * @tc.desc : Check capture session set video stabilization low mode with promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0101', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0101--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0101 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0101 start for camera[" + i + "]"); + + await startCameraSession(i); + + if (mIsVideoStabilizationModeSupportedArray[i] == true) { + await mCameraSession.setVideoStabilizationMode(cameraObj.VideoStabilizationMode.LOW); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0101 finish"); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0101 PASSED with VideoStabilizationMode is: " + cameraObj.VideoStabilizationMode.LOW); + await sleep(500); + + let vdeoStabilizationMode = await mCameraSession.getActiveVideoStabilizationMode(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0101 finish"); + if (vdeoStabilizationMode == cameraObj.VideoStabilizationMode.LOW) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0101 PASSED with VideoStabilizationMode is: " + vdeoStabilizationMode); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0101 FAILED with VideoStabilizationMode is: " + vdeoStabilizationMode); + expect().assertFail(); + } + await sleep(500); + } else { + if (deviceInfo.deviceType != 'default') { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0101 FAILED"); + expect().assertFail(); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0101 PASSED"); + } + } + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0101 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0101 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0102 + * @tc.name : Check capture session support video stabilization middle mode with callback or not + * @tc.desc : Check capture session support video stabilization middle mode with callback or not + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0102', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0102--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0102 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0102 start for camera[" + i + "]"); + + await startCameraSession(i); + + mIsVideoStabilizationModeSupportedArray[i] = false; + + mCameraSession.isVideoStabilizationModeSupported(cameraObj.VideoStabilizationMode.MIDDLE, async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0102 callback"); + if (!err) { + if (data != null || data != undefined) { + mIsVideoStabilizationModeSupportedArray[i] = data; + if ((deviceInfo.deviceType != 'default') && (data == false)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0102 FAILED with isVideoStabilizationModeSupported is: " + data); + expect().assertFail(); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0102 PASSED with isVideoStabilizationModeSupported is: " + data); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0102 FAILED with isVideoStabilizationModeSupported is: " + data); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0102 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(1000); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0102 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0102 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0102 + * @tc.name : Check capture session support video stabilization middle mode with promise or not + * @tc.desc : Check capture session support video stabilization middle mode with promise or not + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0102', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0102--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0102 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0102 start for camera[" + i + "]"); + + await startCameraSession(i); + + let isVideoStabilizationModeSupported = await mCameraSession.isVideoStabilizationModeSupported(cameraObj.VideoStabilizationMode.MIDDLE); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0102 finish"); + if (isVideoStabilizationModeSupported != null || isVideoStabilizationModeSupported != undefined) { + if ((deviceInfo.deviceType != 'default') && (isVideoStabilizationModeSupported == false)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0102 FAILED with isVideoStabilizationModeSupported is: " + isVideoStabilizationModeSupported); + expect().assertFail(); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0102 PASSED with isVideoStabilizationModeSupported is: " + isVideoStabilizationModeSupported); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0102 FAILED with isVideoStabilizationModeSupported is: " + isVideoStabilizationModeSupported); + expect().assertFail(); + } + + await sleep(1000); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0102 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0102 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0102 + * @tc.name : Check capture session set video stabilization middle mode with callback + * @tc.desc : Check capture session set video stabilization middle mode with callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0102', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0102--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0102 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0102 start for camera[" + i + "]"); + + await startCameraSession(i); + + if (mIsVideoStabilizationModeSupportedArray[i] == true) { + mCameraSession.setVideoStabilizationMode(cameraObj.VideoStabilizationMode.MIDDLE, async (err) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0102 callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0102 PASSED with VideoStabilizationMode is: " + cameraObj.VideoStabilizationMode.MIDDLE); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0102 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + mCameraSession.getActiveVideoStabilizationMode(async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0102 callback"); + if (!err) { + if (data == cameraObj.VideoStabilizationMode.MIDDLE) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0102 PASSED with VideoStabilizationMode is: " + data); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0102 FAILED with VideoStabilizationMode is: " + data); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0102 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + } else { + if (deviceInfo.deviceType != 'default') { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0102 FAILED"); + expect().assertFail(); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0102 PASSED"); + } + } + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0102 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0102 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0102 + * @tc.name : Check capture session set video stabilization middle mode with promise + * @tc.desc : Check capture session set video stabilization middle mode with promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0102', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0102--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0102 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0102 start for camera[" + i + "]"); + + await startCameraSession(i); + + if (mIsVideoStabilizationModeSupportedArray[i] == true) { + await mCameraSession.setVideoStabilizationMode(cameraObj.VideoStabilizationMode.MIDDLE); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0102 finish"); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0102 PASSED with VideoStabilizationMode is: " + cameraObj.VideoStabilizationMode.MIDDLE); + await sleep(500); + + let vdeoStabilizationMode = await mCameraSession.getActiveVideoStabilizationMode(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0102 finish"); + if (vdeoStabilizationMode == cameraObj.VideoStabilizationMode.MIDDLE) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0102 PASSED with VideoStabilizationMode is: " + vdeoStabilizationMode); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0102 FAILED with VideoStabilizationMode is: " + vdeoStabilizationMode); + expect().assertFail(); + } + await sleep(500); + } else { + if (deviceInfo.deviceType != 'default') { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0102 FAILED"); + expect().assertFail(); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0102 PASSED"); + } + } + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0102 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0102 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0103 + * @tc.name : Check capture session support video stabilization high mode with callback or not + * @tc.desc : Check capture session support video stabilization high mode with callback or not + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0103', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0103--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0103 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0103 start for camera[" + i + "]"); + + await startCameraSession(i); + + mIsVideoStabilizationModeSupportedArray[i] = false; + + mCameraSession.isVideoStabilizationModeSupported(cameraObj.VideoStabilizationMode.HIGH, async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0103 callback"); + if (!err) { + if (data != null || data != undefined) { + mIsVideoStabilizationModeSupportedArray[i] = data; + if ((deviceInfo.deviceType != 'default') && (data == false)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0103 FAILED with isVideoStabilizationModeSupported is: " + data); + expect().assertFail(); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0103 PASSED with isVideoStabilizationModeSupported is: " + data); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0103 FAILED with isVideoStabilizationModeSupported is: " + data); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0103 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(1000); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0103 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0103 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0103 + * @tc.name : Check capture session support video stabilization high mode with promise or not + * @tc.desc : Check capture session support video stabilization high mode with promise or not + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0103', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0103--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0103 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0103 start for camera[" + i + "]"); + + await startCameraSession(i); + + let isVideoStabilizationModeSupported = await mCameraSession.isVideoStabilizationModeSupported(cameraObj.VideoStabilizationMode.HIGH); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0103 finish"); + if (isVideoStabilizationModeSupported != null || isVideoStabilizationModeSupported != undefined) { + if ((deviceInfo.deviceType != 'default') && (isVideoStabilizationModeSupported == false)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0103 FAILED with isVideoStabilizationModeSupported is: " + isVideoStabilizationModeSupported); + expect().assertFail(); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0103 PASSED with isVideoStabilizationModeSupported is: " + isVideoStabilizationModeSupported); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0103 FAILED with isVideoStabilizationModeSupported is: " + isVideoStabilizationModeSupported); + expect().assertFail(); + } + + await sleep(1000); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0103 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0103 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0103 + * @tc.name : Check capture session set video stabilization high mode with callback + * @tc.desc : Check capture session set video stabilization high mode with callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0103', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0103--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0103 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0103 start for camera[" + i + "]"); + + await startCameraSession(i); + + if (mIsVideoStabilizationModeSupportedArray[i] == true) { + mCameraSession.setVideoStabilizationMode(cameraObj.VideoStabilizationMode.HIGH, async (err) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0103 callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0103 PASSED with VideoStabilizationMode is: " + cameraObj.VideoStabilizationMode.HIGH); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0103 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + mCameraSession.getActiveVideoStabilizationMode(async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0103 callback"); + if (!err) { + if (data == cameraObj.VideoStabilizationMode.HIGH) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0103 PASSED with VideoStabilizationMode is: " + data); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0103 FAILED with VideoStabilizationMode is: " + data); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0103 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + } else { + if (deviceInfo.deviceType != 'default') { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0103 FAILED"); + expect().assertFail(); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0103 PASSED"); + } + } + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0103 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0103 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0103 + * @tc.name : Check capture session set video stabilization high mode with promise + * @tc.desc : Check capture session set video stabilization high mode with promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0103', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0103--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0103 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0103 start for camera[" + i + "]"); + + await startCameraSession(i); + + if (mIsVideoStabilizationModeSupportedArray[i] == true) { + await mCameraSession.setVideoStabilizationMode(cameraObj.VideoStabilizationMode.HIGH); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0103 finish"); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0103 PASSED with VideoStabilizationMode is: " + cameraObj.VideoStabilizationMode.HIGH); + await sleep(500); + + let vdeoStabilizationMode = await mCameraSession.getActiveVideoStabilizationMode(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0103 finish"); + if (vdeoStabilizationMode == cameraObj.VideoStabilizationMode.HIGH) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0103 PASSED with VideoStabilizationMode is: " + vdeoStabilizationMode); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0103 FAILED with VideoStabilizationMode is: " + vdeoStabilizationMode); + expect().assertFail(); + } + await sleep(500); + } else { + if (deviceInfo.deviceType != 'default') { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0103 FAILED"); + expect().assertFail(); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0103 PASSED"); + } + } + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0103 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0103 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0104 + * @tc.name : Check capture session support video stabilization auto mode with callback or not + * @tc.desc : Check capture session support video stabilization auto mode with callback or not + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0104', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0104--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0104 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0104 start for camera[" + i + "]"); + + await startCameraSession(i); + + mIsVideoStabilizationModeSupportedArray[i] = false; + + mCameraSession.isVideoStabilizationModeSupported(cameraObj.VideoStabilizationMode.AUTO, async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0104 callback"); + if (!err) { + if (data != null || data != undefined) { + mIsVideoStabilizationModeSupportedArray[i] = data; + if ((deviceInfo.deviceType != 'default') && (data == false)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0104 FAILED with isVideoStabilizationModeSupported is: " + data); + expect().assertFail(); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0104 PASSED with isVideoStabilizationModeSupported is: " + data); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0104 FAILED with isVideoStabilizationModeSupported is: " + data); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0104 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(1000); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0104 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_CALLBACK_0104 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0104 + * @tc.name : Check capture session support video stabilization auto mode with promise or not + * @tc.desc : Check capture session support video stabilization auto mode with promise or not + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0104', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0104--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0104 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0104 start for camera[" + i + "]"); + + await startCameraSession(i); + + let isVideoStabilizationModeSupported = await mCameraSession.isVideoStabilizationModeSupported(cameraObj.VideoStabilizationMode.AUTO); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0104 finish"); + if (isVideoStabilizationModeSupported != null || isVideoStabilizationModeSupported != undefined) { + if ((deviceInfo.deviceType != 'default') && (isVideoStabilizationModeSupported == false)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0104 FAILED with isVideoStabilizationModeSupported is: " + isVideoStabilizationModeSupported); + expect().assertFail(); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0104 PASSED with isVideoStabilizationModeSupported is: " + isVideoStabilizationModeSupported); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0104 FAILED with isVideoStabilizationModeSupported is: " + isVideoStabilizationModeSupported); + expect().assertFail(); + } + + await sleep(1000); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0104 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0104 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0104 + * @tc.name : Check capture session set video stabilization auto mode with callback + * @tc.desc : Check capture session set video stabilization auto mode with callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0104', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0104--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0104 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0104 start for camera[" + i + "]"); + + await startCameraSession(i); + + if (mIsVideoStabilizationModeSupportedArray[i] == true) { + mCameraSession.setVideoStabilizationMode(cameraObj.VideoStabilizationMode.AUTO, async (err) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0104 callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0104 PASSED with VideoStabilizationMode is: " + cameraObj.VideoStabilizationMode.AUTO); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0104 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + mCameraSession.getActiveVideoStabilizationMode(async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0104 callback"); + if (!err) { + if (data == cameraObj.VideoStabilizationMode.AUTO) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0104 PASSED with VideoStabilizationMode is: " + data); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0104 FAILED with VideoStabilizationMode is: " + data); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0104 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + } else { + if (deviceInfo.deviceType != 'default') { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0104 FAILED"); + expect().assertFail(); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0104 PASSED"); + } + } + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0104 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_CALLBACK_0104 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0104 + * @tc.name : Check capture session set video stabilization auto mode with promise + * @tc.desc : Check capture session set video stabilization auto mode with promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0104', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0104--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0104 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0104 start for camera[" + i + "]"); + + await startCameraSession(i); + + if (mIsVideoStabilizationModeSupportedArray[i] == true) { + await mCameraSession.setVideoStabilizationMode(cameraObj.VideoStabilizationMode.AUTO); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0104 finish"); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0104 PASSED with VideoStabilizationMode is: " + cameraObj.VideoStabilizationMode.AUTO); + await sleep(500); + + let vdeoStabilizationMode = await mCameraSession.getActiveVideoStabilizationMode(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0104 finish"); + if (vdeoStabilizationMode == cameraObj.VideoStabilizationMode.AUTO) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0104 PASSED with VideoStabilizationMode is: " + vdeoStabilizationMode); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0104 FAILED with VideoStabilizationMode is: " + vdeoStabilizationMode); + expect().assertFail(); + } + await sleep(500); + } else { + if (deviceInfo.deviceType != 'default') { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0104 FAILED"); + expect().assertFail(); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0104 PASSED"); + } + } + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0104 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0104 ends here"); + done(); + } + }) + + }) +} \ No newline at end of file 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 new file mode 100755 index 0000000000000000000000000000000000000000..22b558a270b77b3ded224fc5f0e29dc686f22e26 --- /dev/null +++ b/multimedia/camera/camera_js_standard/src/main/ets/MainAbility/test/CameraSessionZoomRatioTest.test.ets @@ -0,0 +1,1217 @@ +/* + * 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. + */ + +// @ts-ignore + +import cameraObj from '@ohos.multimedia.camera'; +import image from '@ohos.multimedia.image'; +import media from '@ohos.multimedia.media' +import mediaLibrary from '@ohos.multimedia.mediaLibrary' +import fileio from '@ohos.fileio'; +import abilityAccessCtrl from '@ohos.abilityAccessCtrl' +import bundle from '@ohos.bundle' +import deviceInfo from '@ohos.deviceInfo'; +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'; + +const TAG = "CameraModuleTest: "; + +// Define global letiables +let mCameraManager; +let mCameraDevicesArray; +let mCameraSession; + +let mPhoteSurface; +let mVideoRecorder; +let mVideoSurface; +let mFileAsset; +let mFdPath; +let mFdNumber; + +// CAMERA-0 letiables +let mCameraInputArray; +let mPreviewOutputArray; +let mPhotoOutputArray; +let mVideoOutputArray; + +let mZoomRatioRangeArray; +let mZoomRatioMaxArray; +let mZoomRatioMinArray; + +let mVideoProfileCfg = { + audioBitrate: 48000, + audioChannels: 2, + audioCodec: 'audio/mp4a-latm', + audioSampleRate: 48000, + durationTime: 1000, + fileFormat: 'mp4', + videoBitrate: 48000, + videoCodec: 'video/mp4v-es', + videoFrameWidth: 640, + videoFrameHeight: 480, + videoFrameRate: 30 +} + +let mVideoConfig = { + audioSourceType: 1, + videoSourceType: 0, + profile: mVideoProfileCfg, + url: 'file:///data/media/CameraSessionZoomRatio.mp4', + orientationHint: 0, + location: { latitude: 30, longitude: 130 }, + maxSize: 100, + maxDuration: 500 +} + +let mPicWidthMax = 8192; +let mPicHeightMax = 8192; + +export default function cameraSessionZoomRatioTest(surfaceId: any) { + + function sleep(ms) { + console.info(TAG + "Entering sleep -> Promise constructor"); + return new Promise(resolve => setTimeout(resolve, ms)); + } + + function isEmpty(data) { + if (data == null || data == undefined) { + return true; + } + return false; + } + + async function getFd(pathName){ + let displayName = pathName; + const mediaTest = mediaLibrary.getMediaLibrary(); + let fileKeyObj = mediaLibrary.FileKey; + let mediaType = mediaLibrary.MediaType.VIDEO; + let publicPath = await mediaTest.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO); + let dataUri = await mediaTest.createAsset(mediaType, displayName, publicPath); + if (dataUri != undefined) { + let args = dataUri.id.toString(); + let fetchOp = { + selections: fileKeyObj.ID + "=?", + selectionArgs: [args], + } + let fetchFileResult = await mediaTest.getFileAssets(fetchOp); + mFileAsset = await fetchFileResult.getAllObject(); + mFdNumber = await mFileAsset[0].open('Rw'); + mFdPath = "fd://" + mFdNumber.toString(); + } + } + + async function closeFd() { + if (mFileAsset != null) { + await mFileAsset[0].close(mFdNumber).then(() => { + console.info('[mediaLibrary] case close fd success'); + }).catch((err) => { + console.info('[mediaLibrary] case close fd failed'); + }); + } else { + console.info('[mediaLibrary] case fileAsset is null'); + } + } + + async function applyPermission() { + let appInfo = await bundle.getApplicationInfo('com.open.harmony.multimedia.cameratest', 0, 100); + let atManager = abilityAccessCtrl.createAtManager(); + if (atManager != null) { + let tokenID = appInfo.accessTokenId; + console.info('[permission] case accessTokenID is ' + tokenID); + let permissionName1 = 'ohos.permission.CAMERA'; + let permissionName2 = 'ohos.permission.MICROPHONE'; + let permissionName3 = 'ohos.permission.MEDIA_LOCATION'; + let permissionName4 = 'ohos.permission.READ_MEDIA'; + let permissionName5 = 'ohos.permission.WRITE_MEDIA'; + await atManager.grantUserGrantedPermission(tokenID, permissionName1, 1).then((result) => { + console.info('[permission] case grantUserGrantedPermission success :' + result); + }).catch((err) => { + console.info('[permission] case grantUserGrantedPermission failed :' + err); + }); + await atManager.grantUserGrantedPermission(tokenID, permissionName2, 1).then((result) => { + console.info('[permission] case grantUserGrantedPermission success :' + result); + }).catch((err) => { + console.info('[permission] case grantUserGrantedPermission failed :' + err); + }); + await atManager.grantUserGrantedPermission(tokenID, permissionName3, 1).then((result) => { + console.info('[permission] case grantUserGrantedPermission success :' + result); + }).catch((err) => { + console.info('[permission] case grantUserGrantedPermission failed :' + err); + }); + await atManager.grantUserGrantedPermission(tokenID, permissionName4, 1).then((result) => { + console.info('[permission] case grantUserGrantedPermission success :' + result); + }).catch((err) => { + console.info('[permission] case grantUserGrantedPermission failed :' + err); + }); + await atManager.grantUserGrantedPermission(tokenID, permissionName5, 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 getPhotoReceiverSurface() { + console.log(TAG + 'Entering getPhotoReceiverSurface') + let receiver = image.createImageReceiver(640, 480, 4, 8) + 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)) + } else { + console.log(TAG + 'Photo receiver is created failed') + } + console.log(TAG + 'Exit getPhotoReceiverSurface') + } + + async function getVideoReceiveSurface() { + console.log(TAG + 'Entering getVideoReceiveSurface') + await getFd('CameraSessionZoomRatio.mp4'); + mVideoConfig.url = mFdPath; + media.createVideoRecorder((err, recorder) => { + console.info(TAG + 'Entering create video receiver') + mVideoRecorder = recorder + console.info(TAG + 'videoRecorder is :' + JSON.stringify(mVideoRecorder)) + console.info(TAG + 'videoRecorder.prepare called.') + mVideoRecorder.prepare(mVideoConfig, (err) => { + console.info(TAG + 'videoRecorder.prepare success.') + }) + mVideoRecorder.getInputSurface((err, id) => { + console.info(TAG + 'getInputSurface called') + mVideoSurface = id + console.info(TAG + 'getInputSurface surfaceId: ' + JSON.stringify(mVideoSurface)) + }) + }) + console.log(TAG + 'Exit getVideoReceiveSurface') + } + + async function releaseVideoReceiveSurface() { + console.log(TAG + 'Entering releaseVideoReceiveSurface') + mVideoRecorder.release((err) => { + console.info(TAG + 'Entering release video receiver') + }) + await closeFd(); + + await sleep(100); + console.log(TAG + 'Exit releaseVideoReceiveSurface') + } + + async function getCameraManagerInstance() { + console.info('Enter getCameraManagerInstance'); + + mCameraManager = await cameraObj.getCameraManager(null); + if (isEmpty(mCameraManager)) { + 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 + "getCameraSupportDevicesArray is: " + mCameraDevicesArray.length); + 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 createInputs() { + console.info('Enter createInputs'); + + if (isEmpty(mCameraDevicesArray)) { + console.info(TAG + "Entering createInputs FAILED with NoCamera"); + return false; + } + + mCameraInputArray = new Array(mCameraDevicesArray.length); + mZoomRatioRangeArray = new Array(mCameraDevicesArray.length); + mZoomRatioMaxArray = new Array(mCameraDevicesArray.length); + mZoomRatioMinArray = new Array(mCameraDevicesArray.length); + + for (let i = 0; i < mCameraDevicesArray.length; i++) { + mCameraInputArray[i] = await mCameraManager.createCameraInput(mCameraDevicesArray[i]); + if (isEmpty(mCameraInputArray[i])) { + console.info(TAG + "createCameraInput FAILED"); + return false; + } + + mCameraInputArray[i].open(async (err) => { + console.info(TAG + "Entering mCameraInputArray open callback"); + if (!err) { + console.info(TAG + "Entering mCameraInputArray open PASSED "); + } else { + console.info(TAG + "Entering mCameraInputArray open FAILED : " + err.message); + } + }) + + await sleep(2000); + + console.info(i + 'th CameraInput is: ' + mCameraInputArray[i]); + } + + console.info('Exit createInputs'); + + return true; + } + + async function releaseInputs() { + console.info('Enter releaseInputs'); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering releaseInputs FAILED with NoCamera"); + return true; + } + + for (let i = 0; i < mCameraInputArray.length; i++) { + await mCameraInputArray[i].close(); + await mCameraInputArray[i].release(); + } + + console.info('Exit releaseInputs'); + + return true; + } + + async function createOutputs() { + console.info('Enter createOutputs'); + + mPreviewOutputArray = new Array(mCameraDevicesArray.length); + mPhotoOutputArray = new Array(mCameraDevicesArray.length); + mVideoOutputArray = new Array(mCameraDevicesArray.length); + + for (let i = 0; i < mCameraDevicesArray.length; i++) { + let cameraOutputCap = await mCameraManager.getSupportedOutputCapability(mCameraDevicesArray[i]); + if (!isEmpty(cameraOutputCap.previewProfiles)) { + console.info(TAG + "cameraOutputCap.previewProfiles.length: " + cameraOutputCap.previewProfiles.length); + for (let j = 0; j < cameraOutputCap.previewProfiles.length; j++) { + mPreviewOutputArray[i] = await mCameraManager.createPreviewOutput(cameraOutputCap.previewProfiles[j], surfaceId); + if (!isEmpty(mPreviewOutputArray[i])) { + break; + } + } + + if (isEmpty(mPreviewOutputArray[i])) { + console.info(TAG + "createPreviewOutput FAILED"); + } + } + + /* + if (!isEmpty(cameraOutputCap.photoProfiles)) { + console.info(TAG + "cameraOutputCap.photoProfiles.length: " + cameraOutputCap.photoProfiles.length); + + for (let j = 0; j < cameraOutputCap.photoProfiles.length; j++) { + mPhotoOutputArray[i] = await mCameraManager.createPhotoOutput(cameraOutputCap.photoProfiles[j], mPhoteSurface); + if (!isEmpty(mPhotoOutputArray[i])) { + break; + } + } + + if (isEmpty(mPhotoOutputArray[i])) { + console.info(TAG + "createPhotoOutput FAILED"); + } + + console.info(TAG + "createPhotoOutput: " + mPhotoOutputArray[i]); + } + + if (!isEmpty(cameraOutputCap.videoProfiles)) { + console.info(TAG + "cameraOutputCap.videoProfiles.length: " + cameraOutputCap.videoProfiles.length); + for (let j = 0; j < cameraOutputCap.videoProfiles.length; j++) { + mVideoOutputArray[i] = await mCameraManager.createVideoOutput(cameraOutputCap.videoProfiles[j], mVideoSurface); + if (!isEmpty(mVideoOutputArray[i])) { + break; + } + } + + if (isEmpty(mVideoOutputArray[i])) { + console.info(TAG + "createVideoOutput FAILED"); + } + + console.info(TAG + "createVideoOutput: " + mPhotoOutputArray[i]); + } + */ + } + + console.info('Exit createOutputs'); + + return true; + } + + async function releaseOutputs() { + for (let i = 0; i < mCameraDevicesArray.length; i++) { + if (!isEmpty(mPreviewOutputArray[i])) { + await mPreviewOutputArray[i].close(); + await mPreviewOutputArray[i].release(); + } + + /* + if (!isEmpty(mPhotoOutputArray[i])) { + await mPhotoOutputArray[i].close(); + await mPhotoOutputArray[i].release(); + } + + if (!isEmpty(mVideoOutputArray[i])) { + await mVideoOutputArray[i].close(); + await mVideoOutputArray[i].release(); + } + */ + } + + return true; + } + + async function startCameraSession(idx:any) { + console.info(TAG + "Enter startCameraSession"); + + if (!isEmpty(mCameraInputArray[idx])) { + console.info(TAG + "Start to addInput"); + await mCameraSession.addInput(mCameraInputArray[idx]); + } + + if (!isEmpty(mPreviewOutputArray[idx])) { + console.info(TAG + "Start to addOutput mPreviewOutput"); + await mCameraSession.addOutput(mPreviewOutputArray[idx]); + } + + /* + if (!isEmpty(mPhotoOutputArray[idx])) { + console.info(TAG + "Start to addOutput mPhotoOutput"); + await mCameraSession.addOutput(mPhotoOutputArray[idx]); + } + + if (!isEmpty(mVideoOutputArray[idx])) { + console.info(TAG + "Start to addOutput mVideoOutput"); + await mCameraSession.addOutput(mVideoOutputArray[idx]); + } + */ + + await commitCameraSessionConfig(); + await beginCameraSessionConfig(); + + /* + await mCameraSession.start(async (err) => { + console.info(TAG + "Entering mCameraSession start callback"); + if (!err) { + console.info(TAG + "Entering mCameraSession start PASSED "); + } else { + console.info(TAG + "Entering mCameraSession start FAILED : " + err.message); + } + }) + + await sleep(1000); + */ + console.info(TAG + "Exit startCameraSession"); + + return true; + } + + async function stopCameraSession(idx:any) { + console.info(TAG + "Enter stopCameraSession"); + /* + mCameraSession.stop(async (err) => { + console.info(TAG + "Entering mCameraSession stop callback"); + if (!err) { + console.info(TAG + "Entering mCameraSession stop PASSED "); + } else { + console.info(TAG + "Entering mCameraSession stop FAILED : " + err.message); + } + }) + + await sleep(1000); + */ + + if (!isEmpty(mCameraInputArray[idx])) { + console.info(TAG + "Start to removeInput input"); + await mCameraSession.removeInput(mCameraInputArray[idx]); + } + + if (!isEmpty(mPreviewOutputArray[idx])) { + console.info(TAG + "Start to removeOutput mPreviewOutput"); + await mCameraSession.removeOutput(mPreviewOutputArray[idx]); + } + + /* + if (!isEmpty(mPhotoOutputArray[idx])) { + console.info(TAG + "Start to removeOutput mPhotoOutput"); + await mCameraSession.removeOutput(mPhotoOutputArray[idx]); + } + + if (!isEmpty(mVideoOutputArray[idx])) { + console.info(TAG + "Start to removeOutput mVideoOutput"); + await mCameraSession.removeOutput(mVideoOutputArray[idx]); + } + */ + + console.info(TAG + "Exit stopCameraSession"); + + return true; + } + + describe('cameraSessionZoomRatioTest', function () { + console.info(TAG + '----------cameraSessionZoomRatioTest--------------') + + beforeAll(async function () { + sleep(100); + + await applyPermission(); + await getPhotoReceiverSurface(); + await getVideoReceiveSurface(); + await getCameraManagerInstance(); + await getCameraSupportDevicesArray(); + await createCameraSessionInstance(); + await createInputs(); + await createOutputs(); + + console.info('Device type = ' + deviceInfo.deviceType); + + console.info('beforeAll case'); + }) + + beforeEach(function () { + sleep(5000); + console.info('beforeEach case'); + }) + + afterEach(async function () { + console.info('afterEach case'); + }) + + afterAll(function () { + releaseInputs(); + releaseOutputs(); + releaseVideoReceiveSurface(); + releaseCameraSessionInstance(); + sleep(1000); + console.info('afterAll case'); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_GET_ZOOM_RATIO_RANGE_CALLBACK_0100 + * @tc.name : Check capture session get zoom ratio range with callback + * @tc.desc : Check capture session get zoom ratio range with callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_GET_ZOOM_RATIO_RANGE_CALLBACK_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_GET_ZOOM_RATIO_RANGE_CALLBACK_0100--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_GET_ZOOM_RATIO_RANGE_CALLBACK_0100 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_GET_ZOOM_RATIO_RANGE_CALLBACK_0100 start for camera[" + i + "]"); + + await startCameraSession(i); + + mCameraSession.getZoomRatioRange(async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_GET_ZOOM_RATIO_RANGE_CALLBACK_0100 callback"); + if (!err) { + if (data.length > 0) { + mZoomRatioRangeArray[i] = data; + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_GET_ZOOM_RATIO_RANGE_CALLBACK_0100 PASSED with ZoomRatioRange length is: " + data.length); + for (let j = 0; j < mZoomRatioRangeArray[i].length; j++) { + console.info(TAG + j + "th, zoom ratio is: " + data[i][j] + ", " + mZoomRatioRangeArray[i][j]); + + if ((mZoomRatioMaxArray[i] == undefined) || (mZoomRatioMaxArray[i] < mZoomRatioRangeArray[i][j])) { + mZoomRatioMaxArray[i] = mZoomRatioRangeArray[i][j] + } + + if ((mZoomRatioMinArray[i] == undefined) || (mZoomRatioMinArray[i] > mZoomRatioRangeArray[i][j])) { + mZoomRatioMinArray[i] = mZoomRatioRangeArray[i][j] + } + } + + console.info(TAG + "Zoom ratio max is: " + mZoomRatioMaxArray[i] + ", min is: " + mZoomRatioMinArray[i]); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_GET_ZOOM_RATIO_RANGE_CALLBACK_0100 FAILED with ZoomRatioRange length is: " + data.length); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_GET_ZOOM_RATIO_RANGE_CALLBACK_0100 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(1000); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_GET_ZOOM_RATIO_RANGE_CALLBACK_0100 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_GET_ZOOM_RATIO_RANGE_CALLBACK_0100 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_GET_ZOOM_RATIO_RANGE_PROMISE_0100 + * @tc.name : Check capture session get zoom ratio range with promise + * @tc.desc : Check capture session get zoom ratio range with promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_GET_ZOOM_RATIO_RANGE_PROMISE_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_GET_ZOOM_RATIO_RANGE_PROMISE_0100--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_GET_ZOOM_RATIO_RANGE_PROMISE_0100 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_GET_ZOOM_RATIO_RANGE_PROMISE_0100 start for camera[" + i + "]"); + + await startCameraSession(i); + + let zoomRatioRange = await mCameraSession.getZoomRatioRange(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_GET_ZOOM_RATIO_RANGE_PROMISE_0100 finish"); + if (zoomRatioRange.length > 0) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_GET_ZOOM_RATIO_RANGE_PROMISE_0100 PASSED with ZoomRatioRange length is: " + zoomRatioRange.length); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_GET_ZOOM_RATIO_RANGE_PROMISE_0100 FAILED with ZoomRatioRange length is: " + zoomRatioRange.length); + expect().assertFail(); + } + + for (let j = 0; j < zoomRatioRange.length; j++) { + console.info(TAG + j + "th, zoom ratio is: " + zoomRatioRange[j]); + } + + await sleep(1000); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_GET_ZOOM_RATIO_RANGE_PROMISE_0100 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_GET_ZOOM_RATIO_RANGE_PROMISE_0100 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0100 + * @tc.name : Check capture session zoom ratio with callback + * @tc.desc : Check capture session zoom ratio with callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0100--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0100 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0100 start for camera[" + i + "]"); + + await startCameraSession(i); + + mCameraSession.setZoomRatio(mZoomRatioRangeArray[i][0], async (err) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0100 callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0100 PASSED with ZoomRatio is: " + mZoomRatioRangeArray[i][0]); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0100 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + mCameraSession.getZoomRatio(async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0100 callback"); + if (!err) { + if (data == mZoomRatioRangeArray[i][0]) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0100 PASSED with ZoomRatioRange is: " + data); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0100 FAILED with ZoomRatioRange is: " + data); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0100 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0100 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0100 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0100 + * @tc.name : Check capture session set zoom ratio with promise + * @tc.desc : Check capture session set zoom ratio with promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0100', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0100--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0100 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0100 start for camera[" + i + "]"); + + await startCameraSession(i); + + await mCameraSession.setZoomRatio(mZoomRatioRangeArray[i][0]); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0100 finish"); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0100 PASSED with ZoomRatio is: " + mZoomRatioRangeArray[i][0]); + await sleep(500); + + let zoomRatio = await mCameraSession.getZoomRatio(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0100 finish"); + if (zoomRatio == mZoomRatioRangeArray[i][0]) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0100 PASSED with ZoomRatio is: " + zoomRatio); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0100 FAILED with ZoomRatio is: " + zoomRatio); + expect().assertFail(); + } + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0100 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0100 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0101 + * @tc.name : Check capture session zoom ratio with callback(invalid value, max + 1) + * @tc.desc : Check capture session zoom ratio with callback(invalid value, max + 1) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0101', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0101--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0101 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0101 start for camera[" + i + "]"); + + await startCameraSession(i); + + mCameraSession.setZoomRatio((mZoomRatioMaxArray[i] + 1), async (err) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0101 callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0101 PASSED with ZoomRatio is: " + (mZoomRatioMaxArray[i] + 1)); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0101 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + mCameraSession.getZoomRatio(async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0101 callback"); + if (!err) { + if (data != (mZoomRatioMaxArray[i] + 1)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0101 PASSED with ZoomRatio is: " + data); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0101 FAILED with ZoomRatio is: " + data); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0101 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0101 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0101 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0101 + * @tc.name : Check capture session set zoom ratio with promise(invalid value, max + 1) + * @tc.desc : Check capture session set zoom ratio with promise(invalid value, max + 1) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0101', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0101--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0101 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0101 start for camera[" + i + "]"); + + await startCameraSession(i); + + await mCameraSession.setZoomRatio((mZoomRatioMaxArray[i] + 1)); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0101 finish"); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0101 PASSED with ZoomRatio is: " + (mZoomRatioMaxArray[i] + 1)); + await sleep(500); + + let zoomRatio = await mCameraSession.getZoomRatio(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0101 finish"); + if (zoomRatio != (mZoomRatioMaxArray[i] + 1)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0101 PASSED with ZoomRatio is: " + zoomRatio); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0101 FAILED with ZoomRatio is: " + zoomRatio); + expect().assertFail(); + } + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0101 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0101 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0102 + * @tc.name : Check capture session zoom ratio with callback(invalid value, max + 0.1) + * @tc.desc : Check capture session zoom ratio with callback(invalid value, max + 0.1) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0102', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0102--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0102 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0102 start for camera[" + i + "]"); + + await startCameraSession(i); + + mCameraSession.setZoomRatio((mZoomRatioMaxArray[i] + 0.1), async (err) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0102 callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0102 PASSED with ZoomRatio is: " + (mZoomRatioMaxArray[i] + 0.1)); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0102 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + mCameraSession.getZoomRatio(async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0102 callback"); + if (!err) { + if (data != (mZoomRatioMaxArray[i] + 0.1)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0102 PASSED with ZoomRatio is: " + data); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0102 FAILED with ZoomRatio is: " + data); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0102 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0102 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0102 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0102 + * @tc.name : Check capture session set zoom ratio with promise(invalid value, max + 0.1) + * @tc.desc : Check capture session set zoom ratio with promise(invalid value, max + 0.1) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0102', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0102--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0102 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0102 start for camera[" + i + "]"); + + await startCameraSession(i); + + await mCameraSession.setZoomRatio((mZoomRatioMaxArray[i] + 0.1)); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0102 finish"); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0102 PASSED with ZoomRatio is: " + (mZoomRatioMaxArray[i] + 0.1)); + await sleep(500); + + let zoomRatio = await mCameraSession.getZoomRatio(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0102 finish"); + if (zoomRatio != (mZoomRatioMaxArray[i] + 0.1)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0102 PASSED with ZoomRatio is: " + zoomRatio); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0102 FAILED with ZoomRatio is: " + zoomRatio); + expect().assertFail(); + } + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0102 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0102 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0103 + * @tc.name : Check capture session zoom ratio with callback(invalid value, min - 1) + * @tc.desc : Check capture session zoom ratio with callback(invalid value, min - 1) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0103', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0103--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0103 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0103 start for camera[" + i + "]"); + + await startCameraSession(i); + + mCameraSession.setZoomRatio((mZoomRatioMinArray[i] - 1), async (err) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0103 callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0103 PASSED with ZoomRatio is: " + (mZoomRatioMaxArray[i] - 1)); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0103 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + mCameraSession.getZoomRatio(async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0103 callback"); + if (!err) { + if (data != (mZoomRatioMinArray[i] - 1)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0103 PASSED with ZoomRatio is: " + data); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0103 FAILED with ZoomRatio is: " + data); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0103 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0103 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0103 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0103 + * @tc.name : Check capture session set zoom ratio with promise(invalid value, min - 1) + * @tc.desc : Check capture session set zoom ratio with promise(invalid value, min - 1) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0103', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0103--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0103 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0103 start for camera[" + i + "]"); + + await startCameraSession(i); + + await mCameraSession.setZoomRatio((mZoomRatioMinArray[i] - 1)); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0103 finish"); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0103 PASSED with ZoomRatio is: " + (mZoomRatioMaxArray[i] - 1)); + await sleep(500); + + let zoomRatio = await mCameraSession.getZoomRatio(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0103 finish"); + if (zoomRatio != (mZoomRatioMinArray[i] - 1)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0103 PASSED with ZoomRatio is: " + zoomRatio); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0103 FAILED with ZoomRatio is: " + zoomRatio); + expect().assertFail(); + } + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0103 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0103 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0104 + * @tc.name : Check capture session zoom ratio with callback(invalid value, min - 0.1) + * @tc.desc : Check capture session zoom ratio with callback(invalid value, min - 0.1) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0104', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0104--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0104 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0104 start for camera[" + i + "]"); + + await startCameraSession(i); + + mCameraSession.setZoomRatio((mZoomRatioMaxArray[i] - 0.1), async (err) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0104 callback"); + if (!err) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0104 PASSED with ZoomRatio is: " + (mZoomRatioMaxArray[i] - 0.1)); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0104 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + mCameraSession.getZoomRatio(async (err, data) => { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0104 callback"); + if (!err) { + if (data != (mZoomRatioMaxArray[i] - 0.1)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0104 PASSED with ZoomRatio is: " + data); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0104 FAILED with ZoomRatio is: " + data); + expect().assertFail(); + } + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0104 FAILED : " + err.message); + expect().assertFail(); + } + }) + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0104 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_CALLBACK_0104 ends here"); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0104 + * @tc.name : Check capture session set zoom ratio with promise(invalid value, min - 0.1) + * @tc.desc : Check capture session set zoom ratio with promise(invalid value, min - 0.1) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0104', 0, async function (done) { + console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0104--------------"); + + if (isEmpty(mCameraInputArray)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0104 FAILED with NoCamera"); + expect().assertFail(); + done(); + } else { + for (let i = 0; i < mCameraInputArray.length; i++) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0104 start for camera[" + i + "]"); + + await startCameraSession(i); + + await mCameraSession.setZoomRatio((mZoomRatioMinArray[i] - 0.1)); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0104 finish"); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0104 PASSED with ZoomRatio is: " + (mZoomRatioMaxArray[i] - 0.1)); + await sleep(500); + + let zoomRatio = await mCameraSession.getZoomRatio(); + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0104 finish"); + if (zoomRatio != (mZoomRatioMinArray[i] - 0.1)) { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0104 PASSED with ZoomRatio is: " + zoomRatio); + } else { + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0104 FAILED with ZoomRatio is: " + zoomRatio); + expect().assertFail(); + } + await sleep(500); + + await stopCameraSession(i); + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0104 end for camera[" + i + "]"); + } + + console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0104 ends here"); + done(); + } + }) + + }) +} \ No newline at end of file