提交 3e219de9 编写于 作者: L lwx1121892

delete camera

Signed-off-by: Nlwx1121892 <liuxueqi3@huawei.com>
上级 507201b0
...@@ -26,7 +26,6 @@ group("multimedia") { ...@@ -26,7 +26,6 @@ group("multimedia") {
"audio/audio_js_standard/audioManager:audio_manager_js_hap", "audio/audio_js_standard/audioManager:audio_manager_js_hap",
"audio/audio_js_standard/audioRenderer:audio_renderer_js_hap", "audio/audio_js_standard/audioRenderer:audio_renderer_js_hap",
"audio/audio_js_standard/audioVoip:audio_voip_js_hap", "audio/audio_js_standard/audioVoip:audio_voip_js_hap",
"camera/camera_js_standard:camera_framework_ets_hap",
"image/image_js_standard/image:image_js_hap", "image/image_js_standard/image:image_js_hap",
"image/image_js_standard/imageColorspace:image_colorspace_js_hap", "image/image_js_standard/imageColorspace:image_colorspace_js_hap",
"image/image_js_standard/imageCreator:image_creator_js_hap", "image/image_js_standard/imageCreator:image_creator_js_hap",
......
# Copyright (C) 2021 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("camera_framework_ets_hap") {
hap_profile = "./entry/src/config.json"
deps = [
":camera_ets_assets",
":camera_ets_resources",
]
ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsCameraStandardETSTest"
subsystem_name = "multimedia"
part_name = "multimedia_camera_framework"
}
ohos_js_assets("camera_ets_assets") {
source_dir = "./entry/src/main/ets/MainAbility"
}
ohos_resources("camera_ets_resources") {
sources = [ "./entry/src/resources" ]
hap_profile = "./entry/src/config.json"
}
{
"description": "Configuration for camerastandard Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "3000000",
"bundle-name":"com.open.harmony.multimedia.cameratest",
"package-name": "com.open.harmony.multimedia.cameratest",
"shell-timeout": "600000",
"testcase-timeout": 100000
},
"kits": [
{
"type": "ShellKit",
"run-command": [
"hilog -Q pidoff",
"rm -rf /storage/media/100/local/files/Videos/*",
"power-shell wakeup",
"uinput -T -d 300 600 -m 300 600 300 100 -u 300 100",
"power-shell setmode 602"
],
"teardown-command":[
"power-shell setmode 600"
]
},
{
"test-file-name": [
"ActsCameraStandardETSTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.open.harmony.multimedia.cameratest",
"vendor": "open",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 7,
"releaseType": "Release",
"target": 7
}
},
"deviceConfig": {},
"module": {
"package": "com.open.harmony.multimedia.cameratest",
"name": ".MyApplication",
"mainAbility": "com.open.harmony.multimedia.cameratest.MainAbility",
"srcPath": "",
"deviceType": [
"tablet",
"default",
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": false
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation": "unspecified",
"visible": true,
"srcPath": "MainAbility",
"name": ".MainAbility",
"srcLanguage": "ets",
"icon": "$media:icon",
"description": "$string:description_mainability",
"formsEnabled": false,
"label": "$string:entry_MainAbility",
"type": "page",
"launchType": "standard"
},
{
"orientation": "unspecified",
"visible": true,
"srcPath": "TestAbility",
"name": ".TestAbility",
"srcLanguage": "ets",
"icon": "$media:icon",
"description": "$string:TestAbility_desc",
"formsEnabled": false,
"label": "$string:TestAbility_label",
"type": "page",
"launchType": "standard"
}
],
"reqPermissions": [
{
"name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",
"reason": "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS"
},
{
"name": "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS",
"reason": "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS"
},
{
"name": "ohos.permission.CAMERA",
"reason": "use ohos.permission.CAMERA"
},
{
"name": "ohos.permission.MICROPHONE",
"reason": "use ohos.permission.MICROPHONE"
},
{
"name": "ohos.permission.MEDIA_LOCATION",
"reason": "use ohos.permission.MEDIA_LOCATION"
},
{
"name": "ohos.permission.READ_MEDIA",
"reason": "use ohos.permission.READ_MEDIA"
},
{
"name": "ohos.permission.WRITE_MEDIA",
"reason": "use ohos.permission.WRITE_MEDIA"
},
{
"name": "ohos.permission.START_ABILIIES_FROM_BACKGROUND",
"reason": "use ohos.permission.START_ABILIIES_FROM_BACKGROUND"
},
{
"name": "ohos.permission.START_INVISIBLE_ABILITY",
"reason": "use ohos.permission.START_INVISIBLE_ABILITY"
},
{
"name": "ohos.permission.ABILITY_BACKGROUND_COMMUNICATION",
"reason": "use ohos.permission.ABILITY_BACKGROUND_COMMUNICATION"
}
],
"js": [
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index"
],
"name": ".MainAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
\ No newline at end of file
/*
* 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.
*/
export default {
onCreate() {
console.info('Application onCreate')
},
onDestroy() {
console.info('Application onDestroy')
},
}
/*
* 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import cameraKit from '../../test/Camera.test.ets'
let TAG = 'CameraModuleTest: '
var mXComponentController: XComponentController = new XComponentController()
var surfaceId: any
@Entry
@Component
struct CameraIndex {
@State isShowSettings: boolean = false
@State previewSize: string = '75%'
aboutToAppear() {
console.info('--------------aboutToAppear--------------')
}
build() {
Flex() {
XComponent({
id: '',
type: 'surface',
libraryname: '',
controller: mXComponentController
})
.onLoad(() => {
console.info('CameraModuleTest: OnLoad() is called!')
mXComponentController.setXComponentSurfaceSize({ surfaceWidth: 1920, surfaceHeight: 1080 });
surfaceId = mXComponentController.getXComponentSurfaceId()
globalThis.surfaceId = surfaceId
console.info('CameraModuleTest: XComponent onLoad surfaceId: ' + surfaceId)
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
//console.info(0x00, 'testTag', '%{public}s', 'start run testcase!!!');
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, cameraKit)
})
.width('1920px')
.height('1080px')
}
}
}
/*
* 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.
*/
export default {
onCreate() {
console.info('Application onCreate')
},
onDestroy() {
console.info('Application onDestroy')
},
}
\ No newline at end of file
/*
* 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 TestRunner from '@ohos.application.testRunner'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
var abilityDelegator = undefined
var abilityDelegatorArguments = undefined
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s itName',
'-s level', '-s testType', '-s size', '-s timeout',
'-s package'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams += ' ' + key + ' ' + parameters[key]
}
}
return targetParams.trim()
}
async function onAbilityCreateCallback() {
console.log('onAbilityCreateCallback');
}
async function addAbilityMonitorCallback(err: any) {
console.info('addAbilityMonitorCallback : ' + JSON.stringify(err))
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
console.info('OpenHarmonyTestRunner OnPrepare')
}
onRun() {
console.log('OpenHarmonyTestRunner onRun run')
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.MainAbility'
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters)
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + d.stdResult);
console.info('executeShellCommand : data : ' + d.exitCode);
})
console.info('OpenHarmonyTestRunner onRun call abilityDelegator.getAppContext')
var context = abilityDelegator.getAppContext()
console.info('getAppContext : ' + JSON.stringify(context))
console.info('OpenHarmonyTestRunner onRun end')
}
};
\ No newline at end of file
/*
* 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 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 CameraErrorCodeUsecaseTest from './CameraErrorCodeUsecaseTest.test.ets'
import cameraManagerTest from './CameraManagerTest.test.ets'
import cameraEnumTest from './CameraEnumTest.test.ets'
let TAG = 'CameraModuleTest: '
export default function cameraKit() {
console.info(TAG + 'Entering cameraKit')
cameraInputTest()
cameraJSUnitOutput()
cameraSessionFlashTest()
cameraSessionExposureTest()
cameraSessionFocusTest()
cameraSessionZoomRatioTest()
cameraSessionVideoStabilizationTest()
cameraSessionBaseTest()
CameraErrorCodeUsecaseTest()
cameraManagerTest()
cameraEnumTest()
}
\ No newline at end of file
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import camera from '@ohos.multimedia.camera';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
const TAG = "CameraEnumTest: ";
export default function cameraEnumTest() {
function isEmpty(data) {
if (data == null || data == undefined) {
return true;
}
return false;
}
describe('CameraEnumTest', function () {
console.info(TAG + '----------CameraEnumTest--------------');
beforeAll(async function () {
console.info('beforeAll case');
})
beforeEach(function () {
console.info('beforeEach case');
})
afterEach(async function () {
console.info('afterEach case');
})
afterAll(function () {
console.info('afterAll case');
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ENUM_CAMERASTATUS_0100
* @tc.name : Camera CameraStatus Eunm
* @tc.desc : Camera CameraStatus Eunm
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_MULTIMEDIA_CAMERA_ENUM_CAMERASTATUS_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ENUM_CAMERASTATUS_0100--------------");
expect(camera.CameraStatus.CAMERA_STATUS_APPEAR == 0).assertTrue();
expect(camera.CameraStatus.CAMERA_STATUS_DISAPPEAR == 1).assertTrue();
expect(camera.CameraStatus.CAMERA_STATUS_AVAILABLE == 2).assertTrue();
expect(camera.CameraStatus.CAMERA_STATUS_UNAVAILABLE == 3).assertTrue();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ENUM_CAMERASTATUS_0100 ends here");
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ENUM_CAMERAPOSITION_0100
* @tc.name : Camera CameraPosition Eunm
* @tc.desc : Camera CameraPosition Eunm
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_MULTIMEDIA_CAMERA_ENUM_CAMERAPOSITION_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ENUM_CAMERAPOSITION_0100--------------");
expect(camera.CameraPosition.CAMERA_POSITION_UNSPECIFIED == 0).assertTrue();
expect(camera.CameraPosition.CAMERA_POSITION_BACK == 1).assertTrue();
expect(camera.CameraPosition.CAMERA_POSITION_FRONT == 2).assertTrue();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ENUM_CAMERAPOSITION_0100 ends here");
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ENUM_CAMERATYPE_0100
* @tc.name : Camera CameraType Eunm
* @tc.desc : Camera CameraType Eunm
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_MULTIMEDIA_CAMERA_ENUM_CAMERATYPE_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ENUM_CAMERATYPE_0100--------------");
console.info("CameraType: "+ JSON.stringify(camera.CameraType));
expect(camera.CameraType.CAMERA_TYPE_DEFAULT == 0).assertTrue();
expect(camera.CameraType.CAMERA_TYPE_WIDE_ANGLE == 1).assertTrue();
expect(camera.CameraType.CAMERA_TYPE_ULTRA_WIDE == 2).assertTrue();
expect(camera.CameraType.CAMERA_TYPE_TELEPHOTO == 3).assertTrue();
expect(camera.CameraType.CAMERA_TYPE_TRUE_DEPTH == 4).assertTrue();
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ENUM_CONNECTIONTYPE_0100
* @tc.name : Camera ConnectionType Eunm
* @tc.desc : Camera ConnectionType Eunm
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_MULTIMEDIA_CAMERA_ENUM_CONNECTIONTYPE_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ENUM_CONNECTIONTYPE_0100--------------");
expect(camera.ConnectionType.CAMERA_CONNECTION_BUILT_IN == 0).assertTrue();
expect(camera.ConnectionType.CAMERA_CONNECTION_USB_PLUGIN == 1).assertTrue();
expect(camera.ConnectionType.CAMERA_CONNECTION_REMOTE == 2).assertTrue();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ENUM_CONNECTIONTYPE_0100 ends here");
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ENUM_CAMERAFORMAT_0100
* @tc.name : Camera CameraFormat Eunm
* @tc.desc : Camera CameraFormat Eunm
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_MULTIMEDIA_CAMERA_ENUM_CAMERAFORMAT_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ENUM_CAMERAFORMAT_0100--------------");
expect(camera.CameraFormat.CAMERA_FORMAT_RGBA_8888 == 3).assertTrue();
expect(camera.CameraFormat.CAMERA_FORMAT_YUV_420_SP == 1003).assertTrue();
expect(camera.CameraFormat.CAMERA_FORMAT_JPEG == 2000).assertTrue();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ENUM_CAMERAFORMAT_0100 ends here");
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ENUM_FLASHMODE_0100
* @tc.name : Camera FlashMode Eunm
* @tc.desc : Camera FlashMode Eunm
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_MULTIMEDIA_CAMERA_ENUM_FLASHMODE_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ENUM_FLASHMODE_0100--------------");
expect(camera.FlashMode.FLASH_MODE_CLOSE == 0).assertTrue();
expect(camera.FlashMode.FLASH_MODE_OPEN == 1).assertTrue();
expect(camera.FlashMode.FLASH_MODE_AUTO == 2).assertTrue();
expect(camera.FlashMode.FLASH_MODE_ALWAYS_OPEN == 3).assertTrue();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ENUM_FLASHMODE_0100 ends here");
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ENUM_EXPOSUREMODE_0100
* @tc.name : Camera ExposureMode Eunm
* @tc.desc : CameraExposureMode Eunm
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_MULTIMEDIA_CAMERA_ENUM_EXPOSUREMODE_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ENUM_EXPOSUREMODE_0100--------------");
expect(camera.ExposureMode.EXPOSURE_MODE_LOCKED == 0).assertTrue();
expect(camera.ExposureMode.EXPOSURE_MODE_AUTO == 1).assertTrue();
expect(camera.ExposureMode.EXPOSURE_MODE_CONTINUOUS_AUTO == 2).assertTrue();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ENUM_EXPOSUREMODE_0100 ends here");
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ENUM_FOCUSMODE_0100
* @tc.name : Camera FocusMode Eunm
* @tc.desc : Camera FocusMode Eunm
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_MULTIMEDIA_CAMERA_ENUM_FOCUSMODE_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ENUM_FOCUSMODE_0100--------------");
expect(camera.FocusMode.FOCUS_MODE_MANUAL == 0).assertTrue();
expect(camera.FocusMode.FOCUS_MODE_CONTINUOUS_AUTO == 1).assertTrue();
expect(camera.FocusMode.FOCUS_MODE_AUTO == 2).assertTrue();
expect(camera.FocusMode.FOCUS_MODE_LOCKED == 3).assertTrue();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ENUM_FOCUSMODE_0100 ends here");
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ENUM_FOCUSSTATE_0100
* @tc.name : Camera FocusState Eunm
* @tc.desc : Camera FocusState Eunm
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_MULTIMEDIA_CAMERA_ENUM_FOCUSSTATE_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ENUM_FOCUSSTATE_0100--------------");
expect(camera.FocusState.FOCUS_STATE_SCAN == 0).assertTrue();
expect(camera.FocusState.FOCUS_STATE_FOCUSED == 1).assertTrue();
expect(camera.FocusState.FOCUS_STATE_UNFOCUSED == 2).assertTrue();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ENUM_FOCUSSTATE_0100 ends here");
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ENUM_VIDEOSTABILIZATIONMODE_0100
* @tc.name : Camera VideoStabilizationMode Eunm
* @tc.desc : Camera VideoStabilizationMode Eunm
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_MULTIMEDIA_CAMERA_ENUM_VIDEOSTABILIZATIONMODE_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ENUM_VIDEOSTABILIZATIONMODE_0100--------------");
expect(camera.VideoStabilizationMode.OFF == 0).assertTrue();
expect(camera.VideoStabilizationMode.LOW == 1).assertTrue();
expect(camera.VideoStabilizationMode.MIDDLE == 2).assertTrue();
expect(camera.VideoStabilizationMode.HIGH == 3).assertTrue();
expect(camera.VideoStabilizationMode.AUTO == 4).assertTrue();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ENUM_VIDEOSTABILIZATIONMODE_0100 ends here");
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ENUM_IMAGEROTATION_0100
* @tc.name : Camera ImageRotation Eunm
* @tc.desc : Camera ImageRotation Eunm
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_MULTIMEDIA_CAMERA_ENUM_IMAGEROTATION_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ENUM_IMAGEROTATION_0100--------------");
expect(camera.ImageRotation.ROTATION_0 == 0).assertTrue();
expect(camera.ImageRotation.ROTATION_90 == 90).assertTrue();
expect(camera.ImageRotation.ROTATION_180 == 180).assertTrue();
expect(camera.ImageRotation.ROTATION_270 == 270).assertTrue();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ENUM_IMAGEROTATION_0100 ends here");
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ENUM_QUALITYLEVEL_0100
* @tc.name : Camera QualityLevel Eunm
* @tc.desc : Camera QualityLevel Eunm
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_MULTIMEDIA_CAMERA_ENUM_QUALITYLEVEL_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ENUM_QUALITYLEVEL_0100--------------");
expect(camera.QualityLevel.QUALITY_LEVEL_HIGH == 0).assertTrue();
expect(camera.QualityLevel.QUALITY_LEVEL_MEDIUM == 1).assertTrue();
expect(camera.QualityLevel.QUALITY_LEVEL_LOW == 2).assertTrue();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ENUM_QUALITYLEVEL_0100 ends here");
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ENUM_METADATAOBJECTTYPE_0100
* @tc.name : Camera MetadataObjectType Eunm
* @tc.desc : Camera MetadataObjectType Eunm
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_MULTIMEDIA_CAMERA_ENUM_METADATAOBJECTTYPE_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ENUM_METADATAOBJECTTYPE_0100--------------");
expect(camera.MetadataObjectType.FACE_DETECTION == 0).assertTrue();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ENUM_METADATAOBJECTTYPE_0100 ends here");
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ENUM_CAMERAERRORCODE_0100
* @tc.name : Camera CameraErrorCode Eunm
* @tc.desc : Camera CameraErrorCode Eunm
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_MULTIMEDIA_CAMERA_ENUM_CAMERAERRORCODE_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ENUM_CAMERAERRORCODE_0100--------------");
expect(camera.CameraErrorCode.INVALID_ARGUMENT == 7400101).assertTrue();
expect(camera.CameraErrorCode.OPERATION_NOT_ALLOWED == 7400102).assertTrue();
expect(camera.CameraErrorCode.SESSION_NOT_CONFIG == 7400103).assertTrue();
expect(camera.CameraErrorCode.SESSION_NOT_RUNNING == 7400104).assertTrue();
expect(camera.CameraErrorCode.SESSION_CONFIG_LOCKED == 7400105).assertTrue();
expect(camera.CameraErrorCode.DEVICE_SETTING_LOCKED == 7400106).assertTrue();
expect(camera.CameraErrorCode.CONFILICT_CAMERA == 7400107).assertTrue();
expect(camera.CameraErrorCode.DEVICE_DISABLED == 7400108).assertTrue();
expect(camera.CameraErrorCode.SERVICE_FATAL_ERROR == 7400201).assertTrue();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ENUM_CAMERAERRORCODE_0100 ends here");
done();
})
})
}
\ No newline at end of file
/*
* 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 mediaLibrary from '@ohos.multimedia.mediaLibrary';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium';
// 创建视频录制的参数
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 captureLocation = {
latitude: 0,
longitude: 0,
altitude: 0,
}
let captureSetting = {
quality: cameraObj.QualityLevel.QUALITY_LEVEL_LOW,
rotation: cameraObj.ImageRotation.ROTATION_0,
location: captureLocation,
mirror: false
}
const TAG = "CameraErrorCodeUsecaseTest: ";
let mCameraManager;
let cameraOutputCap;
let mCameraDevicesArray;
let mCameraSession;
let mCameraNum;
let mCameraInput;
let mPreviewOutput;
let mPhotoSurface;
let mPhotoOutput;
let videoOutput;
let videoRecorder;
let videoSurfaceId;
let fdPath;
let fileAsset;
let fdNumber;
let metadataOutput;
let mMetadataObjectTypeArray;
export default function CameraErrorCodeUsecaseTest() {
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;
}
function getCameraManagerInstance() {
console.info(TAG + 'Enter getCameraManagerInstance');
mCameraManager = cameraObj.getCameraManager(null);
if (isEmpty(mCameraManager)) {
console.info(TAG + "getCameraManager FAILED");
return false;
}
console.info(TAG + 'Exit getCameraManagerInstance');
return true;
}
function getCameraSupportDevicesArray() {
console.info(TAG + 'Enter getCameraSupportDevicesArray');
mCameraDevicesArray = mCameraManager.getSupportedCameras();
if (isEmpty(mCameraDevicesArray)) {
console.info(TAG + "getSupportedCameras FAILED");
return false;
}
mCameraNum = mCameraDevicesArray.length;
console.info(TAG + "getCameraSupportDevicesArray is: " + mCameraNum);
console.info(TAG + 'Exit getCameraSupportDevicesArray');
return true;
}
async function createInput(idx:any) {
console.info(TAG + 'Enter createInput');
if (isEmpty(mCameraDevicesArray)) {
console.info(TAG + "Entering createInputs FAILED with NoCamera");
return false;
}
mCameraInput = mCameraManager.createCameraInput(mCameraDevicesArray[idx]);
if (isEmpty(mCameraInput)) {
console.info(TAG + "createCameraInput FAILED");
return false;
}
await mCameraInput.open();
sleep(100);
console.info(idx + 'th CameraInput is: ' + mCameraInput);
console.info(TAG + 'Exit createInput');
return true;
}
async function releaseInput() {
console.info(TAG + 'Enter releaseInput');
if (!isEmpty(mCameraInput)) {
await mCameraInput.close();
mCameraInput = null;
}
console.info(TAG + 'Exit releaseInput');
return true;
}
function beginCameraSessionConfig() {
console.info(TAG + 'Enter beginCameraSessionConfig');
mCameraSession.beginConfig();
console.info(TAG + 'Exit beginCameraSessionConfig');
return true;
}
async function commitCameraSessionConfig() {
console.info(TAG + 'Enter commitCameraSessionConfig');
await mCameraSession.commitConfig();
sleep(500);
console.info(TAG + 'Exit commitCameraSessionConfig');
return true;
}
function createCameraSessionInstance() {
console.info(TAG + 'Enter createCameraSessionInstance');
try {
mCameraSession = mCameraManager.createCaptureSession();
}
catch {
console.info(TAG + 'createCaptureSession FAILED');
}
if (isEmpty(mCameraSession)) {
console.info(TAG + "createCaptureSession FAILED");
return false;
}
beginCameraSessionConfig();
console.info(TAG + 'Exit createCameraSessionInstance');
return true;
}
function releaseCameraSessionInstance() {
mCameraSession.release();
mCameraSession = null;
}
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')
mPhotoSurface = await receiver.getReceivingSurfaceId()
console.log(TAG + 'Photo received id: ' + JSON.stringify(mPhotoSurface))
} else {
console.log(TAG + 'Photo receiver is created failed')
}
console.log(TAG + 'Exit getPhotoReceiverSurface')
}
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('ErrorCodeCameraOutput.mp4');
videoConfig.url = fdPath;
media.createVideoRecorder((err, recorder) => {
if (!err) {
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) => {
if (!err) {
console.info(TAG + 'videoRecorder.prepare success.')
videoRecorder.getInputSurface((err, id) => {
console.info(TAG + 'getInputSurface called')
if (!err) {
videoSurfaceId = id
console.info(TAG + 'getInputSurface surfaceId: ' + JSON.stringify(videoSurfaceId))
} else {
console.info(TAG + 'getInputSurface FAILED')
}
})
} else {
console.info(TAG + 'prepare FAILED')
}
})
}
else {
console.info(TAG + 'createVideoRecorder FAILED')
}
})
}
async function releaseVideoReceiveSurface() {
console.log(TAG + 'Entering releaseVideoReceiveSurface')
videoRecorder.release((err) => {
console.info(TAG + 'Entering release video receiver')
})
await closeFd();
console.log(TAG + 'Exit releaseVideoReceiveSurface')
}
function createOutput(idx:any) {
console.info(TAG + 'Enter createOutput');
cameraOutputCap = mCameraManager.getSupportedOutputCapability(mCameraDevicesArray[idx]);
if (!isEmpty(cameraOutputCap)) {
if (!isEmpty(cameraOutputCap.previewProfiles)) {
console.info(TAG + "cameraOutputCap.previewProfiles.length: " + cameraOutputCap.previewProfiles.length);
for (let i = 0; i < cameraOutputCap.previewProfiles.length; i++) {
mPreviewOutput = mCameraManager.createPreviewOutput(cameraOutputCap.previewProfiles[i], globalThis.surfaceId);
if (!isEmpty(mPreviewOutput)) {
break;
}
}
if (isEmpty(mPreviewOutput)) {
console.info(TAG + "createPreviewOutput FAILED");
}
console.info(TAG + "createPreviewOutput: " + mPreviewOutput);
}
}
if (!isEmpty(cameraOutputCap.photoProfiles)) {
console.info(TAG + "cameraOutputCap.photoProfiles.length: " + cameraOutputCap.photoProfiles.length);
for (let i = 0; i < cameraOutputCap.photoProfiles.length; i++) {
mPhotoOutput = mCameraManager.createPhotoOutput(cameraOutputCap.photoProfiles[i], mPhotoSurface);
if (!isEmpty(mPhotoOutput)) {
break;
}
}
if (isEmpty(mPhotoOutput)) {
console.info(TAG + "createPhotoOutput FAILED");
}
console.info(TAG + "createPhotoOutput: " + mPhotoOutput);
}
if (!isEmpty(cameraOutputCap.supportedMetadataObjectTypes)) {
mMetadataObjectTypeArray = cameraOutputCap.supportedMetadataObjectTypes;
if (isEmpty(mMetadataObjectTypeArray)) {
console.info(TAG + "mMetadataObjectTypeArray is null");
} else {
console.info(TAG + "createMetadataOutput")
metadataOutput = mCameraManager.createMetadataOutput(mMetadataObjectTypeArray);
}
}
console.info(TAG + 'Exit createOutputs');
return true;
}
describe('CameraErrorCodeUsecaseTest', function () {
console.info(TAG + '----------CameraErrorCodeUsecaseTest--------------');
beforeAll(async function () {
await getPhotoReceiverSurface();
await getvideosurface();
getCameraManagerInstance();
getCameraSupportDevicesArray();
console.info(TAG + 'beforeAll case');
})
beforeEach(function () {
sleep(1000);
console.info('beforeEach case');
})
afterEach(async function () {
console.info('afterEach case');
if (!isEmpty(mCameraInput)) {
await releaseInput();
}
if (!isEmpty(mCameraSession)) {
releaseCameraSessionInstance();
}
})
afterAll(function () {
releaseVideoReceiveSurface();
sleep(1000);
console.info('afterAll case');
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_CAMERA_INPUT_0100
* @tc.name : createCameraInput api
* @tc.desc : createCameraInput api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_CAMERA_INPUT_0100', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_CAMERA_INPUT_0100--------------");
if (isEmpty(mCameraManager)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_CAMERA_INPUT_0100 cameraManager == null || undefined")
expect().assertFail();
done();
} else {
try {
let camerainput = mCameraManager.createCameraInput();
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_CAMERA_INPUT_0100 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code == cameraObj.CameraErrorCode.INVALID_ARGUMENT).assertTrue();
expect(true).assertTrue();
}
done();
}
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_CAMERA_INPUT_0200
* @tc.name : createCameraInput api
* @tc.desc : createCameraInput api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_CAMERA_INPUT_0200', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_CAMERA_INPUT_0200--------------");
if (isEmpty(mCameraManager)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_CAMERA_INPUT_0200 cameraManager == null || undefined")
expect().assertFail();
done();
} else {
try {
let camerainput = mCameraManager.createCameraInput("cameraInput");
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_CAMERA_INPUT_0200 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code == cameraObj.CameraErrorCode.INVALID_ARGUMENT).assertTrue();
expect(true).assertTrue();
}
done();
}
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_CAMERA_INPUT_0300
* @tc.name : createCameraInput api
* @tc.desc : createCameraInput api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_CAMERA_INPUT_0300', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_CAMERA_INPUT_0300--------------");
if (isEmpty(mCameraManager)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_CAMERA_INPUT_0300 cameraManager == null || undefined")
expect().assertFail();
done();
} else {
try {
let camerainput = mCameraManager.createCameraInput(null,"cameraInput");
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_CAMERA_INPUT_0300 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code == cameraObj.CameraErrorCode.INVALID_ARGUMENT).assertTrue();
expect(true).assertTrue();
}
done();
}
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_CAMERA_INPUT_0400
* @tc.name : createCameraInput api
* @tc.desc : createCameraInput api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_CAMERA_INPUT_0400', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_CAMERA_INPUT_0400--------------");
if (isEmpty(mCameraManager)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_CAMERA_INPUT_0400 cameraManager == null || undefined")
expect().assertFail();
done();
} else {
try {
let camerainput = mCameraManager.createCameraInput(null);
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_CAMERA_INPUT_0400 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code == cameraObj.CameraErrorCode.INVALID_ARGUMENT).assertTrue();
expect(true).assertTrue();
}
done();
}
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_PREVIEW_OUTPUT_0100
* @tc.name : createPreviewOutput api
* @tc.desc : createPreviewOutput api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_PREVIEW_OUTPUT_0100', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_PREVIEW_OUTPUT_0100--------------");
if (isEmpty(mCameraManager)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_PREVIEW_OUTPUT_0100 cameraManager == null || undefined")
expect().assertFail();
done();
} else {
try {
let previewoutput = mCameraManager.createPreviewOutput(null);
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_PREVIEW_OUTPUT_0100 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code == cameraObj.CameraErrorCode.INVALID_ARGUMENT).assertTrue();
expect(true).assertTrue();
}
done();
}
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_PREVIEW_OUTPUT_0200
* @tc.name : createPreviewOutput api
* @tc.desc : createPreviewOutput api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_PREVIEW_OUTPUT_0200', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_PREVIEW_OUTPUT_0200--------------");
if (isEmpty(mCameraManager)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_PREVIEW_OUTPUT_0200 cameraManager == null || undefined")
expect().assertFail();
done();
} else {
try {
let previewoutput = mCameraManager.createPreviewOutput(null,"createoutput");
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_PREVIEW_OUTPUT_0200 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code == cameraObj.CameraErrorCode.INVALID_ARGUMENT).assertTrue();
expect(true).assertTrue();
}
done();
}
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_PHOTO_OUTPUT_0100
* @tc.name : createPhotoOutput api
* @tc.desc : createPhotoOutput api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_PHOTO_OUTPUT_0100', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_PHOTO_OUTPUT_0100--------------");
if (isEmpty(mCameraManager)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_PHOTO_OUTPUT_0100 cameraManager == null || undefined")
expect().assertFail();
done();
} else {
try {
let photooutput = mCameraManager.createPhotoOutput(null,"createoutput");
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_PHOTO_OUTPUT_0100 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code == cameraObj.CameraErrorCode.INVALID_ARGUMENT).assertTrue();
expect(true).assertTrue();
}
done();
}
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_PHOTO_OUTPUT_0200
* @tc.name : createPhotoOutput api
* @tc.desc : createPhotoOutput api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_PHOTO_OUTPUT_0200', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_PHOTO_OUTPUT_0200--------------");
if (isEmpty(mCameraManager)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_PHOTO_OUTPUT_0200 cameraManager == null || undefined")
expect().assertFail();
done();
} else {
try {
let photooutput = mCameraManager.createPhotoOutput(null);
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_PHOTO_OUTPUT_0200 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code == cameraObj.CameraErrorCode.INVALID_ARGUMENT).assertTrue();
expect(true).assertTrue();
}
done();
}
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_VIDEO_OUTPUT_0100
* @tc.name : createVideoOutput api
* @tc.desc : createVideoOutput api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_VIDEO_OUTPUT_0100', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_VIDEO_OUTPUT_0100--------------");
if (isEmpty(mCameraManager)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_VIDEO_OUTPUT_0100 cameraManager == null || undefined")
expect().assertFail();
done();
} else {
try {
let videooutput = mCameraManager.createVideoOutput(null);
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_VIDEO_OUTPUT_0100 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code == cameraObj.CameraErrorCode.INVALID_ARGUMENT).assertTrue();
expect(true).assertTrue();
}
done();
}
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_VIDEO_OUTPUT_0200
* @tc.name : createVideoOutput api
* @tc.desc : createVideoOutput api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_VIDEO_OUTPUT_0200', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_VIDEO_OUTPUT_0200--------------");
if (isEmpty(mCameraManager)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_VIDEO_OUTPUT_0200 cameraManager == null || undefined")
expect().assertFail();
done();
} else {
try {
let videooutput = mCameraManager.createVideoOutput(null,"createoutput");
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_VIDEO_OUTPUT_0200 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code == cameraObj.CameraErrorCode.INVALID_ARGUMENT).assertTrue();
expect(true).assertTrue();
}
done();
}
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_METADATA_OUTPUT_0100
* @tc.name : createMetadataOutput api
* @tc.desc : createMetadataOutput api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_METADATA_OUTPUT_0100', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_METADATA_OUTPUT_0100--------------");
if (isEmpty(mCameraManager)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_METADATA_OUTPUT_0100 cameraManager == null || undefined")
expect().assertFail();
done();
} else {
try {
let videooutput = mCameraManager.createMetadataOutput(null);
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_METADATA_OUTPUT_0100 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code == cameraObj.CameraErrorCode.INVALID_ARGUMENT).assertTrue();
expect(true).assertTrue();
}
done();
}
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_METADATA_OUTPUT_0200
* @tc.name : createMetadataOutput api
* @tc.desc : createMetadataOutput api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_METADATA_OUTPUT_0200', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_METADATA_OUTPUT_0200--------------");
if (isEmpty(mCameraManager)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_METADATA_OUTPUT_0200 cameraManager == null || undefined")
expect().assertFail();
done();
} else {
try {
let metadataoutput = mCameraManager.createMetadataOutput();
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CREATE_METADATA_OUTPUT_0200 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code == cameraObj.CameraErrorCode.INVALID_ARGUMENT).assertTrue();
expect(true).assertTrue();
}
done();
}
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_ADD_INPUT_0100
* @tc.name : addInput api
* @tc.desc : addInput api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_ADD_INPUT_0100', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_ADD_INPUT_0100--------------");
createCameraSessionInstance();
try {
mCameraSession.addInput(null);
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_ADD_INPUT_0100 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code == cameraObj.CameraErrorCode.INVALID_ARGUMENT).assertTrue();
expect(true).assertTrue();
}
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_ADD_INPUT_0200
* @tc.name : addInput api
* @tc.desc : addInput api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_ADD_INPUT_0200', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_ADD_INPUT_0200--------------");
createCameraSessionInstance();
try {
mCameraSession.addInput();
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_ADD_INPUT_0200 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code == cameraObj.CameraErrorCode.INVALID_ARGUMENT).assertTrue();
expect(true).assertTrue();
}
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_REMOVE_INPUT_0100
* @tc.name : removeInput api
* @tc.desc : removeInput api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_REMOVE_INPUT_0100', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_REMOVE_INPUT_0100--------------");
createCameraSessionInstance();
try {
mCameraSession.removeInput();
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_REMOVE_INPUT_0100 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code == cameraObj.CameraErrorCode.INVALID_ARGUMENT).assertTrue();
expect(true).assertTrue();
}
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_REMOVE_INPUT_0200
* @tc.name : removeInput api
* @tc.desc : removeInput api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_REMOVE_INPUT_0200', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_REMOVE_INPUT_0200--------------");
createCameraSessionInstance();
try {
mCameraSession.removeInput(null);
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_REMOVE_INPUT_0200 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code == cameraObj.CameraErrorCode.INVALID_ARGUMENT).assertTrue();
expect(true).assertTrue();
}
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_ADD_OUTPUT_0100
* @tc.name : addOutput api
* @tc.desc : addOutput api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_ADD_OUTPUT_0100', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_ADD_OUTPUT_0100--------------");
createCameraSessionInstance();
try {
mCameraSession.addOutput();
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_ADD_OUTPUT_0100 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code == cameraObj.CameraErrorCode.INVALID_ARGUMENT).assertTrue();
expect(true).assertTrue();
}
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_ADD_OUTPUT_0200
* @tc.name : addOutput api
* @tc.desc : addOutput api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_ADD_OUTPUT_0200', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_ADD_OUTPUT_0200--------------");
createCameraSessionInstance();
try {
mCameraSession.addOutput(null);
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_ADD_OUTPUT_0200 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code == cameraObj.CameraErrorCode.INVALID_ARGUMENT).assertTrue();
expect(true).assertTrue();
}
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_REMOVE_OUTPUT_0100
* @tc.name : removeOutput api
* @tc.desc : removeOutput api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_REMOVE_OUTPUT_0100', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_REMOVE_OUTPUT_0100--------------");
createCameraSessionInstance();
try {
mCameraSession.removeOutput();
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_REMOVE_OUTPUT_0100 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code == cameraObj.CameraErrorCode.INVALID_ARGUMENT).assertTrue();
expect(true).assertTrue();
}
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_REMOVE_OUTPUT_0200
* @tc.name : removeOutput api
* @tc.desc : removeOutput api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_REMOVE_OUTPUT_0200', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_REMOVE_OUTPUT_0200--------------");
createCameraSessionInstance();
try {
mCameraSession.removeOutput(null);
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_REMOVE_OUTPUT_0200 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code == cameraObj.CameraErrorCode.INVALID_ARGUMENT).assertTrue();
expect(true).assertTrue();
}
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_PHOTOOUTPUT_CAPTURE_0200
* @tc.name : photoOutput capture api
* @tc.desc : photoOutput capture api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_PHOTOOUTPUT_CAPTURE_0200', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_PHOTOOUTPUT_CAPTURE_0200--------------");
await createInput(0);
createCameraSessionInstance();
mCameraSession.addInput(mCameraInput);
createOutput(0);
mCameraSession.addOutput(mPreviewOutput);
mCameraSession.addOutput(mPhotoOutput);
await commitCameraSessionConfig();
await mCameraSession.start();
mPhotoOutput.capture({},async (err) => {
if (!err) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_PHOTOOUTPUT_CAPTURE_0200 success");
} else {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_PHOTOOUTPUT_CAPTURE_0200 FAILED");
console.info(TAG + "ERRORCODE: " + err.code);
expect(err.code == cameraObj.CameraErrorCode.INVALID_ARGUMENT).assertTrue();
}
})
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_PHOTOOUTPUT_CAPTURE_0400
* @tc.name : photoOutput capture api
* @tc.desc : photoOutput capture api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_PHOTOOUTPUT_CAPTURE_0400', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_PHOTOOUTPUT_CAPTURE_0400--------------");
await createInput(0);
createCameraSessionInstance();
mCameraSession.addInput(mCameraInput);
createOutput(0);
mCameraSession.addOutput(mPreviewOutput);
mCameraSession.addOutput(mPhotoOutput);
await commitCameraSessionConfig();
await mCameraSession.start();
await mPhotoOutput.capture({}).then((result) => {
console.info('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_PHOTOOUTPUT_CAPTURE_0400 success :' + result);
}).catch((err) => {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_PHOTOOUTPUT_CAPTURE_0400 FAILED");
console.info(TAG + "ERRORCODE: " + err.code);
expect(err.code == cameraObj.CameraErrorCode.INVALID_ARGUMENT).assertTrue();
expect(true).assertTrue();
});
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_COMMITCONFIG_0100
* @tc.name : commitConfig api
* @tc.desc : commitConfig api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_COMMITCONFIG_0100', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_COMMITCONFIG_0100--------------");
await createInput(0);
mCameraSession = mCameraManager.createCaptureSession();
mCameraSession.commitConfig(async (err) => {
if (!err) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_COMMITCONFIG_0100 success");
} else {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_COMMITCONFIG_0100 FAILED");
console.info(TAG + "ERRORCODE: " + err.code);
expect(err.code == cameraObj.CameraErrorCode.OPERATION_NOT_ALLOWED).assertTrue();
expect(true).assertTrue();
}
})
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_COMMITCONFIG_0200
* @tc.name : commitConfig api
* @tc.desc : commitConfig api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_COMMITCONFIG_0200', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_COMMITCONFIG_0200--------------");
await createInput(0);
mCameraSession = mCameraManager.createCaptureSession();
await mCameraSession.commitConfig().then((result) => {
console.info('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_COMMITCONFIG_0200 success :' + result);
}).catch((err) => {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_COMMITCONFIG_0200 FAILED");
console.info(TAG + "ERRORCODE: " + err.code);
expect(err.code == cameraObj.CameraErrorCode.OPERATION_NOT_ALLOWED).assertTrue();
expect(true).assertTrue();
});
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_ADD_INPUT_0300
* @tc.name : addInput api
* @tc.desc : addInput api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_ADD_INPUT_0300', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_ADD_INPUT_0300--------------");
await createInput(0);
mCameraSession = mCameraManager.createCaptureSession();
try {
mCameraSession.addInput(mCameraInput);
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_ADD_INPUT_0300 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code == cameraObj.CameraErrorCode.OPERATION_NOT_ALLOWED).assertTrue();
expect(true).assertTrue();
}
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_REMOVE_INPUT_0300
* @tc.name : removeInput api
* @tc.desc : removeInput api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_REMOVE_INPUT_0300', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_REMOVE_INPUT_0300--------------");
await createInput(0);
mCameraSession = mCameraManager.createCaptureSession();
try {
mCameraSession.removeInput(mCameraInput);
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_REMOVE_INPUT_0300 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code == cameraObj.CameraErrorCode.OPERATION_NOT_ALLOWED).assertTrue();
expect(true).assertTrue();
}
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_ADD_OUTPUT_0300
* @tc.name : addOutput api
* @tc.desc : addOutput api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_ADD_OUTPUT_0300', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_ADD_OUTPUT_0300--------------");
await createInput(0);
mCameraSession = mCameraManager.createCaptureSession();
createOutput(0);
try {
mCameraSession.addOutput(mPreviewOutput);
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_ADD_OUTPUT_0300 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code == cameraObj.CameraErrorCode.OPERATION_NOT_ALLOWED).assertTrue();
expect(true).assertTrue();
}
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_REMOVE_OUTPUT_0300
* @tc.name : removeOutput api
* @tc.desc : removeOutput api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_REMOVE_OUTPUT_0300', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_REMOVE_OUTPUT_0300--------------");
await createInput(0);
mCameraSession = mCameraManager.createCaptureSession();
createOutput(0);
try {
mCameraSession.removeOutput(mPreviewOutput);
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_REMOVE_OUTPUT_0300 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code == cameraObj.CameraErrorCode.OPERATION_NOT_ALLOWED).assertTrue();
expect(true).assertTrue();
}
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_START_0100
* @tc.name : capturesession start api
* @tc.desc : capturesession start api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_START_0100', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_START_0100--------------");
await createInput(0);
createCameraSessionInstance();
mCameraSession.addInput(mCameraInput);
createOutput(0);
mCameraSession.addOutput(mPreviewOutput);
mCameraSession.addOutput(mPhotoOutput);
mCameraSession.start().then((result) => {
console.info('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_START_0100 success :' + result);
}).catch((err) => {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_START_0100 FAILED");
console.info(TAG + "ERRORCODE: " + err.code);
console.info(TAG + "cameraObj.CameraErrorCode.SESSION_NOT_CONFIG: " + cameraObj.CameraErrorCode.SESSION_NOT_CONFIG);
expect(err.code == cameraObj.CameraErrorCode.SESSION_NOT_CONFIG).assertTrue();
expect(true).assertTrue();
});
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_START_0200
* @tc.name : capturesession start api
* @tc.desc : capturesession start api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_START_0200', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_START_0200--------------");
await createInput(0);
createCameraSessionInstance();
mCameraSession.addInput(mCameraInput);
createOutput(0);
mCameraSession.addOutput(mPreviewOutput);
mCameraSession.addOutput(mPhotoOutput);
mCameraSession.start(async (err) => {
if (!err) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_START_0200 success");
} else {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_START_0200 FAILED");
console.info(TAG + "ERRORCODE: " + err.code);
console.info(TAG + "cameraObj.CameraErrorCode.SESSION_NOT_CONFIG: " + cameraObj.CameraErrorCode.SESSION_NOT_CONFIG);
expect(err.code == cameraObj.CameraErrorCode.SESSION_NOT_CONFIG).assertTrue();
}
})
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_HASFLASH_0100
* @tc.name : capturesession hasFlash api
* @tc.desc : capturesession hasFlash api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_HASFLASH_0100', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_HASFLASH_0100--------------");
await createInput(0);
createCameraSessionInstance();
mCameraSession.addInput(mCameraInput);
createOutput(0);
mCameraSession.addOutput(mPreviewOutput);
mCameraSession.addOutput(mPhotoOutput);
try{
let isFlash = mCameraSession.hasFlash();
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_HASFLASH_0100 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
console.info(TAG + "cameraObj.CameraErrorCode.SESSION_NOT_CONFIG: " + cameraObj.CameraErrorCode.SESSION_NOT_CONFIG);
expect(error.code == cameraObj.CameraErrorCode.SESSION_NOT_CONFIG).assertTrue();
};
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_ISFLASHMODESUPPORTED_0100
* @tc.name : capturesession isFlashModeSupported api
* @tc.desc : capturesession isFlashModeSupported api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_ISFLASHMODESUPPORTED_0100', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_ISFLASHMODESUPPORTED_0100--------------");
await createInput(0);
createCameraSessionInstance();
mCameraSession.addInput(mCameraInput);
createOutput(0);
mCameraSession.addOutput(mPreviewOutput);
mCameraSession.addOutput(mPhotoOutput);
try{
let isFlashmodesupported = mCameraSession.isFlashModeSupported(cameraObj.FlashMode.FLASH_MODE_AUTO);
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_ISFLASHMODESUPPORTED_0100 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code == cameraObj.CameraErrorCode.SESSION_NOT_CONFIG).assertTrue();
expect(true).assertTrue();
};
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_GETFLASHMODE_0100
* @tc.name : capturesession getFlashMode api
* @tc.desc : capturesession getFlashMode api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_GETFLASHMODE_0100', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_GETFLASHMODE_0100--------------");
await createInput(0);
createCameraSessionInstance();
mCameraSession.addInput(mCameraInput);
createOutput(0);
mCameraSession.addOutput(mPreviewOutput);
mCameraSession.addOutput(mPhotoOutput);
try{
let flashmode = mCameraSession.getFlashMode();
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_GETFLASHMODE_0100 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code == cameraObj.CameraErrorCode.SESSION_NOT_CONFIG).assertTrue();
expect(true).assertTrue();
};
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETFLASHMODE_0100
* @tc.name : capturesession setFlashMode api
* @tc.desc : capturesession setFlashMode api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETFLASHMODE_0100', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETFLASHMODE_0100--------------");
await createInput(0);
createCameraSessionInstance();
mCameraSession.addInput(mCameraInput);
createOutput(0);
mCameraSession.addOutput(mPreviewOutput);
mCameraSession.addOutput(mPhotoOutput);
try{
mCameraSession.setFlashMode(cameraObj.FlashMode.FLASH_MODE_AUTO);
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETFLASHMODE_0100 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code == cameraObj.CameraErrorCode.SESSION_NOT_CONFIG).assertTrue();
expect(true).assertTrue();
};
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETFLASHMODE_0101
* @tc.name : capturesession setFlashMode api
* @tc.desc : capturesession setFlashMode api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETFLASHMODE_0101', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETFLASHMODE_0101--------------");
await createInput(0);
createCameraSessionInstance();
mCameraSession.addInput(mCameraInput);
createOutput(0);
mCameraSession.addOutput(mPreviewOutput);
mCameraSession.addOutput(mPhotoOutput);
await commitCameraSessionConfig();
await mCameraSession.start();
try{
mCameraSession.setFlashMode(5);
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETFLASHMODE_0101 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code != cameraObj.CameraErrorCode.SESSION_NOT_CONFIG).assertTrue();
};
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_ISEXPOSUREMODESUPPORTED_0100
* @tc.name : capturesession isExposureModeSupported api
* @tc.desc : capturesession isExposureModeSupported api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_ISEXPOSUREMODESUPPORTED_0100', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_ISEXPOSUREMODESUPPORTED_0100--------------");
await createInput(0);
createCameraSessionInstance();
mCameraSession.addInput(mCameraInput);
createOutput(0);
mCameraSession.addOutput(mPreviewOutput);
mCameraSession.addOutput(mPhotoOutput);
try{
let issupported = mCameraSession.isExposureModeSupported(cameraObj.ExposureMode.EXPOSURE_MODE_AUTO);
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_ISEXPOSUREMODESUPPORTED_0100 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code == cameraObj.CameraErrorCode.SESSION_NOT_CONFIG).assertTrue();
expect(true).assertTrue();
};
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_GETEXPOSUREMODE_0100
* @tc.name : capturesession getExposureMode api
* @tc.desc : capturesession getExposureMode api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_GETEXPOSUREMODE_0100', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_GETEXPOSUREMODE_0100--------------");
await createInput(0);
createCameraSessionInstance();
mCameraSession.addInput(mCameraInput);
createOutput(0);
mCameraSession.addOutput(mPreviewOutput);
mCameraSession.addOutput(mPhotoOutput);
try{
let exposure = mCameraSession.getExposureMode();
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_GETEXPOSUREMODE_0100 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code == cameraObj.CameraErrorCode.SESSION_NOT_CONFIG).assertTrue();
expect(true).assertTrue();
};
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETEXPOSUREMODE_0100
* @tc.name : capturesession setExposureMode api
* @tc.desc : capturesession setExposureMode api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETEXPOSUREMODE_0100', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETEXPOSUREMODE_0100--------------");
await createInput(0);
createCameraSessionInstance();
mCameraSession.addInput(mCameraInput);
createOutput(0);
mCameraSession.addOutput(mPreviewOutput);
mCameraSession.addOutput(mPhotoOutput);
try{
mCameraSession.setExposureMode(cameraObj.ExposureMode.EXPOSURE_MODE_AUTO);
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETEXPOSUREMODE_0100 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code == cameraObj.CameraErrorCode.SESSION_NOT_CONFIG).assertTrue();
};
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETEXPOSUREMODE_0101
* @tc.name : capturesession setExposureMode api
* @tc.desc : capturesession setExposureMode api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETEXPOSUREMODE_0101', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETEXPOSUREMODE_0101--------------");
await createInput(0);
createCameraSessionInstance();
mCameraSession.addInput(mCameraInput);
createOutput(0);
mCameraSession.addOutput(mPreviewOutput);
mCameraSession.addOutput(mPhotoOutput);
await commitCameraSessionConfig();
await mCameraSession.start();
try{
mCameraSession.setExposureMode(5);
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETEXPOSUREMODE_0101 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code != cameraObj.CameraErrorCode.SESSION_NOT_CONFIG).assertTrue();
};
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_GETMETERINGPOINT_0100
* @tc.name : capturesession getMeteringPoint api
* @tc.desc : capturesession getMeteringPoint api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_GETMETERINGPOINT_0100', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_GETMETERINGPOINT_0100--------------");
await createInput(0);
createCameraSessionInstance();
mCameraSession.addInput(mCameraInput);
createOutput(0);
mCameraSession.addOutput(mPreviewOutput);
mCameraSession.addOutput(mPhotoOutput);
try{
let point = mCameraSession.getMeteringPoint();
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_GETMETERINGPOINT_0100 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code == cameraObj.CameraErrorCode.SESSION_NOT_CONFIG).assertTrue();
expect(true).assertTrue();
};
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETMETERINGPOINT_0100
* @tc.name : capturesession setMeteringPoint api
* @tc.desc : capturesession setMeteringPoint api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETMETERINGPOINT_0100', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETMETERINGPOINT_0100--------------");
await createInput(0);
createCameraSessionInstance();
mCameraSession.addInput(mCameraInput);
createOutput(0);
mCameraSession.addOutput(mPreviewOutput);
mCameraSession.addOutput(mPhotoOutput);
try{
mCameraSession.setMeteringPoint({x:1,y:1});
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETMETERINGPOINT_0100 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code == cameraObj.CameraErrorCode.SESSION_NOT_CONFIG).assertTrue();
expect(true).assertTrue();
};
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETMETERINGPOINT_0101
* @tc.name : capturesession setMeteringPoint api
* @tc.desc : capturesession setMeteringPoint api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETMETERINGPOINT_0101', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETMETERINGPOINT_0101--------------");
await createInput(0);
createCameraSessionInstance();
mCameraSession.addInput(mCameraInput);
createOutput(0);
mCameraSession.addOutput(mPreviewOutput);
mCameraSession.addOutput(mPhotoOutput);
await commitCameraSessionConfig();
await mCameraSession.start();
try{
mCameraSession.setMeteringPoint({x:-1,y:-1});
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETMETERINGPOINT_0101 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code != cameraObj.CameraErrorCode.SESSION_NOT_CONFIG).assertTrue();
};
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_GETEXPOSUREBIASRANGE_0100
* @tc.name : capturesession getExposureBiasRange api
* @tc.desc : capturesession getExposureBiasRange api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_GETEXPOSUREBIASRANGE_0100', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_GETEXPOSUREBIASRANGE_0100--------------");
await createInput(0);
createCameraSessionInstance();
mCameraSession.addInput(mCameraInput);
createOutput(0);
mCameraSession.addOutput(mPreviewOutput);
mCameraSession.addOutput(mPhotoOutput);
try{
let range = mCameraSession.getExposureBiasRange();
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_GETEXPOSUREBIASRANGE_0100 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code == cameraObj.CameraErrorCode.SESSION_NOT_CONFIG).assertTrue();
expect(true).assertTrue();
};
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETEXPOSUREBIAS_0100
* @tc.name : capturesession setExposureBias api
* @tc.desc : capturesession setExposureBias api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETEXPOSUREBIAS_0100', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETEXPOSUREBIAS_0100--------------");
await createInput(0);
createCameraSessionInstance();
mCameraSession.addInput(mCameraInput);
createOutput(0);
mCameraSession.addOutput(mPreviewOutput);
mCameraSession.addOutput(mPhotoOutput);
try{
let range = mCameraSession.getExposureBiasRange();
mCameraSession.setExposureBias(range[0]);
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETEXPOSUREBIAS_0100 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code == cameraObj.CameraErrorCode.SESSION_NOT_CONFIG).assertTrue();
expect(true).assertTrue();
};
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETEXPOSUREBIAS_0101
* @tc.name : capturesession setExposureBias api
* @tc.desc : capturesession setExposureBias api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETEXPOSUREBIAS_0101', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETEXPOSUREBIAS_0101--------------");
await createInput(0);
createCameraSessionInstance();
mCameraSession.addInput(mCameraInput);
createOutput(0);
mCameraSession.addOutput(mPreviewOutput);
mCameraSession.addOutput(mPhotoOutput);
await commitCameraSessionConfig();
await mCameraSession.start();
try{
let range = mCameraSession.getExposureBiasRange();
mCameraSession.setExposureBias(-101);
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETEXPOSUREBIAS_0101 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code != cameraObj.CameraErrorCode.SESSION_NOT_CONFIG).assertTrue();
};
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_GETEXPOSUREVALUE_0100
* @tc.name : capturesession getExposureValue api
* @tc.desc : capturesession getExposureValue api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_GETEXPOSUREVALUE_0100', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_GETEXPOSUREVALUE_0100--------------");
await createInput(0);
createCameraSessionInstance();
mCameraSession.addInput(mCameraInput);
createOutput(0);
mCameraSession.addOutput(mPreviewOutput);
mCameraSession.addOutput(mPhotoOutput);
try{
let value = mCameraSession.getExposureValue();
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_GETEXPOSUREVALUE_0100 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code == cameraObj.CameraErrorCode.SESSION_NOT_CONFIG).assertTrue();
expect(true).assertTrue();
};
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_ISFOCUSMODESUPPORTED_0100
* @tc.name : capturesession isFocusModeSupported api
* @tc.desc : capturesession isFocusModeSupported api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_ISFOCUSMODESUPPORTED_0100', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_ISFOCUSMODESUPPORTED_0100--------------");
await createInput(0);
createCameraSessionInstance();
mCameraSession.addInput(mCameraInput);
createOutput(0);
mCameraSession.addOutput(mPreviewOutput);
mCameraSession.addOutput(mPhotoOutput);
try{
let issupported = mCameraSession.isFocusModeSupported(cameraObj.FocusMode.FOCUS_MODE_AUTO);
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_ISFOCUSMODESUPPORTED_0100 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code == cameraObj.CameraErrorCode.SESSION_NOT_CONFIG).assertTrue();
expect(true).assertTrue();
};
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_GETFOCUSMODE_0100
* @tc.name : capturesession getFocusMode api
* @tc.desc : capturesession getFocusMode api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_GETFOCUSMODE_0100', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_GETFOCUSMODE_0100--------------");
await createInput(0);
createCameraSessionInstance();
mCameraSession.addInput(mCameraInput);
createOutput(0);
mCameraSession.addOutput(mPreviewOutput);
mCameraSession.addOutput(mPhotoOutput);
try{
let focusmode = mCameraSession.getFocusMode();
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_GETFOCUSMODE_0100 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code == cameraObj.CameraErrorCode.SESSION_NOT_CONFIG).assertTrue();
expect(true).assertTrue();
};
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETFOCUSMODE_0100
* @tc.name : capturesession setFocusMode api
* @tc.desc : capturesession setFocusMode api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETFOCUSMODE_0100', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETFOCUSMODE_0100--------------");
await createInput(0);
createCameraSessionInstance();
mCameraSession.addInput(mCameraInput);
createOutput(0);
mCameraSession.addOutput(mPreviewOutput);
mCameraSession.addOutput(mPhotoOutput);
try{
mCameraSession.setFocusMode(cameraObj.FocusMode.FOCUS_MODE_MANUAL);
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETFOCUSMODE_0100 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code == cameraObj.CameraErrorCode.SESSION_NOT_CONFIG).assertTrue();
};
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETFOCUSMODE_0101
* @tc.name : capturesession setFocusMode api
* @tc.desc : capturesession setFocusMode api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETFOCUSMODE_0101', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETFOCUSMODE_0101--------------");
await createInput(0);
createCameraSessionInstance();
mCameraSession.addInput(mCameraInput);
createOutput(0);
mCameraSession.addOutput(mPreviewOutput);
mCameraSession.addOutput(mPhotoOutput);
await commitCameraSessionConfig();
await mCameraSession.start();
try{
mCameraSession.setFocusMode(5);
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETFOCUSMODE_0101 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code != cameraObj.CameraErrorCode.SESSION_NOT_CONFIG).assertTrue();
};
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETFOCUSPOINT_0100
* @tc.name : capturesession setFocusPoint api
* @tc.desc : capturesession setFocusPoint api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETFOCUSPOINT_0100', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETFOCUSPOINT_0100--------------");
await createInput(0);
createCameraSessionInstance();
mCameraSession.addInput(mCameraInput);
createOutput(0);
mCameraSession.addOutput(mPreviewOutput);
mCameraSession.addOutput(mPhotoOutput);
try{
mCameraSession.setFocusPoint({x:1,y:1});
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETFOCUSPOINT_0100 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code == cameraObj.CameraErrorCode.SESSION_NOT_CONFIG).assertTrue();
expect(true).assertTrue();
};
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETFOCUSPOINT_0101
* @tc.name : capturesession setFocusPoint api
* @tc.desc : capturesession setFocusPoint api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETFOCUSPOINT_0101', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETFOCUSPOINT_0101--------------");
await createInput(0);
createCameraSessionInstance();
mCameraSession.addInput(mCameraInput);
createOutput(0);
mCameraSession.addOutput(mPreviewOutput);
mCameraSession.addOutput(mPhotoOutput);
await commitCameraSessionConfig();
await mCameraSession.start();
try{
mCameraSession.setFocusPoint({x:-1,y:-1});
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETFOCUSPOINT_0101 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code != cameraObj.CameraErrorCode.SESSION_NOT_CONFIG).assertTrue();
};
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_GETFOCUSPOINT_0100
* @tc.name : capturesession getFocusPoint api
* @tc.desc : capturesession getFocusPoint api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_GETFOCUSPOINT_0100', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_GETFOCUSPOINT_0100--------------");
await createInput(0);
createCameraSessionInstance();
mCameraSession.addInput(mCameraInput);
createOutput(0);
mCameraSession.addOutput(mPreviewOutput);
mCameraSession.addOutput(mPhotoOutput);
try{
let point = mCameraSession.getFocusPoint();
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_GETFOCUSPOINT_0100 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code == cameraObj.CameraErrorCode.SESSION_NOT_CONFIG).assertTrue();
expect(true).assertTrue();
};
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_GETFOCUSLENGTH_0100
* @tc.name : capturesession getFocalLength api
* @tc.desc : capturesession getFocalLength api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_GETFOCUSLENGTH_0100', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_GETFOCUSLENGTH_0100--------------");
await createInput(0);
createCameraSessionInstance();
mCameraSession.addInput(mCameraInput);
createOutput(0);
mCameraSession.addOutput(mPreviewOutput);
mCameraSession.addOutput(mPhotoOutput);
try{
let length = mCameraSession.getFocalLength();
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_GETFOCUSLENGTH_0100 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code == cameraObj.CameraErrorCode.SESSION_NOT_CONFIG).assertTrue();
expect(true).assertTrue();
};
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_GETZOOMRATIORANG_0100
* @tc.name : capturesession getZoomRatioRange api
* @tc.desc : capturesession getZoomRatioRange api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_GETZOOMRATIORANG_0100', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_GETZOOMRATIORANG_0100--------------");
await createInput(0);
createCameraSessionInstance();
mCameraSession.addInput(mCameraInput);
createOutput(0);
mCameraSession.addOutput(mPreviewOutput);
mCameraSession.addOutput(mPhotoOutput);
try{
let zoomratiorange = mCameraSession.getZoomRatioRange();
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_GETZOOMRATIORANG_0100 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code == cameraObj.CameraErrorCode.SESSION_NOT_CONFIG).assertTrue();
expect(true).assertTrue();
};
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_GETZOOMRATIO_0100
* @tc.name : capturesession getZoomRatio api
* @tc.desc : capturesession getZoomRatio api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_GETZOOMRATIO_0100', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_GETZOOMRATIO_0100--------------");
await createInput(0);
createCameraSessionInstance();
mCameraSession.addInput(mCameraInput);
createOutput(0);
mCameraSession.addOutput(mPreviewOutput);
mCameraSession.addOutput(mPhotoOutput);
try{
let zoomratio = mCameraSession.getZoomRatio();
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_GETZOOMRATIO_0100 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code == cameraObj.CameraErrorCode.SESSION_NOT_CONFIG).assertTrue();
expect(true).assertTrue();
};
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETZOOMRATIO_0100
* @tc.name : capturesession setZoomRatio api
* @tc.desc : capturesession setZoomRatio api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETZOOMRATIO_0100', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETZOOMRATIO_0100--------------");
await createInput(0);
createCameraSessionInstance();
mCameraSession.addInput(mCameraInput);
createOutput(0);
mCameraSession.addOutput(mPreviewOutput);
mCameraSession.addOutput(mPhotoOutput);
try{
let zoomratiorange = mCameraSession.getZoomRatioRange();
mCameraSession.setZoomRatio(zoomratiorange[0]);
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETZOOMRATIO_0100 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code == cameraObj.CameraErrorCode.SESSION_NOT_CONFIG).assertTrue();
expect(true).assertTrue();
};
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETZOOMRATIO_0101
* @tc.name : capturesession setZoomRatio api
* @tc.desc : capturesession setZoomRatio api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETZOOMRATIO_0101', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETZOOMRATIO_0101--------------");
await createInput(0);
createCameraSessionInstance();
mCameraSession.addInput(mCameraInput);
createOutput(0);
mCameraSession.addOutput(mPreviewOutput);
mCameraSession.addOutput(mPhotoOutput);
await commitCameraSessionConfig();
await mCameraSession.start();
try{
let zoomratiorange = mCameraSession.getZoomRatioRange();
mCameraSession.setZoomRatio(-101);
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETZOOMRATIO_0101 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code != cameraObj.CameraErrorCode.SESSION_NOT_CONFIG).assertTrue();
};
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_ISVSMS_0100
* @tc.name : capturesession isVideoStabilizationModeSupported api
* @tc.desc : capturesession isVideoStabilizationModeSupported api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_ISVSMS_0100', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_ISVSMS_0100--------------");
await createInput(0);
createCameraSessionInstance();
mCameraSession.addInput(mCameraInput);
createOutput(0);
mCameraSession.addOutput(mPreviewOutput);
mCameraSession.addOutput(mPhotoOutput);
try{
let isVSMS = mCameraSession.isVideoStabilizationModeSupported(cameraObj.VideoStabilizationMode.LOW);
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_ISVSMS_0100 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code == cameraObj.CameraErrorCode.SESSION_NOT_CONFIG).assertTrue();
expect(true).assertTrue();
};
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_AVSTMODE_0100
* @tc.name : capturesession getActiveVideoStabilizationMode api
* @tc.desc : capturesession getActiveVideoStabilizationMode api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_AVSTMODE_0100', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_AVSTMODE_0100--------------");
await createInput(0);
createCameraSessionInstance();
mCameraSession.addInput(mCameraInput);
createOutput(0);
mCameraSession.addOutput(mPreviewOutput);
mCameraSession.addOutput(mPhotoOutput);
try{
let avstmode = mCameraSession.getActiveVideoStabilizationMode();
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_AVSTMODE_0100 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code == cameraObj.CameraErrorCode.SESSION_NOT_CONFIG).assertTrue();
expect(true).assertTrue();
};
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETVSTMODE_0100
* @tc.name : capturesession setVideoStabilizationMode api
* @tc.desc : capturesession setVideoStabilizationMode api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETVSTMODE_0100', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETVSTMODE_0100--------------");
await createInput(0);
createCameraSessionInstance();
mCameraSession.addInput(mCameraInput);
createOutput(0);
mCameraSession.addOutput(mPreviewOutput);
mCameraSession.addOutput(mPhotoOutput);
try{
mCameraSession.setVideoStabilizationMode(cameraObj.VideoStabilizationMode.LOW);
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETVSTMODE_0100 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code == cameraObj.CameraErrorCode.SESSION_NOT_CONFIG).assertTrue();
expect(true).assertTrue();
};
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETVSTMODE_0101
* @tc.name : capturesession setVideoStabilizationMode api
* @tc.desc : capturesession setVideoStabilizationMode api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETVSTMODE_0101', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETVSTMODE_0101--------------");
await createInput(0);
createCameraSessionInstance();
mCameraSession.addInput(mCameraInput);
createOutput(0);
mCameraSession.addOutput(mPreviewOutput);
mCameraSession.addOutput(mPhotoOutput);
await commitCameraSessionConfig();
await mCameraSession.start();
try{
mCameraSession.setVideoStabilizationMode(5);
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAPTURESESSION_SETVSTMODE_0101 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code != cameraObj.CameraErrorCode.SESSION_NOT_CONFIG).assertTrue();
};
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_PREVIEW_START_0100
* @tc.name : PreviewOutput start api
* @tc.desc : PreviewOutput start api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_PREVIEW_START_0100', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_PREVIEW_START_0100--------------");
await createInput(0);
createCameraSessionInstance();
mCameraSession.addInput(mCameraInput);
createOutput(0);
mCameraSession.addOutput(mPreviewOutput);
mCameraSession.addOutput(mPhotoOutput);
mPreviewOutput.start(async (err) => {
if (!err) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_PREVIEW_START_0100 success");
} else {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_PREVIEW_START_0100 FAILED");
console.info(TAG + "ERRORCODE: " + err.code);
expect(err.code == cameraObj.CameraErrorCode.SESSION_NOT_CONFIG).assertTrue();
expect(true).assertTrue();
}
})
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_PREVIEW_START_0200
* @tc.name : PreviewOutput start api
* @tc.desc : PreviewOutput start api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_PREVIEW_START_0200', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_PREVIEW_START_0200--------------");
await createInput(0);
createCameraSessionInstance();
mCameraSession.addInput(mCameraInput);
createOutput(0);
mCameraSession.addOutput(mPreviewOutput);
mCameraSession.addOutput(mPhotoOutput);
await mPreviewOutput.start().then((result) => {
console.info('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_PREVIEW_START_0200 success :' + result);
}).catch((err) => {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_PREVIEW_START_0200 FAILED");
console.info(TAG + "ERRORCODE: " + err.code);
expect(err.code == cameraObj.CameraErrorCode.SESSION_NOT_CONFIG).assertTrue();
});
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_VIDEO_START_0100
* @tc.name : videooutput start api
* @tc.desc : videooutput start api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_VIDEO_START_0100', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_VIDEO_START_0100--------------");
await createInput(0);
createCameraSessionInstance();
mCameraSession.addInput(mCameraInput);
createOutput(0);
if (!isEmpty(cameraOutputCap.videoProfiles)) {
for (let i = 0; i < cameraOutputCap.videoProfiles.length; i++) {
videoOutput = mCameraManager.createVideoOutput(cameraOutputCap.videoProfiles[i], videoSurfaceId);
if (!isEmpty(videoOutput)) {
break;
}
}
}
mCameraSession.addOutput(mPreviewOutput);
if (!isEmpty(videoOutput)) {
mCameraSession.addOutput(videoOutput);
videoOutput.start(async (err) => {
if (!err) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_VIDEO_START_0100 success");
} else {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_VIDEO_START_0100 FAILED");
console.info(TAG + "ERRORCODE: " + err.code);
expect(err.code == cameraObj.CameraErrorCode.SESSION_NOT_CONFIG).assertTrue();
expect(true).assertTrue();
}
})
}
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_VIDEO_START_0200
* @tc.name : videooutput start api
* @tc.desc : videooutput start api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_VIDEO_START_0200', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_VIDEO_START_0200--------------");
await createInput(0);
createCameraSessionInstance();
mCameraSession.addInput(mCameraInput);
createOutput(0);
mCameraSession.addOutput(mPreviewOutput);
if (!isEmpty(videoOutput)) {
mCameraSession.addOutput(videoOutput);
await videoOutput.start().then((result) => {
console.info('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_VIDEO_START_0200 success :' + result);
}).catch((err) => {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_VIDEO_START_0200 FAILED");
console.info(TAG + "ERRORCODE: " + err.code);
expect(err.code == cameraObj.CameraErrorCode.SESSION_NOT_CONFIG).assertTrue();
});
}
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_METADATAOUTPUT_START_0100
* @tc.name : MetadataOutput start api
* @tc.desc : MetadataOutput start api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_METADATAOUTPUT_START_0100', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_METADATAOUTPUT_START_0100--------------");
await createInput(0);
createCameraSessionInstance();
mCameraSession.addInput(mCameraInput);
createOutput(0);
if (isEmpty(metadataOutput)) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_METADATAOUTPUT_START_0100 metadataOutput IS NULL");
} else {
mCameraSession.addOutput(metadataOutput);
metadataOutput.start(async (err) => {
if (!err) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_METADATAOUTPUT_START_0100 success");
} else {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_METADATAOUTPUT_START_0100 FAILED");
console.info(TAG + "ERRORCODE: " + err.code);
expect(err.code == cameraObj.CameraErrorCode.SESSION_NOT_CONFIG).assertTrue();
expect(true).assertTrue();
}
})
}
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_METADATAOUTPUT_START_0200
* @tc.name : metadataOutput start api
* @tc.desc : metadataOutput start api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_METADATAOUTPUT_START_0200', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_METADATAOUTPUT_START_0200--------------");
await createInput(0);
createCameraSessionInstance();
mCameraSession.addInput(mCameraInput);
createOutput(0);
if (isEmpty(metadataOutput)) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_METADATAOUTPUT_START_0200 metadataOutput IS NULL");
} else {
mCameraSession.addOutput(metadataOutput);
await metadataOutput.start().then((result) => {
console.info('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_METADATAOUTPUT_START_0200 success :' + result);
}).catch((err) => {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_METADATAOUTPUT_START_0200 FAILED");
console.info(TAG + "ERRORCODE: " + err.code);
expect(err.code == cameraObj.CameraErrorCode.SESSION_NOT_CONFIG).assertTrue();
expect(true).assertTrue();
});
}
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_PHOTOOUTPUT_CAPTURE_0500
* @tc.name : photoOutput capture api
* @tc.desc : photoOutput capture api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_PHOTOOUTPUT_CAPTURE_0500', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_PHOTOOUTPUT_CAPTURE_0500--------------");
await createInput(0);
createCameraSessionInstance();
mCameraSession.addInput(mCameraInput);
createOutput(0);
mCameraSession.addOutput(mPreviewOutput);
mCameraSession.addOutput(mPhotoOutput);
await commitCameraSessionConfig();
try {
await mPhotoOutput.capture();
} catch (err) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_PHOTOOUTPUT_CAPTURE_0500 FAILED");
console.info(TAG + "ERRORCODE: " + err.code);
expect(err.code == cameraObj.CameraErrorCode.SESSION_NOT_RUNNING).assertTrue();
expect(true).assertTrue();
}
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_PHOTOOUTPUT_CAPTURE_0600
* @tc.name : photoOutput capture api
* @tc.desc : photoOutput capture api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_PHOTOOUTPUT_CAPTURE_0600', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_PHOTOOUTPUT_CAPTURE_0600--------------");
await createInput(0);
createCameraSessionInstance();
mCameraSession.addInput(mCameraInput);
createOutput(0);
mCameraSession.addOutput(mPreviewOutput);
mCameraSession.addOutput(mPhotoOutput);
await commitCameraSessionConfig();
mPhotoOutput.capture(async (err) => {
if (!err) {
expect(true).assertTrue();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_PHOTOOUTPUT_CAPTURE_0600 success");
} else {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_PHOTOOUTPUT_CAPTURE_0600 FAILED");
console.info(TAG + "ERRORCODE: " + err.code);
expect(err.code == cameraObj.CameraErrorCode.SESSION_NOT_RUNNING).assertTrue();
}
})
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_PHOTOOUTPUT_CAPTURE_0700
* @tc.name : photoOutput capture api
* @tc.desc : photoOutput capture api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_PHOTOOUTPUT_CAPTURE_0700', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_PHOTOOUTPUT_CAPTURE_0700--------------");
await createInput(0);
createCameraSessionInstance();
mCameraSession.addInput(mCameraInput);
createOutput(0);
mCameraSession.addOutput(mPreviewOutput);
mCameraSession.addOutput(mPhotoOutput);
await commitCameraSessionConfig();
mPhotoOutput.capture(captureSetting,async (err) => {
if (!err) {
expect(true).assertTrue();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_PHOTOOUTPUT_CAPTURE_0700 success");
} else {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_PHOTOOUTPUT_CAPTURE_0700 FAILED");
console.info(TAG + "ERRORCODE: " + err.code);
expect(err.code == cameraObj.CameraErrorCode.SESSION_NOT_RUNNING).assertTrue();
}
})
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_PHOTOOUTPUT_CAPTURE_0800
* @tc.name : photoOutput capture api
* @tc.desc : photoOutput capture api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_PHOTOOUTPUT_CAPTURE_0800', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_PHOTOOUTPUT_CAPTURE_0800--------------");
await createInput(0);
createCameraSessionInstance();
mCameraSession.addInput(mCameraInput);
createOutput(0);
mCameraSession.addOutput(mPreviewOutput);
mCameraSession.addOutput(mPhotoOutput);
await commitCameraSessionConfig();
try {
await mPhotoOutput.capture(captureSetting);
} catch (err) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_PHOTOOUTPUT_CAPTURE_0800 FAILED");
console.info(TAG + "ERRORCODE: " + err.code);
expect(err.code == cameraObj.CameraErrorCode.SESSION_NOT_RUNNING).assertTrue();
expect(true).assertTrue();
}
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_BEGINCONFIG_0100
* @tc.name : capturesession beginConfig api
* @tc.desc : capturesession beginConfig api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_BEGINCONFIG_0100', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_BEGINCONFIG_0100--------------");
await createInput(0);
mCameraSession = mCameraManager.createCaptureSession();
mCameraSession.beginConfig();
try {
mCameraSession.beginConfig();
} catch (error) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_BEGINCONFIG_0100 FAILED");
console.info(TAG + "ERRORCODE: " + error.code);
expect(error.code == cameraObj.CameraErrorCode.SESSION_CONFIG_LOCKED).assertTrue();
expect(true).assertTrue();
}
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAMERAINPUT_OPEN_CONFLICT_0100
* @tc.name : CameraInput open api
* @tc.desc : CameraInput open api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAMERAINPUT_OPEN_CONFLICT_0100', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAMERAINPUT_OPEN_CONFLICT_0100--------------");
mCameraInput = mCameraManager.createCameraInput(mCameraDevicesArray[0]);
if (!isEmpty(mCameraInput)) {
mCameraInput.open(async (err) => {
console.info(TAG + "Entering mCameraInput open callback");
if (!err) {
console.info(TAG + "Entering mCameraInput open PASSED ");
} else {
console.info(TAG + "Entering mCameraInput open FAILED : " + err.message);
}
})
mCameraInput.open(async (err) => {
console.info(TAG + "Entering mCameraInput open callback");
if (!err) {
console.info(TAG + "Entering mCameraInput open PASSED ");
} else {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAMERAINPUT_OPEN_CONFLICT_0100 FAILED");
console.info(TAG + "ERRORCODE: " + err.code);
expect(err.code == cameraObj.CameraErrorCode.CONFILICT_CAMERA).assertTrue();
expect(true).assertTrue();
}
})
} else {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAMERAINPUT_OPEN_CONFLICT_0100 createCameraInput FAILED");
}
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAMERAINPUT_OPEN_CONFLICT_0200
* @tc.name : CameraInput open api
* @tc.desc : CameraInput open api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAMERAINPUT_OPEN_CONFLICT_0200', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAMERAINPUT_OPEN_CONFLICT_0200--------------");
mCameraInput = mCameraManager.createCameraInput(mCameraDevicesArray[0]);
if (!isEmpty(mCameraInput)) {
await mCameraInput.open().then((result) => {
console.info('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAMERAINPUT_OPEN_CONFLICT_0200 success :' + result);
}).catch((err) => {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAMERAINPUT_OPEN_CONFLICT_0200 FAILED");
console.info(TAG + "ERRORCODE: " + err.code);
});
await mCameraInput.open().then((result) => {
console.info('SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAMERAINPUT_OPEN_CONFLICT_0200 success :' + result);
}).catch((err) => {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAMERAINPUT_OPEN_CONFLICT_0200 FAILED");
console.info(TAG + "ERRORCODE: " + err.code);
expect(err.code == cameraObj.CameraErrorCode.CONFILICT_CAMERA).assertTrue();
expect(true).assertTrue();
});
} else {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_ERROR_CODE_USECASE_CAMERAINPUT_OPEN_CONFLICT_0200 createCameraInput FAILED");
}
done();
})
})
}
\ No newline at end of file
/*
* 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 featureAbility from '@ohos.ability.featureAbility';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium';
import {UiDriver, BY} from '@ohos.uitest'
const TAG = "CameraInputTest: ";
// Define global variables
let mCameraManager;
let mCameraDevicesArray;
let mCameraSession;
let mCameraNum;
let mCameraInput;
let mPreviewOutput;
export default function CameraInputTest() {
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 getPermission() {
let permissions = ['ohos.permission.CAMERA',
'ohos.permission.MICROPHONE',
'ohos.permission.MEDIA_LOCATION',
'ohos.permission.READ_MEDIA',
'ohos.permission.WRITE_MEDIA',
'ohos.permission.ABILITY_BACKGROUND_COMMUNICATION'];
featureAbility.getContext().requestPermissionsFromUser(permissions, 0, (data) => {
console.info("request success" + JSON.stringify(data));
})
}
async function driveFn() {
console.info(`come in driveFn`);
let driver = await UiDriver.create();
console.info(`driver is ${JSON.stringify(driver)}`);
await sleep(2000);
console.info(`UiDriver start`);
let button = await driver.findComponent(BY.text('允许'));
while(button){
console.info(`button is ${JSON.stringify(button)}`);
await button.click();
await sleep(1000);
button = await driver.findComponent(BY.text('允许'));
}
}
function getCameraManagerInstance() {
console.info('Enter getCameraManagerInstance');
mCameraManager = cameraObj.getCameraManager(null);
if (isEmpty(mCameraManager)) {
console.info(TAG + "getCameraManager FAILED");
return false;
}
console.info('Exit getCameraManagerInstance');
return true;
}
function getCameraSupportDevicesArray() {
console.info('Enter getCameraSupportDevicesArray');
mCameraDevicesArray = 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(300);
*/
if (isEmpty(mCameraDevicesArray)) {
console.info(TAG + "getSupportedCameras FAILED");
return false;
}
//mCameraNum = 1;
mCameraNum = mCameraDevicesArray.length;
console.info(TAG + "getCameraSupportDevicesArray is: " + mCameraNum);
console.info('Exit getCameraSupportDevicesArray');
return true;
}
function beginCameraSessionConfig() {
console.info('Enter beginCameraSessionConfig');
console.info(TAG + "Entering beginConfig start");
mCameraSession.beginConfig();
console.info(TAG + "Entering beginConfig end");
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;
}
function createCameraSessionInstance() {
console.info('Enter createCameraSessionInstance');
try {
mCameraSession = mCameraManager.createCaptureSession();
}
catch {
console.info('createCaptureSession FAILED');
}
if (isEmpty(mCameraSession)) {
console.info(TAG + "createCaptureSession FAILED");
return false;
}
beginCameraSessionConfig();
console.info('Exit createCameraSessionInstance');
return true;
}
async function releaseCameraSessionInstance() {
await mCameraSession.release();
}
async function createInput(idx:any) {
console.info('Enter createInput');
if (isEmpty(mCameraDevicesArray)) {
console.info(TAG + "Entering createInputs FAILED with NoCamera");
return false;
}
mCameraInput = mCameraManager.createCameraInput(mCameraDevicesArray[idx]);
if (isEmpty(mCameraInput)) {
console.info(TAG + "createCameraInput FAILED");
return false;
}
await mCameraInput.open();
sleep(100);
console.info(idx + 'th CameraInput is: ' + mCameraInput);
console.info('Exit createInput');
return true;
}
async function releaseInput() {
console.info('Enter releaseInput');
if (!isEmpty(mCameraInput)) {
await mCameraInput.close();
}
console.info('Exit releaseInput');
return true;
}
function createOutput(idx:any) {
console.info('Enter createOutput');
let cameraOutputCap = mCameraManager.getSupportedOutputCapability(mCameraDevicesArray[idx]);
if (!isEmpty(cameraOutputCap)) {
if (!isEmpty(cameraOutputCap.previewProfiles)) {
console.info(TAG + "cameraOutputCap.previewProfiles.length: " + cameraOutputCap.previewProfiles.length);
for (let i = 0; i < cameraOutputCap.previewProfiles.length; i++) {
mPreviewOutput = mCameraManager.createPreviewOutput(cameraOutputCap.previewProfiles[i], globalThis.surfaceId);
if (!isEmpty(mPreviewOutput)) {
break;
}
}
if (isEmpty(mPreviewOutput)) {
console.info(TAG + "createPreviewOutput FAILED");
}
console.info(TAG + "createPreviewOutput: " + mPreviewOutput);
}
}
console.info('Exit createOutputs');
return true;
}
async function releaseOutput() {
console.info('Enter releaseOutput');
if (!isEmpty(mPreviewOutput)) {
await mPreviewOutput.release();
}
console.info('Exit releaseOutput');
return true;
}
async function startCameraSession(idx:any) {
console.info(TAG + "Enter startCameraSession");
await createInput(idx);
createOutput(idx);
await sleep(1);
if (!isEmpty(mCameraInput)) {
console.info(TAG + "Start to addInput");
mCameraSession.addInput(mCameraInput);
}
if (!isEmpty(mPreviewOutput)) {
console.info(TAG + "Start to addOutput mPreviewOutput");
mCameraSession.addOutput(mPreviewOutput);
}
await sleep(1);
await commitCameraSessionConfig();
console.info(TAG + "Exit startCameraSession");
return true;
}
async function stopCameraSession() {
console.info(TAG + "Enter stopCameraSession");
if (!isEmpty(mCameraInput)) {
console.info(TAG + "Start to removeInput input");
mCameraSession.removeInput(mCameraInput);
}
if (!isEmpty(mPreviewOutput)) {
console.info(TAG + "Start to removeOutput mPreviewOutput");
mCameraSession.removeOutput(mPreviewOutput);
}
await releaseInput();
await releaseOutput();
console.info(TAG + "Exit stopCameraSession");
return true;
}
describe('CameraInputTest', function () {
console.info(TAG + '----------CameraInputTest--------------');
beforeAll(async function () {
await getPermission();
sleep(1000);
await driveFn();
getCameraManagerInstance();
getCameraSupportDevicesArray();
createCameraSessionInstance();
console.info('beforeAll case');
});
beforeEach(function () {
sleep(1000);
console.info('beforeEach case');
});
afterEach(async function () {
console.info('afterEach case');
});
afterAll(function () {
releaseCameraSessionInstance();
console.info('afterAll case');
});
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_ERROR_0100
* @tc.name : camera status callback on CameraInput async api for error
* @tc.desc : camera status callback on CameraInput async api for error
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_ERROR_0100', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_ERROR_0100--------------");
if (mCameraNum == 0) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_ERROR_0100 FAILED with NoCamera");
expect().assertFail();
done();
} else {
for (let i = 0; i < mCameraNum; i++) {
let nfyFlag = false;
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_ERROR_0100 start for camera[" + i + "]");
await startCameraSession(i);
mCameraInput.on('error', mCameraDevicesArray[i], async (err, data) => {
if (!err) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_ERROR_0100 callback");
if (data != null || data != undefined) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_ERROR_0100 PASSED: " + data);
nfyFlag = true;
} else {
expect().assertFail();
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_ERROR_0100 FAILED with data is empty");
}
} else {
expect().assertFail();
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_ERROR_0100 FAILED: " + err.message);
}
await sleep(1);
})
await sleep(300);
if (nfyFlag == false) {
//expect().assertFail();
//console.info(TAG + "SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_ERROR_0100 FAILED without any nofity!");
}
await beginCameraSessionConfig();
await stopCameraSession();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_ERROR_0100 end for camera[" + i + "]");
}
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_ON_ERROR_0100 ends here");
done();
}
});
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_CALLBACK_0100
* @tc.name : open/close Camera with cameraInput callback api
* @tc.desc : open/close Camera with cameraInput callback api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_CALLBACK_0100', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_CALLBACK_0100--------------");
if (isEmpty(mCameraManager)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_CALLBACK_0100 cameraManager == null || undefined");
expect().assertFail();
} else {
let camerasArray = mCameraDevicesArray;
for (let i = 0; i < camerasArray.length; i++) {
let successFlag = false;
console.info(TAG + "Entering createCameraInput with camera: " + camerasArray[i].cameraId);
let cameraInput = mCameraManager.createCameraInput(camerasArray[i]);
expect(isEmpty(cameraInput)).assertFalse();
await cameraInput.open(async (err) => {
if (!err) {
successFlag = true;
console.info(TAG + " SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_CALLBACK_0100 PASSED open with CameraID :" + camerasArray[i].cameraId);
} else {
successFlag = false;
console.info(TAG + " SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_CALLBACK_0100 open FAILED: " + err.message);
}
});
await sleep(400);
successFlag = false;
await cameraInput.close(async (err) => {
if (!err) {
successFlag = true;
console.info(TAG + " SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_CALLBACK_0100 PASSED close with CameraID :" + camerasArray[i].cameraId);
} else {
successFlag = false;
console.info(TAG + " SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_CALLBACK_0100 close FAILED: " + err.message);
}
});
await sleep(100);
expect(successFlag).assertEqual(true);
}
}
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_CALLBACK_0100 ends here");
await sleep(1000);
done();
});
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_PROMISE_0100
* @tc.name : open/close Camera with cameraInput promise api
* @tc.desc : open/close Camera with cameraInput promise api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_PROMISE_0100', 0, async function (done) {
let functionTag = "SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_PROMISE_0100";
console.info(functionTag);
if (isEmpty(mCameraManager)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_PROMISE_0100 cameraManager == null || undefined");
expect().assertFail();
} else {
let camerasArray = mCameraDevicesArray;
for (let i = 0; i < camerasArray.length; i++) {
let successFlag = false;
console.info(TAG + functionTag + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_PROMISE_0100 createCameraInput with camera: " + camerasArray[i].cameraId);
let cameraInput = mCameraManager.createCameraInput(camerasArray[i]);
expect(isEmpty(cameraInput)).assertFalse();
console.info(TAG + functionTag + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_PROMISE_0100 cameraInput open with camera: " + camerasArray[i].cameraId);
await cameraInput.open().then(async () => {
successFlag = true;
console.info(TAG + functionTag + " SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_PROMISE_0100 PASSED open with CameraID :" + camerasArray[i].cameraId);
}).catch((err) => {
successFlag = false;
console.info(TAG + functionTag + " SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_PROMISE_0100 open FAILED: " + err.message);
});
await sleep(400);
successFlag = false;
await cameraInput.close().then(async () => {
successFlag = true;
console.info(TAG + functionTag + " SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_PROMISE_0100 PASSED close with CameraID :" + camerasArray[i].cameraId);
}).catch((err) => {
successFlag = false;
console.info(TAG + functionTag + " SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_PROMISE_0100 close FAILED: " + err.message);
});
await sleep(100);
expect(successFlag).assertEqual(true);
await sleep(600);
}
//await sleep(400 * camerasArray.length);
}
console.info(TAG + functionTag + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_INPUT_OPEN_CLOSE_PROMISE_0100 ends here");
done();
});
})
}
\ No newline at end of file
/*
* 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 mediaLibrary from '@ohos.multimedia.mediaLibrary';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
const TAG = "CameraUnitTest: ";
let captureLocation = {
latitude: 0,
longitude: 0,
altitude: 0,
}
let captureSetting = {
quality: cameraObj.QualityLevel.QUALITY_LEVEL_LOW,
rotation: cameraObj.ImageRotation.ROTATION_0,
location: captureLocation,
mirror: false
}
// 创建视频录制的参数
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 metadataOutput;
let videoSurfaceId;
let fdPath;
let fileAsset;
let fdNumber;
let mMetadataObjectTypeArray;
let mMetadataObjectArray;
export default function cameraJSUnitOutput() {
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) => {
if (!err) {
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) => {
if (!err) {
console.info(TAG + 'videoRecorder.prepare success.')
videoRecorder.getInputSurface((err, id) => {
console.info(TAG + 'getInputSurface called')
if (!err) {
videoSurfaceId = id
console.info(TAG + 'getInputSurface surfaceId: ' + JSON.stringify(videoSurfaceId))
} else {
console.info(TAG + 'getInputSurface FAILED')
}
})
} else {
console.info(TAG + 'prepare FAILED')
}
})
}
else {
console.info(TAG + 'createVideoRecorder FAILED')
}
})
}
async function release() {
console.log(TAG + "start 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;
}
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 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_CALLBACK_0100
* @tc.name : Create CameraManager instance async api
* @tc.desc : Create CameraManager instance async api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_MULTIMEDIA_CAMERA_GET_CAMERA_MANAGER_CALLBACK_0100', 1, async function (done) {
console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_GET_CAMERA_MANAGER_CALLBACK_0100--------------");
if (isEmpty(cameraObj)) {
console.info(TAG + "Entering GET_CAMERA_MANAGER cameraManager == null || undefined")
expect().assertFail();
} else {
cameraManager = cameraObj.getCameraManager(null);
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 1
*/
it('SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_CALLBACK_0100', 1, async function (done) {
console.info("--------------GET_CAMERAS--------------");
if (isEmpty(cameraManager)) {
console.info(TAG + "Entering GET_CAMERAS cameraManager == null || undefined")
expect().assertFail();
}
cameraDevicesArray = cameraManager.getSupportedCameras();
if (isEmpty(cameraDevicesArray)) {
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");
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");
}
}
await sleep(1000);
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_OUTPUT_PROMISE_0100
* @tc.name : Create previewOutput instance async api
* @tc.desc : Create previewOutput instance async api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_PROMISE_0100', 2, async function (done) {
console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_PROMISE_0100--------------");
if (isEmpty(cameraManager)) {
console.info(TAG + "Entering CREATE_CAMERA_INPUT cameraManager == null || undefined")
expect().assertFail();
} else {
cameraInput = cameraManager.createCameraInput(cameraDevicesArray[0]);
if (isEmpty(cameraInput)) {
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_PROMISE_0100 FAILED");
}
cameraInput.open(async (err) => {
if (!err) {
expect(true).assertTrue();
} else {
expect().assertFail();
}
await sleep(1000);
done();
})
}
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_CREATE_PREVIEW_OUTPUT_CALLBACK_0100
* @tc.name : Create previewOutput instance async api
* @tc.desc : Create previewOutput instance async api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_MULTIMEDIA_CAMERA_CREATE_PREVIEW_OUTPUT_0100', 1, async function (done) {
console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_CREATE_PREVIEW_OUTPUT_CALLBACK_0100--------------");
if (isEmpty(cameraManager)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_PREVIEW_OUTPUT_CALLBACK_0100 cameraManager == null || undefined")
expect().assertFail();
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_PREVIEW_OUTPUT_CALLBACK_0100")
let cameraOutputCap = getSupportedOutputCapabilityInPromise(cameraDevicesArray[0]);
let previewProfilesArray = cameraOutputCap.previewProfiles;
if (isEmpty(previewProfilesArray)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_PREVIEW_OUTPUT_CALLBACK_0100 previewProfilesArray == null || undefined")
expect(isEmpty(previewProfilesArray)).assertFalse();
}
previewOutput = cameraManager.createPreviewOutput(previewProfilesArray[0], globalThis.surfaceId);
}
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_CREATE_PHOTO_OUTPUT_PROMISE_0100
* @tc.name : Create photoOutput instance async api
* @tc.desc : Create photoOutput instance async api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_MULTIMEDIA_CAMERA_CREATE_PHOTO_OUTPUT_PROMISE_0100', 1, async function (done) {
console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_CREATE_PHOTO_OUTPUT_PROMISE_0100--------------");
if (isEmpty(cameraManager)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_PHOTO_OUTPUT_PROMISE_0100 cameraManager == null || undefined")
expect().assertFail();
} else {
let cameraOutputCap = getSupportedOutputCapabilityInPromise(cameraDevicesArray[0]);
let photoProfilesArray = cameraOutputCap.photoProfiles;
if (isEmpty(photoProfilesArray)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_PHOTO_OUTPUT_PROMISE_0100 previewProfilesArray == null || undefined")
expect().assertFalse();
}
photoOutput = cameraManager.createPhotoOutput(photoProfilesArray[0], surfaceId1);
if (isEmpty(photoOutput)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_PHOTO_OUTPUT_PROMISE_0100 data is empty");
expect().assertFalse();
}
}
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_CREATE_VIDEO_OUTPUT_CALLBACK_0100
* @tc.name : Create videoOutput instance async api
* @tc.desc : Create videoOutput instance async api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_MULTIMEDIA_CAMERA_CREATE_VIDEO_OUTPUT_0100', 1, async function (done) {
console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_CREATE_VIDEO_OUTPUT_CALLBACK_0100--------------");
if (isEmpty(cameraManager)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_VIDEO_OUTPUT_CALLBACK_0100 cameraManager == null || undefined")
expect().assertFail();
} else {
let cameraOutputCap = getSupportedOutputCapabilityInPromise(cameraDevicesArray[0]);
console.info("SUB_MULTIMEDIA_CAMERA_CREATE_VIDEO_OUTPUT_CALLBACK_0100 camera:" + cameraDevicesArray[0].cameraId);
expect(isEmpty(cameraOutputCap)).assertFalse();
let videoProfilesArray = cameraOutputCap.videoProfiles;
expect(isEmpty(videoProfilesArray)).assertFalse();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_VIDEO_OUTPUT_CALLBACK_0100 start createVideoOutput")
videoOutput = cameraManager.createVideoOutput(videoProfilesArray[0], videoSurfaceId);
}
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_CREATE_METADATA_OUTPUT_CALLBACK_0100
* @tc.name : Create metadataOutput instance async api
* @tc.desc : Create metadataOutput instance async api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_MULTIMEDIA_CAMERA_CREATE_METADATA_OUTPUT_0100', 1, async function (done) {
console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_CREATE_METADATA_OUTPUT_CALLBACK_0100--------------");
if (isEmpty(cameraManager)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_METADATA_OUTPUT_CALLBACK_0100 cameraManager == null || undefined")
expect().assertFail();
} else {
let cameraOutputCap = getSupportedOutputCapabilityInPromise(cameraDevicesArray[0]);
console.info("SUB_MULTIMEDIA_CAMERA_CREATE_METADATA_OUTPUT_CALLBACK_0100 camera:" + cameraDevicesArray[0].cameraId);
expect(isEmpty(cameraOutputCap)).assertFalse();
mMetadataObjectTypeArray = cameraOutputCap.supportedMetadataObjectTypes;
if (isEmpty(mMetadataObjectTypeArray)) {
console.info("SUB_MULTIMEDIA_CAMERA_CREATE_METADATA_OUTPUT_CALLBACK_0100 end with mMetadataObjectTypeArray is null");
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_METADATA_OUTPUT_CALLBACK_0100 start createMetadataOutput")
metadataOutput = cameraManager.createMetadataOutput(mMetadataObjectTypeArray);
}
}
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 1
*/
it('SUB_MULTIMEDIA_CAMERA_CREATE_CAPTURE_SESSION_0100', 1, async function (done) {
console.info(TAG + "--------------SUB_MULTIMEDIA_CAMERA_CREATE_CAPTURE_SESSION_CALLBACK_0100--------------");
if (isEmpty(cameraManager)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAPTURE_SESSION_CALLBACK_0100 cameraManager == null || undefined")
expect().assertFail();
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAPTURE_SESSION_CALLBACK_0100")
captureSession = cameraManager.createCaptureSession();
}
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_BEGIN_CONFIG_CALLBACK_0100
* @tc.name : captureSession beginConfig
* @tc.desc : captureSession beginConfig
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_BEGIN_CONFIG_0100', 1, async function (done) {
console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_BEGIN_CONFIG_CALLBACK_0100--------------");
if (isEmpty(captureSession)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_BEGIN_CONFIG_CALLBACK_0100 captureSession == null || undefined")
expect().assertFail();
} else {
captureSession.beginConfig();
}
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_ADD_INPUT_CALLBACK_0100
* @tc.name : captureSession addInput
* @tc.desc : captureSession addInput
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_ADD_INPUT_0100', 1, async function (done) {
console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_ADD_INPUT_CALLBACK_0100--------------");
if (isEmpty(captureSession)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_ADD_INPUT_CALLBACK_0100 captureSession == null || undefined")
expect().assertFail();
} else {
captureSession.addInput(cameraInput)
}
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_ADD_PREVIEW_OUTPUT_CALLBACK_0100
* @tc.name : captureSession add previewOutput
* @tc.desc : captureSession add previewOutput
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_ADD_PREVIEW_OUTPUT_0100', 1, async function (done) {
console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_ADD_PREVIEW_OUTPUT_0100--------------");
if (isEmpty(captureSession)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_ADD_PREVIEW_OUTPUT_0100 captureSession == null || undefined")
expect().assertFail();
} else {
if (isEmpty(previewOutput)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_ADD_PREVIEW_OUTPUT_0100 previewOutput == null || undefined")
expect().assertFail();
}
captureSession.addOutput(previewOutput)
}
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_ADD_PHOTO_OUTPUT_CALLBACK_0100
* @tc.name : captureSession add photoOutput
* @tc.desc : captureSession add photoOutput
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_ADD_PHOTO_OUTPUT_0100', 1, async function (done) {
console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_ADD_PHOTO_OUTPUT_CALLBACK_0100--------------");
if (isEmpty(captureSession)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_ADD_PHOTO_OUTPUT_CALLBACK_0100 captureSession == null || undefined")
expect().assertFail();
} else {
if (isEmpty(photoOutput)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_ADD_PHOTO_OUTPUT_CALLBACK_0100 photoOutput == null || undefined")
expect().assertFail();
}
console.info(TAG + "captureSession start add photoOutput")
captureSession.addOutput(photoOutput)
}
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_ADD_VIDEO_OUTPUT_CALLBACK_0100
* @tc.name : captureSession remove photoOutput
* @tc.desc : captureSession remove photoOutput
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_ADD_VIDEO_OUTPUT_0100', 1, async function (done) {
console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_ADD_VIDEO_OUTPUT_CALLBACK_0100--------------");
if (isEmpty(captureSession)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_ADD_VIDEO_OUTPUT_CALLBACK_0100 captureSession == null || undefined")
expect().assertFail();
} else {
captureSession.addOutput(videoOutput)
}
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_ADD_METADATA_OUTPUT_CALLBACK_0100
* @tc.name : captureSession add metadataOutput
* @tc.desc : captureSession add metadataOutput
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_ADD_METADATA_OUTPUT_0100', 1, async function (done) {
console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_ADD_METADATA_OUTPUT_CALLBACK_0100--------------");
if (isEmpty(captureSession)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_ADD_METADATA_OUTPUT_CALLBACK_0100 captureSession == null || undefined")
expect().assertFail();
} else {
if (!isEmpty(metadataOutput)) {
captureSession.addOutput(metadataOutput)
}
}
await sleep(1000);
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_COMMIT_CONFIG_CALLBACK_0100
* @tc.name : captureSession commitConfig
* @tc.desc : captureSession commitConfig
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_COMMIT_CONFIG_CALLBACK_0100', 1, async function (done) {
console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_COMMIT_CONFIG_CALLBACK_0100--------------");
if (isEmpty(captureSession)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_COMMIT_CONFIG_CALLBACK_0100 captureSession == null || undefined")
expect().assertFail();
} else {
captureSession.commitConfig(async (err) => {
if (!err) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_COMMIT_CONFIG_CALLBACK_0100 success");
expect(true).assertTrue();
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_COMMIT_CONFIG_CALLBACK_0100 FAILED: " + err.message);
expect().assertFail();
}
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_COMMIT_CONFIG_CALLBACK_0100 ends here");
await sleep(1000);
done();
})
}
await sleep(1000);
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ON_AVAILABLE_METADATA_OUTPUT_CALLBACK_0100
* @tc.name : Start metadataOutput type async api
* @tc.desc : Start metadataOutput type async api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_MULTIMEDIA_CAMERA_ON_AVAILABLE_METADATA_OUTPUT_CALLBACK_0100', 1, async function (done) {
console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_ON_AVAILABLE_METADATA_OUTPUT_CALLBACK_0100--------------");
if (isEmpty(metadataOutput)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ON_AVAILABLE_METADATA_OUTPUT_CALLBACK_0100 metadataOutput == null || undefined")
} else {
metadataOutput.on('metadataObjectsAvailable', async (err, data) => {
if (!err) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ON_AVAILABLE_METADATA_OUTPUT_CALLBACK_0100 is not error");
expect(isEmpty(data)).assertFalse();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ON_AVAILABLE_METADATA_OUTPUT_CALLBACK_0100 success");
mMetadataObjectArray = data;
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ON_AVAILABLE_METADATA_OUTPUT_CALLBACK_0100 FAILED: " + err.message);
expect().assertFail();
}
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ON_AVAILABLE_METADATA_OUTPUT_CALLBACK_0100 ends here");
await sleep(1000);
})
}
await sleep(1000);
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_METADATA_OUTPUT_CALLBACK_ON_ERROR_0100
* @tc.name : metadata output callback on error api
* @tc.desc : metadata output callback on error api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_MULTIMEDIA_CAMERA_METADATA_OUTPUT_CALLBACK_ON_ERROR_0100', 1, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_METADATA_OUTPUT_CALLBACK_ON_ERROR_0100--------------");
if (isEmpty(metadataOutput)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_METADATA_OUTPUT_CALLBACK_ON_ERROR_0100 metadata is not support")
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_METADATA_OUTPUT_CALLBACK_ON_ERROR_0100 to operate");
metadataOutput.on('error', async (err, data) => {
if (!err) {
expect(true).assertTrue();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_METADATA_OUTPUT_CALLBACK_ON_ERROR_0100 success");
} else {
expect().assertFail();
console.info(TAG + "Error in SUB_MULTIMEDIA_CAMERA_METADATA_OUTPUT_CALLBACK_ON_ERROR_0100 FAILED: " + err.message);
}
await sleep(1000);
done();
})
}
await sleep(1000);
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_START_CALLBACK_0100
* @tc.name : captureSession start
* @tc.desc : captureSession start
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_START_CALLBACK_0100', 1, async function (done) {
console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_START_CALLBACK_0100--------------");
if (isEmpty(captureSession)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_START_CALLBACK_0100 captureSession == null || undefined")
expect().assertFail();
} else {
captureSession.start(async (err) => {
if (!err) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_START_CALLBACK_0100 success");
expect(true).assertTrue();
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_START_CALLBACK_0100 FAILED: " + err.message);
expect().assertFail();
}
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAPTURE_SESSION_START_CALLBACK_0100 ends here");
await sleep(1000);
done();
})
}
await sleep(1000);
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_START_METADATA_OUTPUT_CALLBACK_0100
* @tc.name : Start metadataOutput type async api
* @tc.desc : Start metadataOutput type async api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_MULTIMEDIA_CAMERA_START_METADATA_OUTPUT_CALLBACK_0100', 1, async function (done) {
console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_START_METADATA_OUTPUT_CALLBACK_0100--------------");
if (isEmpty(metadataOutput)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_START_METADATA_OUTPUT_CALLBACK_0100 metadataOutput == null || undefined")
} else {
metadataOutput.start(async (err) => {
if (!err) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_START_METADATA_OUTPUT_CALLBACK_0100 success");
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_START_METADATA_OUTPUT_CALLBACK_0100 FAILED: " + err.message);
expect().assertFail();
}
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_START_METADATA_OUTPUT_CALLBACK_0100 ends here");
await sleep(1000);
})
}
await sleep(1000);
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_GET_METADATA_TYPE_PROMISE_0100
* @tc.name : Start metadataOutput type async api
* @tc.desc : Start metadataOutput type async api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_MULTIMEDIA_CAMERA_GET_METADATA_TYPE_PROMISE_0100', 1, async function (done) {
console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_GET_METADATA_TYPE_PROMISE_0100--------------");
if (isEmpty(mMetadataObjectArray)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_METADATA_TYPE_PROMISE_0100 mMetadataObjectArray == null || undefined")
} else {
let type = mMetadataObjectArray[0].type;
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_METADATA_TYPE_PROMISE_0100 success, type : " + type);
}
await sleep(1000);
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_GET_METADATA_TIMESTAMP_PROMISE_0100
* @tc.name : Start metadataOutput timestamp async api
* @tc.desc : Start metadataOutput timestamp async api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_MULTIMEDIA_CAMERA_GET_METADATA_TIMESTAMP_PROMISE_0100', 1, async function (done) {
console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_GET_METADATA_TIMESTAMP_PROMISE_0100--------------");
if (isEmpty(mMetadataObjectArray)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_METADATA_TIMESTAMP_PROMISE_0100 mMetadataObjectArray == null || undefined")
} else {
let timeStamp = mMetadataObjectArray[0].timestamp;
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_METADATA_TIMESTAMP_PROMISE_0100 success, timeStamp : " + timeStamp);
}
await sleep(1000);
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_GET_METADATA_BOUNDING_BOX_PROMISE_0100
* @tc.name : Start metadataOutput bounding box async api
* @tc.desc : Start metadataOutput bounding box async api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_MULTIMEDIA_CAMERA_GET_METADATA_BOUNDING_BOX_PROMISE_0100', 1, async function (done) {
console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_GET_METADATA_BOUNDING_BOX_PROMISE_0100--------------");
if (isEmpty(mMetadataObjectArray)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_METADATA_BOUNDING_BOX_PROMISE_0100 mMetadataObjectArray == null || undefined")
} else {
let boundingBox = mMetadataObjectArray[0].boundingBox;
let w = boundingBox.width;
let h = boundingBox.height;
let tx = boundingBox.topLeftX;
let ty = boundingBox.topLeftY;
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_METADATA_BOUNDING_BOX_PROMISE_0100 success, boundingBox : " + w + "x" + h);
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_METADATA_BOUNDING_BOX_PROMISE_0100 success, boundingBox : " + tx + "x" + ty);
}
await sleep(1000);
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_STOP_METADATA_OUTPUT_CALLBACK_0100
* @tc.name : Stop metadataOutput type async api
* @tc.desc : Stop metadataOutput type async api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_MULTIMEDIA_CAMERA_STOP_METADATA_OUTPUT_CALLBACK_0100', 1, async function (done) {
console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_STOP_METADATA_OUTPUT_CALLBACK_0100--------------");
if (isEmpty(metadataOutput)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_STOP_METADATA_OUTPUT_CALLBACK_0100 metadataOutput == null || undefined")
} else {
metadataOutput.stop(async (err) => {
if (!err) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_STOP_METADATA_OUTPUT_CALLBACK_0100 success");
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_STOP_METADATA_OUTPUT_CALLBACK_0100 FAILED: " + err.message);
expect().assertFail();
}
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_STOP_METADATA_OUTPUT_CALLBACK_0100 ends here");
await sleep(1000);
done();
})
}
await sleep(1000);
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_START_PREVIEW_OUTPUT_PROMISE_0100
* @tc.name : Create previewOutput instance promise api
* @tc.desc : Create previewOutput instance promise api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_MULTIMEDIA_CAMERA_START_PREVIEW_OUTPUT_PROMISE_0100', 1, async function (done) {
console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_START_PREVIEW_OUTPUT_PROMISE_0100--------------");
if (isEmpty(previewOutput)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_START_PREVIEW_OUTPUT_PROMISE_0100 previewOutput == null || undefined")
expect().assertFail();
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_START_PREVIEW_OUTPUT_PROMISE_0100 start")
previewOutput.start();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_START_PREVIEW_OUTPUT_PROMISE_0100 end")
}
await sleep(1000);
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_STOP_PREVIEW_OUTPUT_PROMISE_0100
* @tc.name : Create previewOutput instance promise api
* @tc.desc : Create previewOutput instance promise api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_MULTIMEDIA_CAMERA_STOP_PREVIEW_OUTPUT_PROMISE_0100', 1, async function (done) {
console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_STOP_PREVIEW_OUTPUT_PROMISE_0100--------------");
if (isEmpty(previewOutput)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_STOP_PREVIEW_OUTPUT_PROMISE_0100 previewOutput == null || undefined")
expect().assertFail();
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_STOP_PREVIEW_OUTPUT_PROMISE_0100 start")
previewOutput.stop();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_STOP_PREVIEW_OUTPUT_PROMISE_0100 end")
}
await sleep(1000);
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_START_PREVIEW_OUTPUT_CALLBACK_0100
* @tc.name : Create previewOutput instance async api
* @tc.desc : Create previewOutput instance async api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_MULTIMEDIA_CAMERA_START_PREVIEW_OUTPUT_CALLBACK_0100', 1, async function (done) {
console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_START_PREVIEW_OUTPUT_CALLBACK_0100--------------");
if (isEmpty(previewOutput)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_START_PREVIEW_OUTPUT_CALLBACK_0100 previewOutput == null || undefined")
expect().assertFail();
} else {
previewOutput.start(async (err) => {
if (!err) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_START_PREVIEW_OUTPUT_CALLBACK_0100 success");
expect(true).assertTrue();
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_START_PREVIEW_OUTPUT_CALLBACK_0100 FAILED: " + err.message);
expect().assertFail();
}
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_START_PREVIEW_OUTPUT_CALLBACK_0100 ends here");
await sleep(1000);
done();
})
}
await sleep(1000);
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_STOP_PREVIEW_OUTPUT_CALLBACK_0100
* @tc.name : Create previewOutput instance async api
* @tc.desc : Create previewOutput instance async api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_MULTIMEDIA_CAMERA_STOP_PREVIEW_OUTPUT_CALLBACK_0100', 1, async function (done) {
console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_STOP_PREVIEW_OUTPUT_CALLBACK_0100--------------");
if (isEmpty(previewOutput)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_STOP_PREVIEW_OUTPUT_CALLBACK_0100 previewOutput == null || undefined")
expect().assertFail();
} else {
previewOutput.stop(async (err) => {
if (!err) {
expect(true).assertTrue();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_STOP_PREVIEW_OUTPUT_CALLBACK_0100 success");
} else {
expect().assertFail();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_STOP_PREVIEW_OUTPUT_CALLBACK_0100 FAILED: " + err.message);
}
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_STOP_PREVIEW_OUTPUT_CALLBACK_0100 ends here");
await sleep(1000);
done();
})
}
await sleep(1000);
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_PREVIEW_OUTPUT_CALLBACK_ON_FRAME_START_0100
* @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 1
*/
it('SUB_MULTIMEDIA_CAMERA_PREVIEW_OUTPUT_CALLBACK_ON_FRAME_START_0100', 1, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_PREVIEW_OUTPUT_CALLBACK_ON_FRAME_START_0100--------------");
if (isEmpty(previewOutput)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PREVIEW_OUTPUT_CALLBACK_ON_FRAME_START_0100 previewOutput == null || undefined")
expect().assertFail();
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PREVIEW_OUTPUT_CALLBACK_ON_FRAME_START_0100 to operate");
let count = 0;
previewOutput.on('frameStart', async (err, data) => {
if (!err) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PREVIEW_OUTPUT_CALLBACK_ON_FRAME_START_0100 success");
count++;
} else {
console.info(TAG + "Error in SUB_MULTIMEDIA_CAMERA_PREVIEW_OUTPUT_CALLBACK_ON_FRAME_START_0100 FAILED: " + err.message);
expect().assertFail();
}
await sleep(1000);
done();
})
await sleep(1000);
done();
previewOutput.start();
previewOutput.stop();
// expect(count == 1).assertTrue();
}
await sleep(1000);
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_PREVIEW_OUTPUT_CALLBACK_ON_FRAME_END_0100
* @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 1
*/
it('SUB_MULTIMEDIA_CAMERA_PREVIEW_OUTPUT_CALLBACK_ON_FRAME_END_0100', 1, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_PREVIEW_OUTPUT_CALLBACK_ON_FRAME_END_0100--------------");
if (isEmpty(previewOutput)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PREVIEW_OUTPUT_CALLBACK_ON_FRAME_END_0100 previewOutput == null || undefined")
expect().assertFail();
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PREVIEW_OUTPUT_CALLBACK_ON_FRAME_END_0100 to operate");
let count = 0;
previewOutput.on('frameEnd', async (err, data) => {
if (!err) {
count++
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PREVIEW_OUTPUT_CALLBACK_ON_FRAME_END_0100 success");
} else {
expect().assertFail();
console.info(TAG + "Error in SUB_MULTIMEDIA_CAMERA_PREVIEW_OUTPUT_CALLBACK_ON_FRAME_END_0100 FAILED: " + err.message);
}
await sleep(1000);
done();
})
previewOutput.stop();
// expect(count == 1).assertTrue();
}
await sleep(1000);
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_PREVIEW_OUTPUT_CALLBACK_ON_ERROR_0100
* @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 1
*/
it('SUB_MULTIMEDIA_CAMERA_PREVIEW_OUTPUT_CALLBACK_ON_ERROR_0100', 1, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_PREVIEW_OUTPUT_CALLBACK_ON_ERROR_0100--------------");
if (isEmpty(previewOutput)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PREVIEW_OUTPUT_CALLBACK_ON_ERROR_0100 previewOutput == null || undefined")
expect().assertFail();
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PREVIEW_OUTPUT_CALLBACK_ON_ERROR_0100 to operate");
previewOutput.on('error', async (err, data) => {
if (!err) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PREVIEW_OUTPUT_CALLBACK_ON_ERROR_0100 success");
} else {
expect().assertFail();
console.info(TAG + "Error in SUB_MULTIMEDIA_CAMERA_PREVIEW_OUTPUT_CALLBACK_ON_ERROR_0100 FAILED: " + err.message);
}
await sleep(1000);
done();
})
}
await sleep(1000);
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_IS_MIRROR_SUPPORTED_PROMISE_0100
* @tc.name : check photoOutput is mirror supported with promise mode
* @tc.desc : check photoOutput is mirror supported with promise mode
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_IS_MIRROR_SUPPORTED_PROMISE_0100', 1, async function (done) {
console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_IS_MIRROR_SUPPORTED_PROMISE_0100--------------");
if (isEmpty(photoOutput)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_IS_MIRROR_SUPPORTED_PROMISE_0100 photoOutput == null || undefined")
expect().assertFail();
} else {
let isMirrorSupportedFlag = photoOutput.isMirrorSupported();
console.info('SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_IS_MIRROR_SUPPORTED_PROMISE_0100 isMirrorSupportedFlag = ' + isMirrorSupportedFlag);
}
await sleep(1000);
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_DEFAULT_PROMISE_0100
* @tc.name : photoOutput capture with promise mode
* @tc.desc : photoOutput capture with promise mode
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_DEFAULT_PROMISE_0100', 1, async function (done) {
console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_DEFAULT_PROMISE_0100--------------");
if (isEmpty(photoOutput)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_DEFAULT_PROMISE_0100 photoOutput == null || undefined")
expect().assertFail();
} else {
await photoOutput.capture().then(() => {
console.info('SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_DEFAULT_PROMISE_0100 success');
}).catch((err) => {
console.info('SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_DEFAULT_PROMISE_0100 failed :' + err);
expect().assertFail();
});
}
await sleep(1000);
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_DEFAULT_CALLBACK_0100
* @tc.name : photoOutput commitConfig
* @tc.desc : captureSession commitConfig
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_DEFAULT_CALLBACK_0100', 1, async function (done) {
console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_DEFAULT_CALLBACK_0100--------------");
if (isEmpty(photoOutput)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_DEFAULT_CALLBACK_0100 photoOutput == null || undefined")
expect().assertFail();
} else {
photoOutput.capture(async (err) => {
if (!err) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_DEFAULT_CALLBACK_0100 success");
expect(true).assertTrue();
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_DEFAULT_CALLBACK_0100 FAILED: " + err.message);
expect().assertFail();
}
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_DEFAULT_CALLBACK_0100 ends here");
await sleep(1000);
done();
})
}
await sleep(1000);
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_SETTING_PROMISE_0100
* @tc.name : photoOutput commitConfig
* @tc.desc : captureSession commitConfig
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_SETTING_PROMISE_0100', 1, async function (done) {
console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_SETTING_PROMISE_0100--------------");
if (isEmpty(photoOutput)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_SETTING_PROMISE_0100 photoOutput == null || undefined")
expect().assertFail();
} else {
console.info('SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_SETTING_PROMISE_0100 captureSetting.quality = ' + captureSetting.quality);
console.info('SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_SETTING_PROMISE_0100 captureSetting.rotation = ' + captureSetting.rotation);
console.info('SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_SETTING_PROMISE_0100 captureSetting.location.latitude = ' + captureSetting.location.latitude);
console.info('SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_SETTING_PROMISE_0100 captureSetting.location.longitude = ' + captureSetting.location.longitude);
console.info('SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_SETTING_PROMISE_0100 captureSetting.location.altitude = ' + captureSetting.location.altitude);
console.info('SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_SETTING_PROMISE_0100 captureSetting.mirror = ' + captureSetting.mirror);
await photoOutput.capture(captureSetting).then((result) => {
console.info('SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_SETTING_PROMISE_0100 success :' + result);
}).catch((err) => {
console.info('SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_SETTING_PROMISE_0100 failed :' + err);
});
}
await sleep(1000);
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_SETTING_CALLBACK_0100
* @tc.name : photoOutput commitConfig
* @tc.desc : captureSession commitConfig
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_SETTING_CALLBACK_0100', 1, async function (done) {
console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_SETTING_CALLBACK_0100--------------");
if (isEmpty(photoOutput)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_SETTING_CALLBACK_0100 photoOutput == null || undefined")
expect().assertFail();
} else {
photoOutput.capture(captureSetting, async (err) => {
if (!err) {
expect(true).assertTrue();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_SETTING_CALLBACK_0100 success");
} else {
expect().assertFail();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_SETTING_CALLBACK_0100 FAILED: " + err.message);
}
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CAPTURE_SETTING_CALLBACK_0100 ends here");
await sleep(1000);
done();
})
}
await sleep(1000);
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CALLBACK_ON_CAPTURE_START_0100
* @tc.name : photo output callback on captureStart
* @tc.desc : photo output callback on captureStart
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CALLBACK_ON_CAPTURE_START_0100', 1, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CALLBACK_ON_CAPTURE_START_0100--------------");
if (isEmpty(photoOutput)) {
console.info(TAG + "Entering PREVIEW_OUTPUT_CALLBACK_ON_FRAME_START previewOutput == null || undefined")
expect().assertFail();
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CALLBACK_ON_CAPTURE_START_0100 to operate");
let count = 0;
photoOutput.on('captureStart', async (data) => {
count++;
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CALLBACK_ON_CAPTURE_START_0100 success");
await sleep(1000);
done();
})
photoOutput.capture();
// expect(count == 1).assertTrue();
}
await sleep(1000);
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CALLBACK_ON_FRAME_SHUTTER_0100
* @tc.name : photo output callback on frameShutter
* @tc.desc : photo output callback on frameShutter
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CALLBACK_ON_FRAME_SHUTTER_0100', 1, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CALLBACK_ON_FRAME_SHUTTER_0100--------------");
if (isEmpty(photoOutput)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CALLBACK_ON_FRAME_SHUTTER_0100 previewOutput == null || undefined")
expect().assertFail();
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CALLBACK_ON_FRAME_SHUTTER_0100 to operate");
let count = 0;
photoOutput.on('frameShutter', async (err, data) => {
if (!err) {
count++;
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CALLBACK_ON_FRAME_SHUTTER_0100 success");
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CALLBACK_ON_FRAME_SHUTTER_0100, captureId = " + data.captureId);
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CALLBACK_ON_FRAME_SHUTTER_0100, timestamp = " + data.timestamp);
} else {
expect().assertFail();
console.info(TAG + "Error in SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CALLBACK_ON_FRAME_SHUTTER_0100 FAILED: " + err.message);
}
await sleep(1000);
done();
})
await sleep(1000);
done();
photoOutput.capture();
// expect(count == 1).assertTrue();
}
await sleep(1000);
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CALLBACK_ON_CAPTURE_END_0100
* @tc.name : photo output callback on captureEnd
* @tc.desc : photo output callback on captureEnd
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CALLBACK_ON_CAPTURE_END_0100', 1, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CALLBACK_ON_CAPTURE_END_0100--------------");
if (isEmpty(photoOutput)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CALLBACK_ON_CAPTURE_END_0100 previewOutput == null || undefined")
expect().assertFail();
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CALLBACK_ON_CAPTURE_END_0100 to operate");
let count = 0;
photoOutput.on('captureEnd', async (data) => {
count++;
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CALLBACK_ON_CAPTURE_END_0100 success");
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CALLBACK_ON_CAPTURE_END_0100, captureId = " + data.captureId);
console.info(TAG + "SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CALLBACK_ON_CAPTURE_END_0100, frameCount = " + data.frameCount);
await sleep(1000);
done();
})
await sleep(1000);
done();
photoOutput.capture();
// expect(count == 1).assertTrue();
}
await sleep(1000);
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CALLBACK_ON_ERROR_0100
* @tc.name : photo output callback on error
* @tc.desc : photo output callback on error
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CALLBACK_ON_ERROR_0100', 1, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CALLBACK_ON_ERROR_0100--------------");
if (isEmpty(photoOutput)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CALLBACK_ON_ERROR_0100 previewOutput == null || undefined")
expect().assertFail();
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CALLBACK_ON_ERROR_0100 to operate");
photoOutput.on('error', async (err, data) => {
if (!err) {
expect(true).assertTrue();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CALLBACK_ON_ERROR_0100 success");
} else {
expect().assertFail();
console.info(TAG + "Error in SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_CALLBACK_ON_ERROR_0100 FAILED: " + err.message);
}
await sleep(1000);
done();
})
}
await sleep(1000);
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_RELEASE_CALLBACK_0100
* @tc.name : Create previewOutput instance async api
* @tc.desc : Create previewOutput instance async api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_RELEASE_CALLBACK_0100', 1, async function (done) {
console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_RELEASE_CALLBACK_0100--------------");
if (isEmpty(photoOutput)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_RELEASE_CALLBACK_0100 photoOutput == null || undefined")
expect().assertFail();
} else {
photoOutput.release(async (err) => {
if (!err) {
expect(true).assertTrue();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_RELEASE_CALLBACK_0100 success");
} else {
expect().assertFail();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_RELEASE_CALLBACK_0100 FAILED: " + err.message);
}
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_PHOTO_OUTPUT_RELEASE_CALLBACK_0100 ends here");
await sleep(1000);
done();
})
}
await sleep(1000);
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_START_PROMISE_0100
* @tc.name : videoOutput start promise api
* @tc.desc : videoOutput start promise api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_START_PROMISE_0100', 1, async function (done) {
console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_START_PROMISE_0100--------------");
if (isEmpty(videoOutput)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_START_PROMISE_0100 videoOutput == null || undefined")
expect().assertFail();
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_START_PROMISE_0100 start")
videoOutput.start();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_START_PROMISE_0100 end")
}
await sleep(1000);
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_STOP_PROMISE_0100
* @tc.name : videoOutput stop promise api
* @tc.desc : videoOutput stop promise api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_STOP_PROMISE_0100', 1, async function (done) {
console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_STOP_PROMISE_0100--------------");
if (isEmpty(videoOutput)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_STOP_PROMISE_0100 videoOutput == null || undefined")
expect().assertFail();
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_STOP_PROMISE_0100 start")
videoOutput.stop();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_STOP_PROMISE_0100 end")
}
await sleep(1000);
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_START_METADATA_OUTPUT_PROMISE_0100
* @tc.name : Start metadataOutput sync api
* @tc.desc : Start metadataOutput sync api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_MULTIMEDIA_CAMERA_START_METADATA_OUTPUT_PROMISE_0100', 1, async function (done) {
console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_START_METADATA_OUTPUT_PROMISE_0100--------------");
if (isEmpty(metadataOutput)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_START_METADATA_OUTPUT_PROMISE_0100 metadataOutput == null || undefined")
} else {
metadataOutput.start().then((result) => {
console.info('SUB_MULTIMEDIA_CAMERA_START_METADATA_OUTPUT_PROMISE_0100 success :' + result);
}).catch((err) => {
console.info('SUB_MULTIMEDIA_CAMERA_START_METADATA_OUTPUT_PROMISE_0100 failed :' + err);
});
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_START_METADATA_OUTPUT_PROMISE_0100 ends here");
}
await sleep(1000);
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_STOP_METADATA_OUTPUT_PROMISE_0100
* @tc.name : Stop metadataOutput sync api
* @tc.desc : Stop metadataOutput aync api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_MULTIMEDIA_CAMERA_STOP_METADATA_OUTPUT_PROMISE_0100', 1, async function (done) {
console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_STOP_METADATA_OUTPUT_PROMISE_0100--------------");
if (isEmpty(metadataOutput)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_STOP_METADATA_OUTPUT_PROMISE_0100 metadataOutput == null || undefined")
} else {
metadataOutput.stop().then((result) => {
console.info('SUB_MULTIMEDIA_CAMERA_STOP_METADATA_OUTPUT_PROMISE_0100 success :' + result);
}).catch((err) => {
console.info('SUB_MULTIMEDIA_CAMERA_STOP_METADATA_OUTPUT_PROMISE_0100 failed :' + err);
});
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_STOP_METADATA_OUTPUT_PROMISE_0100 ends here");
}
await sleep(1000);
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_START_CALLBACK_0100
* @tc.name : videoOutput start async api
* @tc.desc : videoOutput start async api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_START_CALLBACK_0100', 1, async function (done) {
console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_START_CALLBACK_0100--------------");
if (isEmpty(videoOutput)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_START_CALLBACK_0100 videoOutput == null || undefined")
expect().assertFail();
} else {
videoOutput.start(async (err, data) => {
if (!err) {
expect(true).assertTrue();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_START_CALLBACK_0100 success");
} else {
expect().assertFail();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_START_CALLBACK_0100 FAILED: " + err.message);
}
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_START_CALLBACK_0100 ends here");
await sleep(1000);
done();
})
}
await sleep(1000);
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_STOP_CALLBACK_0100
* @tc.name : videoOutput stop async api
* @tc.desc : videoOutput stop async api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_STOP_CALLBACK_0100', 1, async function (done) {
console.info(TAG + " --------------SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_STOP_CALLBACK_0100--------------");
if (isEmpty(videoOutput)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_STOP_CALLBACK_0100 videoOutput == null || undefined")
expect().assertFail();
} else {
videoOutput.stop(async (err, data) => {
if (!err) {
expect(true).assertTrue();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_STOP_CALLBACK_0100 success");
} else {
expect().assertFail();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_STOP_CALLBACK_0100 FAILED: " + err.message);
}
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_STOP_CALLBACK_0100 ends here");
await sleep(1000);
done();
})
}
await sleep(1000);
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_CALLBACK_ON_FRAME_START_0100
* @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 1
*/
it('SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_CALLBACK_ON_FRAME_START_0100', 1, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_CALLBACK_ON_FRAME_START_0100--------------");
if (isEmpty(videoOutput)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_CALLBACK_ON_FRAME_START_0100 videoOutput == null || undefined")
expect().assertFail();
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_CALLBACK_ON_FRAME_START_0100 to operate");
videoOutput.on('frameStart', async (err, data) => {
if (!err) {
expect(true).assertTrue();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_CALLBACK_ON_FRAME_START_0100 success");
} else {
expect().assertFail();
console.info(TAG + "Error in SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_CALLBACK_ON_FRAME_START_0100 FAILED: " + err.message);
}
await sleep(1000);
done();
})
}
await sleep(1000);
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_CALLBACK_ON_FRAME_END_0100
* @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 1
*/
it('SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_CALLBACK_ON_FRAME_END_0100', 1, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_CALLBACK_ON_FRAME_END_0100--------------");
if (isEmpty(videoOutput)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_CALLBACK_ON_FRAME_END_0100 videoOutput == null || undefined")
expect().assertFail();
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_CALLBACK_ON_FRAME_END_0100 to operate");
videoOutput.on('frameEnd', async (err, data) => {
if (!err) {
expect(true).assertTrue();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_CALLBACK_ON_FRAME_END_0100 success");
} else {
expect().assertFail();
console.info(TAG + "Error in SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_CALLBACK_ON_FRAME_END_0100 FAILED: " + err.message);
}
await sleep(1000);
done();
})
}
await sleep(1000);
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_CALLBACK_ON_FRAME_ERROR_0100
* @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 1
*/
it('SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_CALLBACK_ON_FRAME_ERROR_0100', 1, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_CALLBACK_ON_FRAME_ERROR_0100--------------");
if (isEmpty(videoOutput)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_CALLBACK_ON_FRAME_ERROR_0100 videoOutput == null || undefined")
expect().assertFail();
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_CALLBACK_ON_FRAME_ERROR_0100 to operate");
videoOutput.on('error', async (err, data) => {
if (!err) {
expect(true).assertTrue();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_CALLBACK_ON_FRAME_ERROR_0100 success");
} else {
expect().assertFail();
console.info(TAG + "Error in SUB_MULTIMEDIA_CAMERA_VIDEO_OUTPUT_CALLBACK_ON_FRAME_ERROR_0100 FAILED: " + err.message);
}
await sleep(1000);
done();
})
}
await sleep(1000);
done();
})
})
}
\ No newline at end of file
/*
* 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 mediaLibrary from '@ohos.multimedia.mediaLibrary';
import media from '@ohos.multimedia.media';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium';
const TAG = "CameraUnitTest: ";
// Define global variables
let mCameraManager;
let mCameraDevicesArray;
let mPhotoSurface;
let mVideoRecorder;
let mVideoSurface;
let mFileAsset;
let mFdPath;
let mFdNumber;
// CAMERA-0 letiables
let mCameraNum;
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() {
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')
mPhotoSurface = await receiver.getReceivingSurfaceId()
console.log(TAG + 'Received id: ' + JSON.stringify(mPhotoSurface))
} 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) => {
if (!err) {
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) => {
if (!err) {
console.info(TAG + 'videoRecorder.prepare success.')
mVideoRecorder.getInputSurface((err, id) => {
console.info(TAG + 'getInputSurface called')
if (!err) {
mVideoSurface = id
console.info(TAG + 'getInputSurface surfaceId: ' + JSON.stringify(mVideoSurface))
} else {
console.info(TAG + 'getInputSurface FAILED')
}
})
} else {
console.info(TAG + 'prepare FAILED')
}
})
} else {
console.info(TAG + 'createVideoRecorder FAILED')
}
})
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;
}
function getCameraManagerInstance() {
console.info('Enter getCameraManagerInstance');
mCameraManager = cameraObj.getCameraManager(null);
if (isEmpty(mCameraManager)) {
console.info(TAG + "getCameraManager FAILED");
return false;
}
console.info('Exit getCameraManagerInstance');
return true;
}
function getCameraSupportDevicesArray() {
console.info('Enter getCameraSupportDevicesArray');
mCameraDevicesArray = mCameraManager.getSupportedCameras();
/*
mCameraManager.getSupportedCameras(async (err, data) => {
console.info(TAG + "Entering getCameraSupportDevicesArray callback");
if (!err) {
if (data != null || data != undefined) {
mCameraDevicesArray = data;
console.info(TAG + "Entering getCameraSupportDevicesArray PASSED with CameraDevicesArray is: " + data);
} else {
console.info(TAG + "Entering getCameraSupportDevicesArray FAILED with CameraDevicesArray is: " + data);
}
} else {
console.info(TAG + "Entering getCameraSupportDevicesArray FAILED : " + err.message);
}
})
await sleep(3000);
*/
if (isEmpty(mCameraDevicesArray)) {
console.info(TAG + "getSupportedCameras FAILED");
return false;
}
//mCameraNum = 1;
mCameraNum = mCameraDevicesArray.length;
console.info(TAG + "getCameraSupportDevicesArray is: " + mCameraNum);
console.info('Exit getCameraSupportDevicesArray');
return true;
}
function getSupportedOutputCapability(cameraDevice) {
if (isEmpty(mCameraManager)) {
console.info(TAG + "Entering getSupportedOutputCapability cameraManager == null || undefined")
expect().assertFail();
return undefined;
}
let outputCapability = mCameraManager.getSupportedOutputCapability(cameraDevice);
if (isEmpty(outputCapability)) {
console.info(TAG + "Entering getSupportedOutputCapability outputCapability == null || undefined")
} else {
console.info("CameraUnitTest: getSupportedOutputCapability: " + JSON.stringify(outputCapability));
}
return outputCapability;
}
describe('CameraManagerTest', function () {
console.info(TAG + '----------CameraManagerTest--------------')
beforeAll(async function () {
getCameraManagerInstance();
await getImageReceiverSurfaceId();
await getVideoReceiveSurface();
getCameraSupportDevicesArray();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_GET_CAMERA_MANAGER_PROMISE_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_GET_CAMERA_MANAGER_PROMISE_0100--------------");
let cameraManagerPromise = cameraObj.getCameraManager(null);
expect(isEmpty(cameraManagerPromise)).assertFalse();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_CAMERA_MANAGER_PROMISE_0100 cameraManagerPromise: " + JSON.stringify(cameraManagerPromise));
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 2
*/
it('SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_PROMISE_0100', 2, 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 = 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 2
*/
it('SUB_MULTIMEDIA_CAMERA_GET_SUPPORTED_CAMERA_OUTPUT_CAPABILITY_CALLBACK_0100', 2, 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 = getSupportedOutputCapability(camerasArray[i]);
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_SUPPORTED_CAMERA_OUTPUT_CAPABILITY_CALLBACK_0100 camera:" + camerasArray[i].cameraId);
if (!isEmpty(cameraOutputCap)) {
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");
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 2
*/
it('SUB_MULTIMEDIA_CAMERA_GET_SUPPORTED_CAMERA_OUTPUT_CAPABILITY_PROMISE_0100', 2, 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 = getSupportedOutputCapability(mCameraDevicesArray[i]);
console.info("Entering SUB_MULTIMEDIA_CAMERA_GET_SUPPORTED_CAMERA_OUTPUT_CAPABILITY_PROMISE_0100 camera:" + mCameraDevicesArray[i].cameraId);
if (!isEmpty(cameraOutputCap)) {
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");
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 2
*/
it('SUB_MULTIMEDIA_CAMERA_PREVIEW_PROFILES_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_PREVIEW_PROFILES_0100--------------");
let camerasArray = mCameraDevicesArray;
for (let i = 0; i < camerasArray.length; i++) {
let cameraOutputCap = getSupportedOutputCapability(camerasArray[i]);
console.info("Entering SUB_MULTIMEDIA_CAMERA_PREVIEW_PROFILES_0100 camera:" + camerasArray[i].cameraId);
if (!isEmpty(cameraOutputCap)) {
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);
}
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 2
*/
it('SUB_MULTIMEDIA_CAMERA_PHOTO_PROFILES_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_PHOTO_PROFILES_0100--------------");
let camerasArray = mCameraDevicesArray;
for (let i = 0; i < camerasArray.length; i++) {
let cameraOutputCap = getSupportedOutputCapability(camerasArray[i]);
console.info("Entering SUB_MULTIMEDIA_CAMERA_PHOTO_PROFILES_0100 camera:" + camerasArray[i].cameraId);
if (!isEmpty(cameraOutputCap)) {
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);
}
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 2
*/
it('SUB_MULTIMEDIA_CAMERA_VIDEO_PROFILES_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_VIDEO_PROFILES_0100--------------");
let camerasArray = mCameraDevicesArray;
for (let i = 0; i < camerasArray.length; i++) {
let cameraOutputCap = getSupportedOutputCapability(camerasArray[i]);
console.info("Entering SUB_MULTIMEDIA_CAMERA_VIDEO_PROFILES_0100 camera:" + camerasArray[i].cameraId);
if (!isEmpty(cameraOutputCap)) {
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);
}
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 2
*/
it('SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_PROMISE_0100', 2, 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 = 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");
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_BY_POSITION_AND_TYPE_PROMISE_0100
* @tc.name : Create camerainput from camera-0 cameraposition back & cameratype unspecified promise api
* @tc.desc : Create camerainput from camera-0 cameraposition back & cameratype unspecified promise api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_BY_POSITION_AND_TYPE_PROMISE_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_BY_POSITION_AND_TYPE_PROMISE_0100--------------");
if (isEmpty(mCameraManager)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_BY_POSITION_AND_TYPE_PROMISE_0100 cameraManager == null || undefined")
expect().assertFail();
} else {
let camerasArray = mCameraDevicesArray;
for (let i = 0; i < camerasArray.length; i++) {
let cameraInputPromiseByType = mCameraManager.createCameraInput(camerasArray[i].cameraPosition, camerasArray[i].cameraType);
if (isEmpty(cameraInputPromiseByType)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_BY_POSITION_AND_TYPE_PROMISE_0100 cameraInputPromiseByType == null || undefined")
expect().assertFail();
}
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_BY_POSITION_AND_TYPE_PROMISE_0100 camera: " + camerasArray[i].cameraId);
}
}
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_INPUT_BY_POSITION_AND_TYPE_PROMISE_0100 ends here");
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 2
*/
it('SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_PREVIEW_OUTPUT_PROMISE_0100', 2, 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 = getSupportedOutputCapability(camerasArray[i]);
console.info("SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_PREVIEW_OUTPUT_PROMISE_0100 camera:" + camerasArray[i].cameraId);
if (!isEmpty(cameraOutputCap)) {
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();
} else {
for (let j = 0; j < previewProfilesArray.length; j++) {
let previewOutputPromise = mCameraManager.createPreviewOutput(previewProfilesArray[j], globalThis.surfaceId);
if (isEmpty(previewOutputPromise)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_PREVIEW_OUTPUT_PROMISE_0100 previewOutputPromise == null || undefined")
expect().assertFail();
}
}
}
}
}
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_PROMISE_0100
* @tc.name : Create camerainput from camera-0 cameraposition front & cameratype unspecified async api
* @tc.desc : Create camerainput from camera-0 cameraposition front & cameratype unspecified async api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_PHOTO_OUTPUT_PROMISE_0100', 2, 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 = getSupportedOutputCapability(camerasArray[i]);
console.info("SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_PHOTO_OUTPUT_PROMISE_0100 camera:" + camerasArray[i].cameraId);
if (!isEmpty(cameraOutputCap)) {
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();
} else {
for (let j = 0; j < photoProfilesArray.length; j++) {
let photoOutputPromise = mCameraManager.createPhotoOutput(photoProfilesArray[j], mPhotoSurface);
if (isEmpty(photoOutputPromise)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_PHOTO_OUTPUT_PROMISE_0100 photoOutputPromise == null || undefined")
expect().assertFail();
}
}
}
}
}
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_PHOTO_OUTPUT_PROMISE_0100 PASS");
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 2
*/
it('SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_VIDEO_OUTPUT_PROMISE_0100', 2, 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 = getSupportedOutputCapability(camerasArray[i]);
console.info("SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_VIDEO_OUTPUT_PROMISE_0100 camera:" + camerasArray[i].cameraId);
if (!isEmpty(cameraOutputCap)) {
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();
} else {
for (let j = 0; j < videoProfilesArray.length; j++) {
let videoOutputPromise = 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();
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_VIDEO_OUTPUT_CALLBACK_0100 videoOutputPromise = " + videoOutputPromise);
break;
}
}
}
}
}
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_VIDEO_OUTPUT_PROMISE_0100 PASS");
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_METADATA_OUTPUT_PROMISE_0100
* @tc.name : Create camerainput from camera-0 cameraposition front & cameratype unspecified async api
* @tc.desc : Create camerainput from camera-0 cameraposition front & cameratype unspecified async api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_METADATA_OUTPUT_PROMISE_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_METADATA_OUTPUT_PROMISE_0100--------------");
let camerasArray = mCameraDevicesArray;
for (let i = 0; i < camerasArray.length; i++) {
let cameraOutputCap = getSupportedOutputCapability(camerasArray[i]);
console.info("SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_METADATA_OUTPUT_PROMISE_0100 camera:" + camerasArray[i].cameraId);
if (!isEmpty(cameraOutputCap)) {
let metadataObjectTypeArray = cameraOutputCap.supportedMetadataObjectTypes;
if (!isEmpty(metadataObjectTypeArray)) {
let metadataOutputPromise = mCameraManager.createMetadataOutput(metadataObjectTypeArray);
if (isEmpty(metadataOutputPromise)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_METADATA_OUTPUT_PROMISE_0100 metadataOutputPromise == null || undefined")
expect().assertFail();
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_METADATA_OUTPUT_PROMISE_0100 metadataOutputPromise = " + metadataOutputPromise)
}
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_METADATA_OUTPUT_PROMISE_0100 metadataObjectTypeArray == null || undefined")
}
}
}
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_METADATA_OUTPUT_PROMISE_0100 PASS");
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 2
*/
it('SUB_MULTIMEDIA_CAMERA_CREATE_CAPTURE_SESSION_PROMISE_0100', 2, async function (done) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAPTURE_SESSION_PROMISE_0100 to operate");
let captureSessionPromise = 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 captureSessionPromise.release();
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_IS_CAMERA_MUTED_0100
* @tc.name : Get camera mute
* @tc.desc : Get camera mute
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_MULTIMEDIA_CAMERA_IS_CAMERA_MUTED_0100', 2, async function (done) {
console.info(TAG + "--------------SUB_MULTIMEDIA_CAMERA_IS_CAMERA_MUTED_0100--------------");
if (isEmpty(mCameraManager)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_IS_CAMERA_MUTED_0100 cameraManager == null || undefined")
expect().assertFail();
}
try {
let isCameraMuted = mCameraManager.isCameraMuted();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_IS_CAMERA_MUTED_0100 isCameraMuted : " + isCameraMuted);
expect(isEmpty(isCameraMuted)).assertFalse();
} catch (err) {
console.log(TAG + "isCameraMuted has failed for " + err.message);
expect().assertFail();
}
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ON_CAMERASTATUS_0100
* @tc.name : camera manager on cameraStatus api
* @tc.desc : camera manager on cameraStatus api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_MULTIMEDIA_CAMERA_ON_CAMERASTATUS_0100', 1, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ON_CAMERASTATUS_0100--------------");
if (isEmpty(mCameraManager)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ON_CAMERASTATUS_0100 mCameraManager == null || undefined")
expect().assertFail();
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ON_CAMERASTATUS_0100 to operate");
mCameraManager.on('cameraStatus', async (err, data) => {
if (!err) {
expect(true).assertTrue();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ON_CAMERASTATUS_0100 success");
} else {
expect().assertFail();
console.info(TAG + "Error in SUB_MULTIMEDIA_CAMERA_ON_CAMERASTATUS_0100 FAILED: " + err.message);
}
await sleep(1000);
done();
})
}
await sleep(1000);
done();
})
})
}
\ No newline at end of file
/*
* 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 deviceInfo from '@ohos.deviceInfo';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium';
const TAG = "CameraModuleTest: ";
// Define global letiables
let mCameraManager;
let mCameraDevicesArray;
let mCameraSession;
let mPhotoSurface;
let mVideoRecorder;
let mVideoSurface;
let mFileAsset;
let mFdPath;
let mFdNumber;
// CAMERA-0 letiables
let mCameraNum;
let mCameraInput;
let mPreviewOutput;
let mPhotoOutput;
let mVideoOutput;
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() {
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 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')
mPhotoSurface = await receiver.getReceivingSurfaceId()
console.log(TAG + 'Photo received id: ' + JSON.stringify(mPhotoSurface))
} 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) => {
if (!err) {
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) => {
if (!err) {
console.info(TAG + 'videoRecorder.prepare success.')
mVideoRecorder.getInputSurface((err, id) => {
console.info(TAG + 'getInputSurface called')
if (!err) {
mVideoSurface = id
console.info(TAG + 'getInputSurface surfaceId: ' + JSON.stringify(mVideoSurface))
} else {
console.info(TAG + 'getInputSurface FAILED')
}
})
} else {
console.info(TAG + 'prepare FAILED')
}
})
} else {
console.info(TAG + 'createVideoRecorder FAILED')
}
})
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 getCameraManagerInstance() {
console.info('Enter getCameraManagerInstance');
mCameraManager = cameraObj.getCameraManager(null);
if (isEmpty(mCameraManager)) {
console.info(TAG + "getCameraManager FAILED");
return false;
}
console.info('Exit getCameraManagerInstance');
return true;
}
function getCameraSupportDevicesArray() {
console.info('Enter getCameraSupportDevicesArray');
mCameraDevicesArray = mCameraManager.getSupportedCameras();
if (isEmpty(mCameraDevicesArray)) {
console.info(TAG + "getSupportedCameras FAILED");
return false;
}
//mCameraNum = 1;
mCameraNum = mCameraDevicesArray.length;
console.info(TAG + "getCameraSupportDevicesArray is: " + mCameraNum);
console.info('Exit getCameraSupportDevicesArray');
return true;
}
function createCameraSessionInstance() {
console.info('Enter createCameraSessionInstance');
try {
mCameraSession = mCameraManager.createCaptureSession();
}
catch {
console.info('createCaptureSession FAILED');
}
if (isEmpty(mCameraSession)) {
console.info(TAG + "createCaptureSession FAILED");
return false;
}
// mCameraSession.beginConfig();
console.info('Exit createCameraSessionInstance');
return true;
}
async function releaseCameraSessionInstance() {
await mCameraSession.release();
}
async function createInput(idx:any) {
console.info('Enter createInput');
if (isEmpty(mCameraDevicesArray)) {
console.info(TAG + "Entering createInputs FAILED with NoCamera");
return false;
}
mCameraInput = mCameraManager.createCameraInput(mCameraDevicesArray[idx]);
await mCameraInput.open();
await sleep(100);
console.info(idx + 'th CameraInput is: ' + mCameraInput);
console.info('Exit createInput');
return true;
}
async function releaseInput() {
console.info('Enter releaseInput');
if (!isEmpty(mCameraInput)) {
await mCameraInput.close();
}
console.info('Exit releaseInput');
return true;
}
function createOutput(idx:any) {
console.info('Enter createOutput');
let cameraOutputCap = mCameraManager.getSupportedOutputCapability(mCameraDevicesArray[idx]);
if (!isEmpty(cameraOutputCap)) {
if (!isEmpty(cameraOutputCap.previewProfiles)) {
console.info(TAG + "cameraOutputCap.previewProfiles.length: " + cameraOutputCap.previewProfiles.length);
for (let i = 0; i < cameraOutputCap.previewProfiles.length; i++) {
mPreviewOutput = mCameraManager.createPreviewOutput(cameraOutputCap.previewProfiles[i], globalThis.surfaceId);
if (!isEmpty(mPreviewOutput)) {
break;
}
}
if (isEmpty(mPreviewOutput)) {
console.info(TAG + "createPreviewOutput FAILED");
}
console.info(TAG + "createPreviewOutput: " + mPreviewOutput);
}
if (!isEmpty(cameraOutputCap.photoProfiles)) {
console.info(TAG + "cameraOutputCap.photoProfiles.length: " + cameraOutputCap.photoProfiles.length);
for (let i = 0; i < cameraOutputCap.photoProfiles.length; i++) {
mPhotoOutput = mCameraManager.createPhotoOutput(cameraOutputCap.photoProfiles[i], mPhotoSurface);
if (!isEmpty(mPhotoOutput)) {
break;
}
}
if (isEmpty(mPhotoOutput)) {
console.info(TAG + "createPhotoOutput FAILED");
}
console.info(TAG + "createPhotoOutput: " + mPhotoOutput);
}
if (!isEmpty(cameraOutputCap.videoProfiles)) {
console.info(TAG + "cameraOutputCap.videoProfiles.length: " + cameraOutputCap.videoProfiles.length);
for (let i = 0; i < cameraOutputCap.videoProfiles.length; i++) {
try {
mVideoOutput = mCameraManager.createVideoOutput(cameraOutputCap.videoProfiles[i], mVideoSurface);
if (!isEmpty(mVideoOutput)) {
break;
}
}
catch {
console.info(TAG + "createVideoOutput FAILED");
}
}
if (isEmpty(mVideoOutput)) {
console.info(TAG + "createVideoOutput FAILED");
}
console.info(TAG + "createVideoOutput: " + mVideoOutput);
}
}
console.info('Exit createOutputs');
return true;
}
async function releaseOutput() {
console.info('Enter releaseOutput');
if (!isEmpty(mPreviewOutput)) {
await mPreviewOutput.release();
}
if (!isEmpty(mPhotoOutput)) {
await mPhotoOutput.release();
}
if (!isEmpty(mVideoOutput)) {
await mVideoOutput.release();
}
console.info('Exit releaseOutput');
return true;
}
async function startCameraSession(idx:any) {
console.info(TAG + "Enter startCameraSession");
await createInput(idx);
createOutput(idx);
await sleep(1);
if (!isEmpty(mCameraInput)) {
console.info(TAG + "Start to addInput");
mCameraSession.addInput(mCameraInput);
}
if (!isEmpty(mPreviewOutput)) {
console.info(TAG + "Start to addOutput mPreviewOutput");
mCameraSession.addOutput(mPreviewOutput);
}
if (!isEmpty(mPhotoOutput)) {
console.info(TAG + "Start to addOutput mPhotoOutput");
mCameraSession.addOutput(mPhotoOutput);
}
/*
if (!isEmpty(mVideoOutput)) {
console.info(TAG + "Start to addOutput mVideoOutput");
await mCameraSession.addOutput(mVideoOutput);
}
*/
await sleep(100);
await mCameraSession.commitConfig();
await sleep(100);
/*
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(100);
*/
console.info(TAG + "Exit startCameraSession");
return true;
}
async function stopCameraSession() {
console.info(TAG + "Enter stopCameraSession");
mCameraSession.beginConfig();
/*
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(100);
*/
if (!isEmpty(mCameraInput)) {
console.info(TAG + "Start to removeInput input");
mCameraSession.removeInput(mCameraInput);
}
if (!isEmpty(mPreviewOutput)) {
console.info(TAG + "Start to removeOutput mPreviewOutput");
mCameraSession.removeOutput(mPreviewOutput);
}
if (!isEmpty(mPhotoOutput)) {
console.info(TAG + "Start to removeOutput mPhotoOutput");
mCameraSession.removeOutput(mPhotoOutput);
}
/*
if (!isEmpty(mVideoOutput)) {
console.info(TAG + "Start to removeOutput mVideoOutput");
await mCameraSession.removeOutput(mVideoOutput);
}
*/
await releaseInput();
await releaseOutput();
console.info(TAG + "Exit stopCameraSession");
return true;
}
describe('CameraSessionBaseTest', function () {
console.info(TAG + '----------CameraSessionTest--------------')
beforeAll(async function () {
sleep(100);
await getPhotoReceiverSurface();
await getVideoReceiveSurface();
getCameraManagerInstance();
getCameraSupportDevicesArray();
createCameraSessionInstance();
console.info('Device type = ' + deviceInfo.deviceType);
console.info('beforeAll case');
})
beforeEach(async function () {
await sleep(100);
console.info('beforeEach case');
await sleep(100);
})
afterEach(async function () {
console.info('afterEach case');
await sleep(100);
})
afterAll(function () {
releaseVideoReceiveSurface();
releaseCameraSessionInstance();
sleep(1000);
console.info('afterAll case');
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_BEGIN_CONFIG_0100
* @tc.name : Check capture session begin config
* @tc.desc : Check capture session begin config
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_BEGIN_CONFIG_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_BEGIN_CONFIG_0100--------------");
if (mCameraNum == 0) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_BEGIN_CONFIG_0100 FAILED with NoCamera");
expect().assertFail();
done();
}
else {
mCameraSession.beginConfig();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_BEGIN_CONFIG_0100 PASSED");
done();
}
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_COMMIT_CONFIG_0100
* @tc.name : Check capture session commit config
* @tc.desc : Check capture session commit config
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_COMMIT_CONFIG_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_COMMIT_CONFIG_0100--------------");
if (mCameraNum == 0) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_COMMIT_CONFIG_0100 FAILED with NoCamera");
expect().assertFail();
done();
}
else {
await createInput(0);
createOutput(0);
if (!isEmpty(mCameraInput)) {
console.info(TAG + "Start to addInput");
mCameraSession.addInput(mCameraInput);
}
if (!isEmpty(mPreviewOutput)) {
console.info(TAG + "Start to addOutput mPreviewOutput");
mCameraSession.addOutput(mPreviewOutput);
}
if (!isEmpty(mPhotoOutput)) {
console.info(TAG + "Start to addOutput mPhotoOutput");
mCameraSession.addOutput(mPhotoOutput);
}
await mCameraSession.commitConfig();
await stopCameraSession();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_COMMIT_CONFIG_0100 PASSED");
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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_INPUT_PROMISE_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_INPUT_PROMISE_0100--------------");
if (mCameraNum == 0) {
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 < mCameraNum; i++) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_INPUT_PROMISE_0100 start for camera[" + i + "]");
await createInput(i);
mCameraSession.addInput(mCameraInput);
mCameraSession.removeInput(mCameraInput);
await releaseInput();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_OUTPUT_PROMISE_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_OUTPUT_PROMISE_0100--------------");
if (mCameraNum == 0) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_OUTPUT_PROMISE_0100 FAILED with NoCamera");
expect().assertFail();
done();
}
else {
createOutput(0);
mCameraSession.addOutput(mPreviewOutput);
mCameraSession.addOutput(mPhotoOutput);
mCameraSession.addOutput(mVideoOutput);
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_OUTPUT_PROMISE_0100 add PASSED");
mCameraSession.removeOutput(mPreviewOutput);
mCameraSession.removeOutput(mPhotoOutput);
mCameraSession.removeOutput(mVideoOutput);
await releaseOutput();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_ADD_REMOVE_OUTPUT_PROMISE_0100 ends here");
done();
}
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_START_STOP_PROMISE_0100
* @tc.name : Check capture session start/stop/release output with promise or not
* @tc.desc : Check capture session start/stop/release output with promise or not
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_START_STOP_PROMISE_0100', 0, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_START_STOP_PROMISE_0100--------------");
if (mCameraNum == 0) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_START_STOP_PROMISE_0100 FAILED with NoCamera");
expect().assertFail();
done();
}
else {
for (let i = 0; i < mCameraNum; i++) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_START_STOP_PROMISE_0100 start for camera[" + i + "]");
await startCameraSession(i);
await mCameraSession.start();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_START_STOP_PROMISE_0100 start PASSED");
await sleep(2000);
await mCameraSession.stop();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_START_STOP_PROMISE_0100 stop PASSED");
await sleep(500);
await stopCameraSession();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_START_STOP_PROMISE_0100 end for camera[" + i + "]");
}
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_START_STOP_PROMISE_0100 ends here");
done();
}
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_SESSION_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_RELEASE_PROMISE_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_RELEASE_PROMISE_0100--------------");
await mCameraSession.release();
// createCameraSessionInstance();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_RELEASE_PROMISE_0100 ends here");
done();
})
})
}
\ No newline at end of file
/*
* 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 deviceInfo from '@ohos.deviceInfo';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium';
const TAG = "CameraModuleTest: ";
// Define global letiables
let mCameraManager;
let mCameraDevicesArray;
let mCameraSession;
let mPhotoSurface;
let mVideoRecorder;
let mVideoSurface;
let mFileAsset;
let mFdPath;
let mFdNumber;
// CAMERA-0 letiables
let mCameraNum;
let mCameraInput;
let mPreviewOutput;
let mPhotoOutput;
let mVideoOutput;
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 = 1;
let mPicHeightMax = 1;
let mMETERINGPoint = {
x: mPicWidthMax / 2.0,
y: mPicHeightMax / 2.0,
}
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() {
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 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')
mPhotoSurface = await receiver.getReceivingSurfaceId()
console.log(TAG + 'Photo received id: ' + JSON.stringify(mPhotoSurface))
} 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) => {
if (!err) {
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) => {
if (!err) {
console.info(TAG + 'videoRecorder.prepare success.')
mVideoRecorder.getInputSurface((err, id) => {
console.info(TAG + 'getInputSurface called')
if (!err) {
mVideoSurface = id
console.info(TAG + 'getInputSurface surfaceId: ' + JSON.stringify(mVideoSurface))
} else {
console.info(TAG + 'getInputSurface FAILED')
}
})
} else {
console.info(TAG + 'prepare FAILED')
}
})
} else {
console.info(TAG + 'createVideoRecorder FAILED')
}
})
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 getCameraManagerInstance() {
console.info('Enter getCameraManagerInstance');
mCameraManager = cameraObj.getCameraManager(null);
if (isEmpty(mCameraManager)) {
console.info(TAG + "getCameraManager FAILED");
return false;
}
console.info('Exit getCameraManagerInstance');
return true;
}
function getCameraSupportDevicesArray() {
console.info('Enter getCameraSupportDevicesArray');
mCameraDevicesArray = mCameraManager.getSupportedCameras();
/*
mCameraManager.getSupportedCameras(async (err, data) => {
console.info(TAG + "Entering getCameraSupportDevicesArray callback");
if (!err) {
if (data != null || data != undefined) {
mCameraDevicesArray = data;
console.info(TAG + "Entering getCameraSupportDevicesArray PASSED with CameraDevicesArray is: " + data);
} else {
console.info(TAG + "Entering getCameraSupportDevicesArray FAILED with CameraDevicesArray is: " + data);
}
} else {
console.info(TAG + "Entering getCameraSupportDevicesArray FAILED : " + err.message);
}
})
await sleep(3000);
*/
if (isEmpty(mCameraDevicesArray)) {
console.info(TAG + "getSupportedCameras FAILED");
return false;
}
//mCameraNum = 1;
mCameraNum = mCameraDevicesArray.length;
console.info(TAG + "getCameraSupportDevicesArray is: " + mCameraNum);
mIsExposureModeSupportedArray = new Array(mCameraNum);
mExposureBiasRangeArray = new Array(mCameraNum);
mExposureBiasMaxArray = new Array(mCameraNum);
mExposureBiasMinArray = new Array(mCameraNum);
console.info('Exit getCameraSupportDevicesArray');
return true;
}
function createCameraSessionInstance() {
console.info('Enter createCameraSessionInstance');
try {
mCameraSession = mCameraManager.createCaptureSession();
}
catch {
console.info('createCaptureSession FAILED');
}
if (isEmpty(mCameraSession)) {
console.info(TAG + "createCaptureSession FAILED");
return false;
}
mCameraSession.beginConfig();
console.info('Exit createCameraSessionInstance');
return true;
}
async function releaseCameraSessionInstance() {
await mCameraSession.release();
}
async function createInput(idx:any) {
console.info('Enter createInput');
if (isEmpty(mCameraDevicesArray)) {
console.info(TAG + "Entering createInputs FAILED with NoCamera");
return false;
}
mCameraInput = mCameraManager.createCameraInput(mCameraDevicesArray[idx]);
if (isEmpty(mCameraInput)) {
console.info(TAG + "createCameraInput FAILED");
return false;
}
await mCameraInput.open();
await sleep(100);
console.info(idx + 'th CameraInput is: ' + mCameraInput);
console.info('Exit createInput');
return true;
}
async function releaseInput() {
console.info('Enter releaseInput');
if (!isEmpty(mCameraInput)) {
await mCameraInput.close();
}
console.info('Exit releaseInput');
return true;
}
function createOutput(idx:any) {
console.info('Enter createOutput');
let cameraOutputCap = mCameraManager.getSupportedOutputCapability(mCameraDevicesArray[idx]);
if (!isEmpty(cameraOutputCap)) {
if (!isEmpty(cameraOutputCap.previewProfiles)) {
console.info(TAG + "cameraOutputCap.previewProfiles.length: " + cameraOutputCap.previewProfiles.length);
for (let i = 0; i < cameraOutputCap.previewProfiles.length; i++) {
mPreviewOutput = mCameraManager.createPreviewOutput(cameraOutputCap.previewProfiles[i], globalThis.surfaceId);
if (!isEmpty(mPreviewOutput)) {
break;
}
}
if (isEmpty(mPreviewOutput)) {
console.info(TAG + "createPreviewOutput FAILED");
}
console.info(TAG + "createPreviewOutput: " + mPreviewOutput);
}
if (!isEmpty(cameraOutputCap.photoProfiles)) {
console.info(TAG + "cameraOutputCap.photoProfiles.length: " + cameraOutputCap.photoProfiles.length);
for (let i = 0; i < cameraOutputCap.photoProfiles.length; i++) {
mPhotoOutput = mCameraManager.createPhotoOutput(cameraOutputCap.photoProfiles[i], mPhotoSurface);
if (!isEmpty(mPhotoOutput)) {
break;
}
}
if (isEmpty(mPhotoOutput)) {
console.info(TAG + "createPhotoOutput FAILED");
}
console.info(TAG + "createPhotoOutput: " + mPhotoOutput);
}
/*
if (!isEmpty(cameraOutputCap.videoProfiles)) {
console.info(TAG + "cameraOutputCap.videoProfiles.length: " + cameraOutputCap.videoProfiles.length);
for (let i = 0; i < cameraOutputCap.videoProfiles.length; i++) {
try {
mVideoOutput = await mCameraManager.createVideoOutput(cameraOutputCap.videoProfiles[i], mVideoSurface);
if (!isEmpty(mVideoOutput)) {
break;
}
}
catch {
console.info(TAG + "createVideoOutput FAILED");
}
}
if (isEmpty(mVideoOutput)) {
console.info(TAG + "createVideoOutput FAILED");
}
console.info(TAG + "createVideoOutput: " + mVideoOutput);
}
*/
}
console.info('Exit createOutputs');
return true;
}
async function releaseOutput() {
console.info('Enter releaseOutput');
if (!isEmpty(mPreviewOutput)) {
await mPreviewOutput.release();
}
if (!isEmpty(mPhotoOutput)) {
await mPhotoOutput.release();
}
/*
if (!isEmpty(mVideoOutput)) {
await mVideoOutput.stop();
await mVideoOutput.release();
}
*/
console.info('Exit releaseOutput');
return true;
}
async function startCameraSession(idx:any) {
console.info(TAG + "Enter startCameraSession");
await createInput(idx);
createOutput(idx);
await sleep(1);
if (!isEmpty(mCameraInput)) {
console.info(TAG + "Start to addInput");
mCameraSession.addInput(mCameraInput);
}
if (!isEmpty(mPreviewOutput)) {
console.info(TAG + "Start to addOutput mPreviewOutput");
mCameraSession.addOutput(mPreviewOutput);
}
if (!isEmpty(mPhotoOutput)) {
console.info(TAG + "Start to addOutput mPhotoOutput");
mCameraSession.addOutput(mPhotoOutput);
}
/*
if (!isEmpty(mVideoOutput)) {
console.info(TAG + "Start to addOutput mVideoOutput");
await mCameraSession.addOutput(mVideoOutput);
}
*/
await sleep(1);
await mCameraSession.commitConfig();
/*
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(100);
*/
console.info(TAG + "Exit startCameraSession");
return true;
}
async function stopCameraSession() {
console.info(TAG + "Enter stopCameraSession");
mCameraSession.beginConfig();
/*
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(100);
*/
if (!isEmpty(mCameraInput)) {
console.info(TAG + "Start to removeInput input");
mCameraSession.removeInput(mCameraInput);
}
if (!isEmpty(mPreviewOutput)) {
console.info(TAG + "Start to removeOutput mPreviewOutput");
mCameraSession.removeOutput(mPreviewOutput);
}
if (!isEmpty(mPhotoOutput)) {
console.info(TAG + "Start to removeOutput mPhotoOutput");
mCameraSession.removeOutput(mPhotoOutput);
}
/*
if (!isEmpty(mVideoOutput)) {
console.info(TAG + "Start to removeOutput mVideoOutput");
await mCameraSession.removeOutput(mVideoOutput);
}
*/
await releaseInput();
await releaseOutput();
console.info(TAG + "Exit stopCameraSession");
return true;
}
describe('cameraSessionExposureTest', function () {
console.info(TAG + '----------cameraSessionExposureTest--------------')
beforeAll(async function () {
sleep(100);
await getPhotoReceiverSurface();
await getVideoReceiveSurface();
getCameraManagerInstance();
getCameraSupportDevicesArray();
createCameraSessionInstance();
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 () {
releaseVideoReceiveSurface();
releaseCameraSessionInstance();
sleep(1000);
console.info('afterAll case');
})
/**
* @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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_PROMISE_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_PROMISE_0100--------------");
if (mCameraNum == 0) {
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 < mCameraNum; i++) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_PROMISE_0100 start for camera[" + i + "]");
await startCameraSession(i);
let isExposureModeSupported = 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 stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_PROMISE_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_PROMISE_0100--------------");
if (mCameraNum == 0) {
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 < mCameraNum; 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) {
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);
let exposureMode = 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();
}
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_PROMISE_0100 not support");
}
await stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_PROMISE_0101', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_PROMISE_0101--------------");
if (mCameraNum == 0) {
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 < mCameraNum; i++) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_PROMISE_0101 start for camera[" + i + "]");
await startCameraSession(i);
let isExposureModeSupported = 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 stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_PROMISE_0101', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_PROMISE_0101--------------");
if (mCameraNum == 0) {
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 < mCameraNum; 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) {
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);
let exposureMode = 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();
}
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_PROMISE_0101 not support");
}
await stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_PROMISE_0101', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_PROMISE_0102--------------");
if (mCameraNum == 0) {
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 < mCameraNum; i++) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_EXPOSURE_MODE_SUPPORT_PROMISE_0102 start for camera[" + i + "]");
await startCameraSession(i);
let isExposureModeSupported = 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 stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_PROMISE_0102', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_PROMISE_0102--------------");
if (mCameraNum == 0) {
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 < mCameraNum; 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) {
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);
let exposureMode = 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();
}
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_MODE_PROMISE_0102 not support");
}
await stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0100--------------");
if (mCameraNum == 0) {
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 < mCameraNum; i++) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0100 start for camera[" + i + "]");
await startCameraSession(i);
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);
let METERINGPoint = 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 stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0101', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0101--------------");
if (mCameraNum == 0) {
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 < mCameraNum; i++) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0101 start for camera[" + i + "]");
await startCameraSession(i);
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);
let METERINGPoint = 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 stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0102', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0102--------------");
if (mCameraNum == 0) {
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 < mCameraNum; i++) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0102 start for camera[" + i + "]");
await startCameraSession(i);
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);
let METERINGPoint = 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 stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0103', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0103--------------");
if (mCameraNum == 0) {
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 < mCameraNum; i++) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0103 start for camera[" + i + "]");
await startCameraSession(i);
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);
let METERINGPoint = 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 stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0104', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0104--------------");
if (mCameraNum == 0) {
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 < mCameraNum; i++) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0104 start for camera[" + i + "]");
await startCameraSession(i);
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);
let METERINGPoint = 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 stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0105', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0105--------------");
if (mCameraNum == 0) {
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 < mCameraNum; i++) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0105 start for camera[" + i + "]");
await startCameraSession(i);
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);
let METERINGPoint = 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 stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0106', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0106--------------");
if (mCameraNum == 0) {
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 < mCameraNum; i++) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0106 start for camera[" + i + "]");
await startCameraSession(i);
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);
let METERINGPoint = 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 stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0107', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0107--------------");
if (mCameraNum == 0) {
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 < mCameraNum; i++) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0107 start for camera[" + i + "]");
await startCameraSession(i);
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);
let METERINGPoint = 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 stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0108', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0108--------------");
if (mCameraNum == 0) {
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 < mCameraNum; i++) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_METERING_POINT_PROMISE_0108 start for camera[" + i + "]");
await startCameraSession(i);
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);
let METERINGPoint = 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 stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_GET_EXPOSURE_BIAS_RANGE_PROMISE_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_GET_EXPOSURE_BIAS_RANGE_PROMISE_0100--------------");
if (mCameraNum == 0) {
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 < mCameraNum; i++) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_GET_EXPOSURE_BIAS_RANGE_PROMISE_0100 start for camera[" + i + "]");
await startCameraSession(i);
let exposureBiasRange = mCameraSession.getExposureBiasRange();
mExposureBiasRangeArray[i] = exposureBiasRange;
mExposureBiasMaxArray[i] = exposureBiasRange[exposureBiasRange.length -1];
mExposureBiasMinArray[i] = exposureBiasRange[0];
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 stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0100--------------");
if (mCameraNum == 0) {
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 < mCameraNum; i++) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0100 start for camera[" + i + "]");
let exposureBias = mExposureBiasRangeArray[i][0];
if (exposureBias == 0) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0100 exposureBias is 0");
} else {
await startCameraSession(i);
mCameraSession.setExposureBias(exposureBias);
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]);
let exposureValue = 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 stopCameraSession();
}
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0101', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0101--------------");
if (mCameraNum == 0) {
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 < mCameraNum; i++) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0101 start for camera[" + i + "]");
let exposureBias =mExposureBiasMinArray[i];
if (exposureBias == 0) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0101 exposureBias is 0");
} else {
await startCameraSession(i);
mCameraSession.setExposureBias(exposureBias - 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));
let exposureValue = mCameraSession.getExposureValue();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0101 finish");
if (exposureValue != (exposureBias - 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();
}
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0102', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0102--------------");
if (mCameraNum == 0) {
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 < mCameraNum; i++) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0102 start for camera[" + i + "]");
let exposureBias =mExposureBiasMinArray[i];
if (exposureBias == 0) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0102 exposureBias is 0");
} else {
await startCameraSession(i);
mCameraSession.setExposureBias(exposureBias - 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));
let exposureValue = mCameraSession.getExposureValue();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0102 finish");
if (exposureValue != (exposureBias - 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 stopCameraSession();
}
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0103', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0103--------------");
if (mCameraNum == 0) {
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 < mCameraNum; i++) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0103 start for camera[" + i + "]");
let exposureBias = mExposureBiasMaxArray[i];
if (exposureBias == 0) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0103 exposureBias is 0");
} else {
await startCameraSession(i);
mCameraSession.setExposureBias(exposureBias + 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));
let exposureValue = mCameraSession.getExposureValue();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0103 finish");
if (exposureValue != (exposureBias + 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 stopCameraSession();
}
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0104', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0104--------------");
if (mCameraNum == 0) {
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 < mCameraNum; i++) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0104 start for camera[" + i + "]");
let exposureBias = mExposureBiasMaxArray[i];
if (exposureBias == 0) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0104 exposureBias is 0");
} else {
await startCameraSession(i);
mCameraSession.setExposureBias(exposureBias + 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));
let exposureValue = mCameraSession.getExposureValue();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_EXPOSURE_BIAS_PROMISE_0104 finish");
if (exposureValue != (exposureBias + 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 stopCameraSession();
}
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
/*
* 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 deviceInfo from '@ohos.deviceInfo';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium';
const TAG = "CameraModuleTest: ";
// Define global letiables
let mCameraManager;
let mCameraDevicesArray;
let mCameraSession;
let mPhotoSurface;
let mVideoRecorder;
let mVideoSurface;
let mFileAsset;
let mFdPath;
let mFdNumber;
// CAMERA-0 letiables
let mCameraNum;
let mCameraInput;
let mPreviewOutput;
let mPhotoOutput;
let mVideoOutput;
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() {
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 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')
mPhotoSurface = await receiver.getReceivingSurfaceId()
console.log(TAG + 'Photo received id: ' + JSON.stringify(mPhotoSurface))
} 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) => {
if (!err) {
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) => {
if (!err) {
console.info(TAG + 'videoRecorder.prepare success.')
mVideoRecorder.getInputSurface((err, id) => {
console.info(TAG + 'getInputSurface called')
if (!err) {
mVideoSurface = id
console.info(TAG + 'getInputSurface surfaceId: ' + JSON.stringify(mVideoSurface))
} else {
console.info(TAG + 'getInputSurface FAILED')
}
})
} else {
console.info(TAG + 'prepare FAILED')
}
})
} else {
console.info(TAG + 'createVideoRecorder FAILED')
}
})
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')
}
function mgetCameraManagerInstance() {
console.info('Enter mgetCameraManagerInstance');
mCameraManager = cameraObj.getCameraManager(null);
if (isEmpty(mCameraManager)) {
console.info(TAG + "getCameraManager FAILED");
return false;
}
console.info('Exit mgetCameraManagerInstance');
return true;
}
function getCameraSupportDevicesArray() {
console.info('Enter getCameraSupportDevicesArray');
mCameraDevicesArray = mCameraManager.getSupportedCameras();
/*
mCameraManager.getSupportedCameras(async (err, data) => {
console.info(TAG + "Entering getCameraSupportDevicesArray callback");
if (!err) {
if (data != null || data != undefined) {
mCameraDevicesArray = data;
console.info(TAG + "Entering getCameraSupportDevicesArray PASSED with CameraDevicesArray is: " + data);
} else {
console.info(TAG + "Entering getCameraSupportDevicesArray FAILED with CameraDevicesArray is: " + data);
}
} else {
console.info(TAG + "Entering getCameraSupportDevicesArray FAILED : " + err.message);
}
})
await sleep(3000);
*/
if (isEmpty(mCameraDevicesArray)) {
console.info(TAG + "getSupportedCameras FAILED");
return false;
}
//mCameraNum = 1;
mCameraNum = mCameraDevicesArray.length;
console.info(TAG + "getCameraSupportDevicesArray is: " + mCameraNum);
mHasFlashArray = new Array(mCameraNum);
mIsFlashModeSupportedArray = new Array(mCameraNum);
console.info('Exit getCameraSupportDevicesArray');
return true;
}
function createCameraSessionInstance() {
console.info('Enter createCameraSessionInstance');
try {
mCameraSession = mCameraManager.createCaptureSession();
}
catch {
console.info('createCaptureSession FAILED');
}
if (isEmpty(mCameraSession)) {
console.info(TAG + "createCaptureSession FAILED");
return false;
}
mCameraSession.beginConfig();
console.info('Exit createCameraSessionInstance');
return true;
}
async function releaseCameraSessionInstance() {
await mCameraSession.release();
}
async function createInput(idx:any) {
console.info('Enter createInput');
if (isEmpty(mCameraDevicesArray)) {
console.info(TAG + "Entering createInputs FAILED with NoCamera");
return false;
}
mCameraInput = mCameraManager.createCameraInput(mCameraDevicesArray[idx]);
if (isEmpty(mCameraInput)) {
console.info(TAG + "createCameraInput FAILED");
return false;
}
await mCameraInput.open();
await sleep(100);
console.info(idx + 'th CameraInput is: ' + mCameraInput);
console.info('Exit createInput');
return true;
}
async function releaseInput() {
console.info('Enter releaseInput');
if (!isEmpty(mCameraInput)) {
await mCameraInput.close();
}
console.info('Exit releaseInput');
return true;
}
function createOutput(idx:any) {
console.info('Enter createOutput');
let cameraOutputCap = mCameraManager.getSupportedOutputCapability(mCameraDevicesArray[idx]);
if (!isEmpty(cameraOutputCap)) {
if (!isEmpty(cameraOutputCap.previewProfiles)) {
console.info(TAG + "cameraOutputCap.previewProfiles.length: " + cameraOutputCap.previewProfiles.length);
for (let i = 0; i < cameraOutputCap.previewProfiles.length; i++) {
mPreviewOutput = mCameraManager.createPreviewOutput(cameraOutputCap.previewProfiles[i], globalThis.surfaceId);
if (!isEmpty(mPreviewOutput)) {
break;
}
}
if (isEmpty(mPreviewOutput)) {
console.info(TAG + "createPreviewOutput FAILED");
}
console.info(TAG + "createPreviewOutput: " + mPreviewOutput);
}
if (!isEmpty(cameraOutputCap.photoProfiles)) {
console.info(TAG + "cameraOutputCap.photoProfiles.length: " + cameraOutputCap.photoProfiles.length);
for (let i = 0; i < cameraOutputCap.photoProfiles.length; i++) {
mPhotoOutput = mCameraManager.createPhotoOutput(cameraOutputCap.photoProfiles[i], mPhotoSurface);
if (!isEmpty(mPhotoOutput)) {
break;
}
}
if (isEmpty(mPhotoOutput)) {
console.info(TAG + "createPhotoOutput FAILED");
}
console.info(TAG + "createPhotoOutput: " + mPhotoOutput);
}
/*
if (!isEmpty(cameraOutputCap.videoProfiles)) {
console.info(TAG + "cameraOutputCap.videoProfiles.length: " + cameraOutputCap.videoProfiles.length);
for (let i = 0; i < cameraOutputCap.videoProfiles.length; i++) {
try {
mVideoOutput = await mCameraManager.createVideoOutput(cameraOutputCap.videoProfiles[i], mVideoSurface);
if (!isEmpty(mVideoOutput)) {
break;
}
}
catch {
console.info(TAG + "createVideoOutput FAILED");
}
}
if (isEmpty(mVideoOutput)) {
console.info(TAG + "createVideoOutput FAILED");
}
console.info(TAG + "createVideoOutput: " + mVideoOutput);
}
*/
}
console.info('Exit createOutputs');
return true;
}
async function releaseOutput() {
console.info('Enter releaseOutput');
if (!isEmpty(mPreviewOutput)) {
await mPreviewOutput.release();
}
if (!isEmpty(mPhotoOutput)) {
await mPhotoOutput.release();
}
/*
if (!isEmpty(mVideoOutput)) {
await mVideoOutput.stop();
await mVideoOutput.release();
}
*/
console.info('Exit releaseOutput');
return true;
}
async function startCameraSession(idx:any) {
console.info(TAG + "Enter startCameraSession");
await createInput(idx);
createOutput(idx);
await sleep(1);
if (!isEmpty(mCameraInput)) {
console.info(TAG + "Start to addInput");
mCameraSession.addInput(mCameraInput);
}
if (!isEmpty(mPreviewOutput)) {
console.info(TAG + "Start to addOutput mPreviewOutput");
mCameraSession.addOutput(mPreviewOutput);
}
if (!isEmpty(mPhotoOutput)) {
console.info(TAG + "Start to addOutput mPhotoOutput");
mCameraSession.addOutput(mPhotoOutput);
}
/*
if (!isEmpty(mVideoOutput)) {
console.info(TAG + "Start to addOutput mVideoOutput");
await mCameraSession.addOutput(mVideoOutput);
}
*/
await sleep(1);
await mCameraSession.commitConfig();
/*
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(100);
*/
console.info(TAG + "Exit startCameraSession");
return true;
}
async function stopCameraSession() {
console.info(TAG + "Enter stopCameraSession");
mCameraSession.beginConfig();
/*
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(100);
*/
if (!isEmpty(mCameraInput)) {
console.info(TAG + "Start to removeInput input");
mCameraSession.removeInput(mCameraInput);
}
if (!isEmpty(mPreviewOutput)) {
console.info(TAG + "Start to removeOutput mPreviewOutput");
mCameraSession.removeOutput(mPreviewOutput);
}
if (!isEmpty(mPhotoOutput)) {
console.info(TAG + "Start to removeOutput mPhotoOutput");
mCameraSession.removeOutput(mPhotoOutput);
}
// await mCameraSession.commitConfig();
/*
if (!isEmpty(mVideoOutput)) {
console.info(TAG + "Start to removeOutput mVideoOutput");
await mCameraSession.removeOutput(mVideoOutput);
}
*/
await releaseInput();
await releaseOutput();
console.info(TAG + "Exit stopCameraSession");
return true;
}
describe('cameraSessionFlashTest', function () {
console.info(TAG + '----------cameraSessionFlashTest--------------')
beforeAll(async function () {
sleep(100);
await getPhotoReceiverSurface();
await getVideoReceiveSurface();
mgetCameraManagerInstance();
getCameraSupportDevicesArray();
createCameraSessionInstance();
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 () {
releaseVideoReceiveSurface();
releaseCameraSessionInstance();
sleep(1000);
console.info('afterAll case');
})
/**
* @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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_HAS_FLASH_PROMISE_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_HAS_FLASH_PROMISE_0100--------------");
if (mCameraNum == 0) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_HAS_FLASH_PROMISE_0100 FAILED with NoCamera");
expect().assertFail();
done();
}
else {
for (let i = 0; i < mCameraNum; i++) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_HAS_FLASH_PROMISE_0100 start for camera[" + i + "]");
await startCameraSession(i);
let hasFlashPromise = 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(100);
await stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0100--------------");
if (mCameraNum == 0) {
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 < mCameraNum; 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 = 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(100);
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0100 not support");
}
await stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0100--------------");
if (mCameraNum == 0) {
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 < mCameraNum; 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)) {
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);
let flashMode = 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();
}
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0100 not support");
}
await stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0101', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0101--------------");
if (mCameraNum == 0) {
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 < mCameraNum; 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 = 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();
}
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0101 not support");
}
await stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0101', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0101--------------");
if (mCameraNum == 0) {
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 < mCameraNum; 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)) {
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);
let flashMode = 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();
}
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0101 not support");
}
await stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0102', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0102--------------");
if (mCameraNum == 0) {
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 < mCameraNum; 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 = 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();
}
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0102 not support");
}
await stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0102', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0102--------------");
if (mCameraNum == 0) {
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 < mCameraNum; 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)) {
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);
let flashMode = 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();
}
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0102 not support");
}
await stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0103', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0103--------------");
if (mCameraNum == 0) {
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 < mCameraNum; 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 = 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();
}
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FLASH_MODE_SUPPORT_PROMISE_0103 not support");
}
await stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0103', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0103--------------");
if (mCameraNum == 0) {
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 < mCameraNum; 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)) {
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);
let flashMode = 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();
}
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FLASH_MODE_PROMISE_0103 not support");
}
await stopCameraSession();
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
/*
* 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 deviceInfo from '@ohos.deviceInfo';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium';
const TAG = "CameraModuleTest: ";
// Define global letiables
let mCameraManager;
let mCameraDevicesArray;
let mCameraSession;
let mPhotoSurface;
let mVideoRecorder;
let mVideoSurface;
let mFileAsset;
let mFdPath;
let mFdNumber;
// CAMERA-0 letiables
let mCameraNum;
let mCameraInput;
let mPreviewOutput;
let mPhotoOutput;
let mVideoOutput;
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 = 1;
let mPicHeightMax = 1;
let mFocusPoint = {
x: mPicWidthMax / 2.0,
y: mPicHeightMax / 2.0,
}
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() {
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 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')
mPhotoSurface = await receiver.getReceivingSurfaceId()
console.log(TAG + 'Photo received id: ' + JSON.stringify(mPhotoSurface))
} 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) => {
if (!err) {
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) => {
if (!err) {
console.info(TAG + 'videoRecorder.prepare success.')
mVideoRecorder.getInputSurface((err, id) => {
console.info(TAG + 'getInputSurface called')
if (!err) {
mVideoSurface = id
console.info(TAG + 'getInputSurface surfaceId: ' + JSON.stringify(mVideoSurface))
} else {
console.info(TAG + 'getInputSurface FAILED')
}
})
} else {
console.info(TAG + 'prepare FAILED')
}
})
} else {
console.info(TAG + 'createVideoRecorder FAILED')
}
})
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')
}
function getCameraManagerInstance() {
console.info('Enter getCameraManagerInstance');
mCameraManager = cameraObj.getCameraManager(null);
if (isEmpty(mCameraManager)) {
console.info(TAG + "getCameraManager FAILED");
return false;
}
console.info('Exit getCameraManagerInstance');
return true;
}
function getCameraSupportDevicesArray() {
console.info('Enter getCameraSupportDevicesArray');
mCameraDevicesArray = mCameraManager.getSupportedCameras();
if (isEmpty(mCameraDevicesArray)) {
console.info(TAG + "getSupportedCameras FAILED");
return false;
}
mCameraNum = mCameraDevicesArray.length;
console.info(TAG + "getCameraSupportDevicesArray is: " + mCameraNum);
mIsFocusModeSupportedArray = new Array(mCameraNum);
console.info('Exit getCameraSupportDevicesArray');
return true;
}
function createCameraSessionInstance() {
console.info('Enter createCameraSessionInstance');
try {
mCameraSession = mCameraManager.createCaptureSession();
}
catch {
console.info('createCaptureSession FAILED');
}
if (isEmpty(mCameraSession)) {
console.info(TAG + "createCaptureSession FAILED");
return false;
}
mCameraSession.beginConfig();
console.info('Exit createCameraSessionInstance');
return true;
}
async function releaseCameraSessionInstance() {
await mCameraSession.release();
}
async function createInput(idx:any) {
console.info('Enter createInput');
if (isEmpty(mCameraDevicesArray)) {
console.info(TAG + "Entering createInputs FAILED with NoCamera");
return false;
}
mCameraInput = await mCameraManager.createCameraInput(mCameraDevicesArray[idx]);
if (isEmpty(mCameraInput)) {
console.info(TAG + "createCameraInput FAILED");
return false;
}
await mCameraInput.open();
await sleep(100);
console.info(idx + 'th CameraInput is: ' + mCameraInput);
console.info('Exit createInput');
return true;
}
async function releaseInput() {
console.info('Enter releaseInput');
if (!isEmpty(mCameraInput)) {
await mCameraInput.close();
}
console.info('Exit releaseInput');
return true;
}
function createOutput(idx:any) {
console.info('Enter createOutput');
let cameraOutputCap = mCameraManager.getSupportedOutputCapability(mCameraDevicesArray[idx]);
if (!isEmpty(cameraOutputCap)) {
if (!isEmpty(cameraOutputCap.previewProfiles)) {
console.info(TAG + "cameraOutputCap.previewProfiles.length: " + cameraOutputCap.previewProfiles.length);
for (let i = 0; i < cameraOutputCap.previewProfiles.length; i++) {
mPreviewOutput = mCameraManager.createPreviewOutput(cameraOutputCap.previewProfiles[i], globalThis.surfaceId);
if (!isEmpty(mPreviewOutput)) {
break;
}
}
if (isEmpty(mPreviewOutput)) {
console.info(TAG + "createPreviewOutput FAILED");
}
console.info(TAG + "createPreviewOutput: " + mPreviewOutput);
}
if (!isEmpty(cameraOutputCap.photoProfiles)) {
console.info(TAG + "cameraOutputCap.photoProfiles.length: " + cameraOutputCap.photoProfiles.length);
for (let i = 0; i < cameraOutputCap.photoProfiles.length; i++) {
mPhotoOutput = mCameraManager.createPhotoOutput(cameraOutputCap.photoProfiles[i], mPhotoSurface);
if (!isEmpty(mPhotoOutput)) {
break;
}
}
if (isEmpty(mPhotoOutput)) {
console.info(TAG + "createPhotoOutput FAILED");
}
console.info(TAG + "createPhotoOutput: " + mPhotoOutput);
}
/*
if (!isEmpty(cameraOutputCap.videoProfiles)) {
console.info(TAG + "cameraOutputCap.videoProfiles.length: " + cameraOutputCap.videoProfiles.length);
for (let i = 0; i < cameraOutputCap.videoProfiles.length; i++) {
try {
mVideoOutput = await mCameraManager.createVideoOutput(cameraOutputCap.videoProfiles[i], mVideoSurface);
if (!isEmpty(mVideoOutput)) {
break;
}
}
catch {
console.info(TAG + "createVideoOutput FAILED");
}
}
if (isEmpty(mVideoOutput)) {
console.info(TAG + "createVideoOutput FAILED");
}
console.info(TAG + "createVideoOutput: " + mVideoOutput);
}
*/
}
console.info('Exit createOutputs');
return true;
}
async function releaseOutput() {
console.info('Enter releaseOutput');
if (!isEmpty(mPreviewOutput)) {
await mPreviewOutput.release();
}
if (!isEmpty(mPhotoOutput)) {
await mPhotoOutput.release();
}
/*
if (!isEmpty(mVideoOutput)) {
await mVideoOutput.stop();
await mVideoOutput.release();
}
*/
console.info('Exit releaseOutput');
return true;
}
async function startCameraSession(idx:any) {
console.info(TAG + "Enter startCameraSession");
await createInput(idx);
createOutput(idx);
await sleep(1);
if (!isEmpty(mCameraInput)) {
console.info(TAG + "Start to addInput");
mCameraSession.addInput(mCameraInput);
}
if (!isEmpty(mPreviewOutput)) {
console.info(TAG + "Start to addOutput mPreviewOutput");
mCameraSession.addOutput(mPreviewOutput);
}
if (!isEmpty(mPhotoOutput)) {
console.info(TAG + "Start to addOutput mPhotoOutput");
mCameraSession.addOutput(mPhotoOutput);
}
/*
if (!isEmpty(mVideoOutput)) {
console.info(TAG + "Start to addOutput mVideoOutput");
await mCameraSession.addOutput(mVideoOutput);
}
*/
await sleep(1);
await mCameraSession.commitConfig();
/*
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(100);
*/
console.info(TAG + "Exit startCameraSession");
return true;
}
async function stopCameraSession() {
console.info(TAG + "Enter stopCameraSession");
mCameraSession.beginConfig();
/*
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(100);
*/
if (!isEmpty(mCameraInput)) {
console.info(TAG + "Start to removeInput input");
mCameraSession.removeInput(mCameraInput);
}
if (!isEmpty(mPreviewOutput)) {
console.info(TAG + "Start to removeOutput mPreviewOutput");
mCameraSession.removeOutput(mPreviewOutput);
}
if (!isEmpty(mPhotoOutput)) {
console.info(TAG + "Start to removeOutput mPhotoOutput");
mCameraSession.removeOutput(mPhotoOutput);
}
/*
if (!isEmpty(mVideoOutput)) {
console.info(TAG + "Start to removeOutput mVideoOutput");
await mCameraSession.removeOutput(mVideoOutput);
}
*/
await releaseInput();
await releaseOutput();
console.info(TAG + "Exit stopCameraSession");
return true;
}
describe('cameraSessionFocusTest', function () {
console.info(TAG + '----------cameraSessionFocusTest--------------')
beforeAll(async function () {
sleep(100);
await getPhotoReceiverSurface();
await getVideoReceiveSurface();
getCameraManagerInstance();
getCameraSupportDevicesArray();
createCameraSessionInstance();
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 () {
releaseVideoReceiveSurface();
releaseCameraSessionInstance();
sleep(1000);
console.info('afterAll case');
})
/**
* @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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0100--------------");
if (mCameraNum == 0) {
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 < mCameraNum; i++) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0100 start for camera[" + i + "]");
await startCameraSession(i);
let isFocusModeSupported = 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 stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0100--------------");
if (mCameraNum == 0) {
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 < mCameraNum; 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) {
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);
let focusMode = 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();
}
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0100 not support");
}
await stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0101', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0101--------------");
if (mCameraNum == 0) {
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 < mCameraNum; i++) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0101 start for camera[" + i + "]");
await startCameraSession(i);
let isFocusModeSupported = 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 stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0101', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0101--------------");
if (mCameraNum == 0) {
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 < mCameraNum; 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) {
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);
let focusMode = 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();
}
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0101 not support");
}
await stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0102', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0102--------------");
if (mCameraNum == 0) {
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 < mCameraNum; i++) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0102 start for camera[" + i + "]");
await startCameraSession(i);
let isFocusModeSupported = 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(100);
await stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0102', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0102--------------");
if (mCameraNum == 0) {
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 < mCameraNum; 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) {
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);
let focusMode = 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();
}
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0102 not support");
}
await stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0103', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0103--------------");
if (mCameraNum == 0) {
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 < mCameraNum; i++) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_IS_FOCUS_MODE_SUPPORT_PROMISE_0103 start for camera[" + i + "]");
await startCameraSession(i);
let isFocusModeSupported = 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 stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0103', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0103--------------");
if (mCameraNum == 0) {
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 < mCameraNum; 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) {
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);
let focusMode = 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();
}
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_MODE_PROMISE_0103 not support");
}
await stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0100--------------");
if (mCameraNum == 0) {
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 < mCameraNum; i++) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0100 start for camera[" + i + "]");
await startCameraSession(i);
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);
let focusPoint = 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 stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0101', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0101--------------");
if (mCameraNum == 0) {
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 < mCameraNum; i++) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0101 start for camera[" + i + "]");
await startCameraSession(i);
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);
let focusPoint = 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 stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0102', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0102--------------");
if (mCameraNum == 0) {
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 < mCameraNum; i++) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0102 start for camera[" + i + "]");
await startCameraSession(i);
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);
let focusPoint = 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 stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0103', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0103--------------");
if (mCameraNum == 0) {
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 < mCameraNum; i++) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0103 start for camera[" + i + "]");
await startCameraSession(i);
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);
let focusPoint = 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 stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0104', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0104--------------");
if (mCameraNum == 0) {
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 < mCameraNum; i++) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0104 start for camera[" + i + "]");
await startCameraSession(i);
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);
let focusPoint = 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 stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0105', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0105--------------");
if (mCameraNum == 0) {
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 < mCameraNum; i++) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0105 start for camera[" + i + "]");
await startCameraSession(i);
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);
let focusPoint = 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 stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0106', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0106--------------");
if (mCameraNum == 0) {
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 < mCameraNum; i++) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0106 start for camera[" + i + "]");
await startCameraSession(i);
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);
let focusPoint = 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 stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0107', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0107--------------");
if (mCameraNum == 0) {
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 < mCameraNum; i++) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0107 start for camera[" + i + "]");
await startCameraSession(i);
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);
let focusPoint = 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 stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0108', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0108--------------");
if (mCameraNum == 0) {
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 < mCameraNum; i++) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_FOCUS_POINT_PROMISE_0108 start for camera[" + i + "]");
await startCameraSession(i);
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);
let focusPoint = 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 stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_GET_FOCAL_LENGTH_PROMISE_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_GET_FOCAL_LENGTH_PROMISE_0100--------------");
if (mCameraNum == 0) {
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 < mCameraNum; i++) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_GET_FOCAL_LENGTH_PROMISE_0100 start for camera[" + i + "]");
await startCameraSession(i);
let focalLength = 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 stopCameraSession();
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();
}
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_ON_FOCUSSTATECHANGE_0100
* @tc.name : camera session focusstatechange api
* @tc.desc : camera session focusstatechange api
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_MULTIMEDIA_CAMERA_ON_FOCUSSTATECHANGE_0100', 1, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_ON_FOCUSSTATECHANGE_0100--------------");
if (isEmpty(mCameraSession)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ON_FOCUSSTATECHANGE_0100 mCameraSession == null || undefined")
expect().assertFail();
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ON_FOCUSSTATECHANGE_0100 to operate");
mCameraSession.on('focusStateChange', async (err, data) => {
if (!err) {
expect(true).assertTrue();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_ON_FOCUSSTATECHANGE_0100 success");
} else {
expect().assertFail();
console.info(TAG + "Error in SUB_MULTIMEDIA_CAMERA_ON_FOCUSSTATECHANGE_0100 FAILED: " + err.message);
}
await sleep(1000);
done();
})
}
await sleep(1000);
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_CAMERA_CAMERA_SESSION_ON_ERROR_0100
* @tc.name : camera session callback on error
* @tc.desc : camera session callback on error
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_MULTIMEDIA_CAMERA_CAMERA_SESSION_ON_ERROR_0100', 1, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_CAMERA_SESSION_ON_ERROR_0100--------------");
if (isEmpty(mCameraSession)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_SESSION_ON_ERROR_0100 previewOutput == null || undefined")
expect().assertFail();
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_SESSION_ON_ERROR_0100 to operate");
mCameraSession.on('error', async (err, data) => {
if (!err) {
expect(true).assertTrue();
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CAMERA_SESSION_ON_ERROR_0100 success");
} else {
expect().assertFail();
console.info(TAG + "Error in SUB_MULTIMEDIA_CAMERA_CAMERA_SESSION_ON_ERROR_0100 FAILED: " + err.message);
}
await sleep(1000);
done();
})
}
await sleep(1000);
done();
})
})
}
\ No newline at end of file
/*
* 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 deviceInfo from '@ohos.deviceInfo';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium';
const TAG = "CameraModuleTest: ";
// Define global letiables
let mCameraManager;
let mCameraDevicesArray;
let mCameraSession;
let mPhotoSurface;
let mVideoRecorder;
let mVideoSurface;
let mFileAsset;
let mFdPath;
let mFdNumber;
// CAMERA-0 letiables
let mCameraNum;
let mCameraInput;
let mPreviewOutput;
let mPhotoOutput;
let mVideoOutput;
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() {
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 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')
mPhotoSurface = await receiver.getReceivingSurfaceId()
console.log(TAG + 'Photo received id: ' + JSON.stringify(mPhotoSurface))
} 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) => {
if (!err) {
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) => {
if (!err) {
console.info(TAG + 'videoRecorder.prepare success.')
mVideoRecorder.getInputSurface((err, id) => {
console.info(TAG + 'getInputSurface called')
if (!err) {
mVideoSurface = id
console.info(TAG + 'getInputSurface surfaceId: ' + JSON.stringify(mVideoSurface))
} else {
console.info(TAG + 'getInputSurface FAILED')
}
})
} else {
console.info(TAG + 'prepare FAILED')
}
})
} else {
console.info(TAG + 'createVideoRecorder FAILED')
}
})
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')
}
function getCameraManagerInstance() {
console.info('Enter getCameraManagerInstance');
mCameraManager = cameraObj.getCameraManager(null);
if (isEmpty(mCameraManager)) {
console.info(TAG + "getCameraManager FAILED");
return false;
}
console.info('Exit getCameraManagerInstance');
return true;
}
function getCameraSupportDevicesArray() {
console.info('Enter getCameraSupportDevicesArray');
mCameraDevicesArray = mCameraManager.getSupportedCameras();
/*
mCameraManager.getSupportedCameras(async (err, data) => {
console.info(TAG + "Entering getCameraSupportDevicesArray callback");
if (!err) {
if (data != null || data != undefined) {
mCameraDevicesArray = data;
console.info(TAG + "Entering getCameraSupportDevicesArray PASSED with CameraDevicesArray is: " + data);
} else {
console.info(TAG + "Entering getCameraSupportDevicesArray FAILED with CameraDevicesArray is: " + data);
}
} else {
console.info(TAG + "Entering getCameraSupportDevicesArray FAILED : " + err.message);
}
})
await sleep(3000);
*/
if (isEmpty(mCameraDevicesArray)) {
console.info(TAG + "getSupportedCameras FAILED");
return false;
}
//mCameraNum = 1;
mCameraNum = mCameraDevicesArray.length;
console.info(TAG + "getCameraSupportDevicesArray is: " + mCameraNum);
mIsVideoStabilizationModeSupportedArray = new Array(mCameraNum);
console.info('Exit getCameraSupportDevicesArray');
return true;
}
function createCameraSessionInstance() {
console.info('Enter createCameraSessionInstance');
try {
mCameraSession = mCameraManager.createCaptureSession();
}
catch {
console.info('createCaptureSession FAILED');
}
if (isEmpty(mCameraSession)) {
console.info(TAG + "createCaptureSession FAILED");
return false;
}
mCameraSession.beginConfig();
console.info('Exit createCameraSessionInstance');
return true;
}
async function releaseCameraSessionInstance() {
await mCameraSession.release();
}
async function createInput(idx:any) {
console.info('Enter createInput');
if (isEmpty(mCameraDevicesArray)) {
console.info(TAG + "Entering createInputs FAILED with NoCamera");
return false;
}
mCameraInput = mCameraManager.createCameraInput(mCameraDevicesArray[idx]);
if (isEmpty(mCameraInput)) {
console.info(TAG + "createCameraInput FAILED");
return false;
}
await mCameraInput.open();
await sleep(100);
console.info(idx + 'th CameraInput is: ' + mCameraInput);
console.info('Exit createInput');
return true;
}
async function releaseInput() {
console.info('Enter releaseInput');
if (!isEmpty(mCameraInput)) {
await mCameraInput.close();
}
console.info('Exit releaseInput');
return true;
}
function createOutput(idx:any) {
console.info('Enter createOutput');
let cameraOutputCap = mCameraManager.getSupportedOutputCapability(mCameraDevicesArray[idx]);
if (!isEmpty(cameraOutputCap)) {
if (!isEmpty(cameraOutputCap.previewProfiles)) {
console.info(TAG + "cameraOutputCap.previewProfiles.length: " + cameraOutputCap.previewProfiles.length);
for (let i = 0; i < cameraOutputCap.previewProfiles.length; i++) {
mPreviewOutput = mCameraManager.createPreviewOutput(cameraOutputCap.previewProfiles[i], globalThis.surfaceId);
if (!isEmpty(mPreviewOutput)) {
break;
}
}
if (isEmpty(mPreviewOutput)) {
console.info(TAG + "createPreviewOutput FAILED");
}
console.info(TAG + "createPreviewOutput: " + mPreviewOutput);
}
if (!isEmpty(cameraOutputCap.photoProfiles)) {
console.info(TAG + "cameraOutputCap.photoProfiles.length: " + cameraOutputCap.photoProfiles.length);
for (let i = 0; i < cameraOutputCap.photoProfiles.length; i++) {
mPhotoOutput = mCameraManager.createPhotoOutput(cameraOutputCap.photoProfiles[i], mPhotoSurface);
if (!isEmpty(mPhotoOutput)) {
break;
}
}
if (isEmpty(mPhotoOutput)) {
console.info(TAG + "createPhotoOutput FAILED");
}
console.info(TAG + "createPhotoOutput: " + mPhotoOutput);
}
/*
if (!isEmpty(cameraOutputCap.videoProfiles)) {
console.info(TAG + "cameraOutputCap.videoProfiles.length: " + cameraOutputCap.videoProfiles.length);
for (let i = 0; i < cameraOutputCap.videoProfiles.length; i++) {
try {
mVideoOutput = await mCameraManager.createVideoOutput(cameraOutputCap.videoProfiles[i], mVideoSurface);
if (!isEmpty(mVideoOutput)) {
break;
}
}
catch {
console.info(TAG + "createVideoOutput FAILED");
}
}
if (isEmpty(mVideoOutput)) {
console.info(TAG + "createVideoOutput FAILED");
}
console.info(TAG + "createVideoOutput: " + mVideoOutput);
}
*/
}
console.info('Exit createOutputs');
return true;
}
async function releaseOutput() {
console.info('Enter releaseOutput');
if (!isEmpty(mPreviewOutput)) {
await mPreviewOutput.release();
}
if (!isEmpty(mPhotoOutput)) {
await mPhotoOutput.release();
}
/*
if (!isEmpty(mVideoOutput)) {
await mVideoOutput.stop();
await mVideoOutput.release();
}
*/
console.info('Exit releaseOutput');
return true;
}
async function startCameraSession(idx:any) {
console.info(TAG + "Enter startCameraSession");
await createInput(idx);
createOutput(idx);
await sleep(1);
if (!isEmpty(mCameraInput)) {
console.info(TAG + "Start to addInput");
mCameraSession.addInput(mCameraInput);
}
if (!isEmpty(mPreviewOutput)) {
console.info(TAG + "Start to addOutput mPreviewOutput");
mCameraSession.addOutput(mPreviewOutput);
}
if (!isEmpty(mPhotoOutput)) {
console.info(TAG + "Start to addOutput mPhotoOutput");
mCameraSession.addOutput(mPhotoOutput);
}
/*
if (!isEmpty(mVideoOutput)) {
console.info(TAG + "Start to addOutput mVideoOutput");
await mCameraSession.addOutput(mVideoOutput);
}
*/
await sleep(1);
await mCameraSession.commitConfig();
/*
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(100);
*/
console.info(TAG + "Exit startCameraSession");
return true;
}
async function stopCameraSession() {
console.info(TAG + "Enter stopCameraSession");
mCameraSession.beginConfig();
/*
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(100);
*/
if (!isEmpty(mCameraInput)) {
console.info(TAG + "Start to removeInput input");
await mCameraSession.removeInput(mCameraInput);
}
if (!isEmpty(mPreviewOutput)) {
console.info(TAG + "Start to removeOutput mPreviewOutput");
await mCameraSession.removeOutput(mPreviewOutput);
}
if (!isEmpty(mPhotoOutput)) {
console.info(TAG + "Start to removeOutput mPhotoOutput");
await mCameraSession.removeOutput(mPhotoOutput);
}
/*
if (!isEmpty(mVideoOutput)) {
console.info(TAG + "Start to removeOutput mVideoOutput");
await mCameraSession.removeOutput(mVideoOutput);
}
*/
await releaseInput();
await releaseOutput();
console.info(TAG + "Exit stopCameraSession");
return true;
}
describe('cameraSessionVideoStabilizationTest', function () {
console.info(TAG + '----------cameraSessionVideoStabilizationTest--------------')
beforeAll(async function () {
sleep(100);
await getPhotoReceiverSurface();
await getVideoReceiveSurface();
getCameraManagerInstance();
getCameraSupportDevicesArray();
createCameraSessionInstance();
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 () {
releaseVideoReceiveSurface();
releaseCameraSessionInstance();
sleep(1000);
console.info('afterAll case');
})
/**
* @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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0100--------------");
if (mCameraNum == 0) {
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 < mCameraNum; 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 = 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) {
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 stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0100--------------");
if (mCameraNum == 0) {
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 < mCameraNum; 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) {
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);
let vdeoStabilizationMode = 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();
}
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0100 PASSED");
}
await stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0101', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0101--------------");
if (mCameraNum == 0) {
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 < mCameraNum; 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 = 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) {
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 stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0101', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0101--------------");
if (mCameraNum == 0) {
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 < mCameraNum; 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) {
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);
let vdeoStabilizationMode = 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();
}
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0101 PASSED");
}
await stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0102', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0102--------------");
if (mCameraNum == 0) {
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 < mCameraNum; 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 = 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) {
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 stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0102', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0102--------------");
if (mCameraNum == 0) {
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 < mCameraNum; 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) {
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);
let vdeoStabilizationMode = 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();
}
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0102 PASSED");
}
await stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0103', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0103--------------");
if (mCameraNum == 0) {
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 < mCameraNum; 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 = 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) {
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 stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0103', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0103--------------");
if (mCameraNum == 0) {
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 < mCameraNum; 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) {
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);
let vdeoStabilizationMode = 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();
}
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0103 PASSED");
}
await stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0104', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_IS_VIDEO_STABILIZATION_MODE_SUPPORT_PROMISE_0104--------------");
if (mCameraNum == 0) {
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 < mCameraNum; 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 = 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) {
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 stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0104', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0104--------------");
if (mCameraNum == 0) {
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 < mCameraNum; 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) {
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);
let vdeoStabilizationMode = 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();
}
} else {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_VIDEO_STABILIZATION_MODE_PROMISE_0104 PASSED");
}
await stopCameraSession();
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
/*
* 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 deviceInfo from '@ohos.deviceInfo';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium';
const TAG = "CameraModuleTest: ";
// Define global letiables
let mCameraManager;
let mCameraDevicesArray;
let mCameraSession;
let mPhotoSurface;
let mVideoRecorder;
let mVideoSurface;
let mFileAsset;
let mFdPath;
let mFdNumber;
// CAMERA-0 letiables
let mCameraNum;
let mCameraInput;
let mPreviewOutput;
let mPhotoOutput;
let mVideoOutput;
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() {
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 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')
mPhotoSurface = await receiver.getReceivingSurfaceId()
console.log(TAG + 'Photo received id: ' + JSON.stringify(mPhotoSurface))
} 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) => {
if (!err) {
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) => {
if (!err) {
console.info(TAG + 'videoRecorder.prepare success.')
mVideoRecorder.getInputSurface((err, id) => {
console.info(TAG + 'getInputSurface called')
if (!err) {
mVideoSurface = id
console.info(TAG + 'getInputSurface surfaceId: ' + JSON.stringify(mVideoSurface))
} else {
console.info(TAG + 'getInputSurface FAILED')
}
})
} else {
console.info(TAG + 'prepare FAILED')
}
})
} else {
console.info(TAG + 'createVideoRecorder FAILED')
}
})
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')
}
function getCameraManagerInstance() {
console.info('Enter getCameraManagerInstance');
mCameraManager = cameraObj.getCameraManager(null);
if (isEmpty(mCameraManager)) {
console.info(TAG + "getCameraManager FAILED");
return false;
}
console.info('Exit getCameraManagerInstance');
return true;
}
function getCameraSupportDevicesArray() {
console.info('Enter getCameraSupportDevicesArray');
mCameraDevicesArray = mCameraManager.getSupportedCameras();
/*
mCameraManager.getSupportedCameras(async (err, data) => {
console.info(TAG + "Entering getCameraSupportDevicesArray callback");
if (!err) {
if (data != null || data != undefined) {
mCameraDevicesArray = data;
console.info(TAG + "Entering getCameraSupportDevicesArray PASSED with CameraDevicesArray is: " + data);
} else {
console.info(TAG + "Entering getCameraSupportDevicesArray FAILED with CameraDevicesArray is: " + data);
}
} else {
console.info(TAG + "Entering getCameraSupportDevicesArray FAILED : " + err.message);
}
})
await sleep(3000);
*/
if (isEmpty(mCameraDevicesArray)) {
console.info(TAG + "getSupportedCameras FAILED");
return false;
}
//mCameraNum = 1;
mCameraNum = mCameraDevicesArray.length;
console.info(TAG + "getCameraSupportDevicesArray is: " + mCameraNum);
mZoomRatioRangeArray = new Array(mCameraNum);
mZoomRatioMaxArray = new Array(mCameraNum);
mZoomRatioMinArray = new Array(mCameraNum);
console.info('Exit getCameraSupportDevicesArray');
return true;
}
function createCameraSessionInstance() {
console.info('Enter createCameraSessionInstance');
try {
mCameraSession = mCameraManager.createCaptureSession();
}
catch {
console.info('createCaptureSession FAILED');
}
if (isEmpty(mCameraSession)) {
console.info(TAG + "createCaptureSession FAILED");
return false;
}
mCameraSession.beginConfig();
console.info('Exit createCameraSessionInstance');
return true;
}
async function releaseCameraSessionInstance() {
await mCameraSession.release();
}
async function createInput(idx:any) {
console.info('Enter createInput');
if (isEmpty(mCameraDevicesArray)) {
console.info(TAG + "Entering createInputs FAILED with NoCamera");
return false;
}
mCameraInput = mCameraManager.createCameraInput(mCameraDevicesArray[idx]);
if (isEmpty(mCameraInput)) {
console.info(TAG + "createCameraInput FAILED");
return false;
}
await mCameraInput.open();
await sleep(100);
console.info(idx + 'th CameraInput is: ' + mCameraInput);
console.info('Exit createInput');
return true;
}
async function releaseInput() {
console.info('Enter releaseInput');
if (!isEmpty(mCameraInput)) {
await mCameraInput.close();
}
console.info('Exit releaseInput');
return true;
}
async function createOutput(idx:any) {
console.info('Enter createOutput');
let cameraOutputCap = await mCameraManager.getSupportedOutputCapability(mCameraDevicesArray[idx]);
if (!isEmpty(cameraOutputCap)) {
if (!isEmpty(cameraOutputCap.previewProfiles)) {
console.info(TAG + "cameraOutputCap.previewProfiles.length: " + cameraOutputCap.previewProfiles.length);
for (let i = 0; i < cameraOutputCap.previewProfiles.length; i++) {
mPreviewOutput = await mCameraManager.createPreviewOutput(cameraOutputCap.previewProfiles[i], globalThis.surfaceId);
if (!isEmpty(mPreviewOutput)) {
break;
}
}
if (isEmpty(mPreviewOutput)) {
console.info(TAG + "createPreviewOutput FAILED");
}
console.info(TAG + "createPreviewOutput: " + mPreviewOutput);
}
if (!isEmpty(cameraOutputCap.photoProfiles)) {
console.info(TAG + "cameraOutputCap.photoProfiles.length: " + cameraOutputCap.photoProfiles.length);
for (let i = 0; i < cameraOutputCap.photoProfiles.length; i++) {
mPhotoOutput = await mCameraManager.createPhotoOutput(cameraOutputCap.photoProfiles[i], mPhotoSurface);
if (!isEmpty(mPhotoOutput)) {
break;
}
}
if (isEmpty(mPhotoOutput)) {
console.info(TAG + "createPhotoOutput FAILED");
}
console.info(TAG + "createPhotoOutput: " + mPhotoOutput);
}
/*
if (!isEmpty(cameraOutputCap.videoProfiles)) {
console.info(TAG + "cameraOutputCap.videoProfiles.length: " + cameraOutputCap.videoProfiles.length);
for (let i = 0; i < cameraOutputCap.videoProfiles.length; i++) {
try {
mVideoOutput = await mCameraManager.createVideoOutput(cameraOutputCap.videoProfiles[i], mVideoSurface);
if (!isEmpty(mVideoOutput)) {
break;
}
}
catch {
console.info(TAG + "createVideoOutput FAILED");
}
}
if (isEmpty(mVideoOutput)) {
console.info(TAG + "createVideoOutput FAILED");
}
console.info(TAG + "createVideoOutput: " + mVideoOutput);
}
*/
}
console.info('Exit createOutputs');
return true;
}
async function releaseOutput() {
console.info('Enter releaseOutput');
if (!isEmpty(mPreviewOutput)) {
await mPreviewOutput.release();
}
if (!isEmpty(mPhotoOutput)) {
await mPhotoOutput.release();
}
/*
if (!isEmpty(mVideoOutput)) {
await mVideoOutput.stop();
await mVideoOutput.release();
}
*/
console.info('Exit releaseOutput');
return true;
}
async function startCameraSession(idx:any) {
console.info(TAG + "Enter startCameraSession");
await createInput(idx);
createOutput(idx);
console.info(TAG + "Start to addInput");
await sleep(1);
if (!isEmpty(mCameraInput)) {
console.info(TAG + "Start to addInput");
mCameraSession.addInput(mCameraInput);
}
if (!isEmpty(mPreviewOutput)) {
console.info(TAG + "Start to addOutput mPreviewOutput");
mCameraSession.addOutput(mPreviewOutput);
}
if (!isEmpty(mPhotoOutput)) {
console.info(TAG + "Start to addOutput mPhotoOutput");
mCameraSession.addOutput(mPhotoOutput);
}
/*
if (!isEmpty(mVideoOutput)) {
console.info(TAG + "Start to addOutput mVideoOutput");
await mCameraSession.addOutput(mVideoOutput);
}
*/
await sleep(1);
await mCameraSession.commitConfig();
console.info(TAG + "Entering startCameraSession start session begin");
/*
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(100);
*/
console.info(TAG + "Exit startCameraSession");
return true;
}
async function stopCameraSession() {
console.info(TAG + "Enter stopCameraSession");
mCameraSession.beginConfig();
/*
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(100);
*/
// await commitCameraSessionConfig();
if (!isEmpty(mCameraInput)) {
console.info(TAG + "Start to removeInput input");
mCameraSession.removeInput(mCameraInput);
}
if (!isEmpty(mPreviewOutput)) {
console.info(TAG + "Start to removeOutput mPreviewOutput");
mCameraSession.removeOutput(mPreviewOutput);
}
if (!isEmpty(mPhotoOutput)) {
console.info(TAG + "Start to removeOutput mPhotoOutput");
mCameraSession.removeOutput(mPhotoOutput);
}
/*
if (!isEmpty(mVideoOutput)) {
console.info(TAG + "Start to removeOutput mVideoOutput");
await mCameraSession.removeOutput(mVideoOutput);
}
*/
await releaseInput();
await releaseOutput();
console.info(TAG + "Exit stopCameraSession");
return true;
}
describe('cameraSessionZoomRatioTest', function () {
console.info(TAG + '----------cameraSessionZoomRatioTest--------------')
beforeAll(async function () {
sleep(100);
await getPhotoReceiverSurface();
await getVideoReceiveSurface();
getCameraManagerInstance();
getCameraSupportDevicesArray();
createCameraSessionInstance();
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 () {
releaseVideoReceiveSurface();
releaseCameraSessionInstance();
sleep(1000);
console.info('afterAll case');
})
/**
* @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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_GET_ZOOM_RATIO_RANGE_PROMISE_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_GET_ZOOM_RATIO_RANGE_PROMISE_0100--------------");
if (mCameraNum == 0) {
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 < mCameraNum; i++) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_GET_ZOOM_RATIO_RANGE_PROMISE_0100 start for camera[" + i + "]");
await startCameraSession(i);
try {
let zoomRatioRange = 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]);
}
}
catch {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_GET_ZOOM_RATIO_RANGE_CALLBACK_0100 PASSED");
}
await stopCameraSession();
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0100', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0100--------------");
if (mCameraNum == 0) {
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 < mCameraNum; i++) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0100 start for camera[" + i + "]");
if (!isEmpty(mZoomRatioRangeArray[i])) {
await startCameraSession(i);
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]);
let zoomRatio = 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 stopCameraSession();
}
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0101', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0101--------------");
if (mCameraNum == 0) {
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 < mCameraNum; i++) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0101 start for camera[" + i + "]");
if (!isEmpty(mZoomRatioRangeArray[i])) {
await startCameraSession(i);
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));
let zoomRatio = 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 stopCameraSession();
}
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0102', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0102--------------");
if (mCameraNum == 0) {
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 < mCameraNum; i++) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0102 start for camera[" + i + "]");
if (!isEmpty(mZoomRatioRangeArray[i])) {
await startCameraSession(i);
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));
let zoomRatio = 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 stopCameraSession();
}
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0103', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0103--------------");
if (mCameraNum == 0) {
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 < mCameraNum; i++) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0103 start for camera[" + i + "]");
if (!isEmpty(mZoomRatioRangeArray[i])) {
await startCameraSession(i);
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));
let zoomRatio = 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 stopCameraSession();
}
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_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 2
*/
it('SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0104', 2, async function (done) {
console.info("--------------SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0104--------------");
if (mCameraNum == 0) {
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 < mCameraNum; i++) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_SESSION_SET_GET_ZOOM_RATIO_PROMISE_0104 start for camera[" + i + "]");
if (!isEmpty(mZoomRatioRangeArray[i])) {
await startCameraSession(i);
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));
let zoomRatio = 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 stopCameraSession();
}
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
{
"string": [
{
"name": "entry_MainAbility",
"value": "entry_MainAbility"
},
{
"name": "description_mainability",
"value": "eTS_Empty Ability"
},
{
"name": "TestAbility_desc",
"value": "description"
},
{
"name": "TestAbility_label",
"value": "label"
}
]
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册