未验证 提交 dda9e14d 编写于 作者: O openharmony_ci 提交者: Gitee

!8890 add camera xts beta1

Merge pull request !8890 from 秦莉文/OpenHarmony-4.0-Beta1
......@@ -28,6 +28,7 @@ group("multimedia") {
"audio/audio_js_standard/audioRenderer:audio_renderer_js_hap",
"audio/audio_js_standard/audioVoip:audio_voip_js_hap",
"avsession/avsession_js_standard/avsessionManager:avsession_framework_js_hap",
"camera/camera_js_standard:camera_framework_ets_hap",
"image/image_js_standard/image:image_js_hap",
"image/image_js_standard/imageColorspace:image_colorspace_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(TAG + "--------------SUB_MULTIMEDIA_CAMERA_ENUM_CAMERAERRORCODE_0100--------------");
expect(camera.CameraErrorCode.INVALID_ARGUMENT == 7400101).assertTrue();
console.info(TAG + "--------------INVALID_ARGUMENT--------------");
expect(camera.CameraErrorCode.OPERATION_NOT_ALLOWED == 7400102).assertTrue();
console.info(TAG + "--------------OPERATION_NOT_ALLOWED--------------");
expect(camera.CameraErrorCode.SESSION_NOT_CONFIG == 7400103).assertTrue();
console.info(TAG + "--------------SESSION_NOT_CONFIG--------------");
expect(camera.CameraErrorCode.SESSION_NOT_RUNNING == 7400104).assertTrue();
console.info(TAG + "--------------SESSION_NOT_RUNNING--------------");
expect(camera.CameraErrorCode.SESSION_CONFIG_LOCKED == 7400105).assertTrue();
console.info(TAG + "--------------SESSION_CONFIG_LOCKED--------------");
expect(camera.CameraErrorCode.DEVICE_SETTING_LOCKED == 7400106).assertTrue();
console.info(TAG + "--------------DEVICE_SETTING_LOCKED--------------");
// expect(camera.CameraErrorCode.CONFLICT_CAMERA == 7400107).assertTrue();
// console.info(TAG + "--------------CONFLICT_CAMERA--------------");
expect(camera.CameraErrorCode.DEVICE_DISABLED == 7400108).assertTrue();
console.info(TAG + "--------------DEVICE_DISABLED--------------");
expect(camera.CameraErrorCode.DEVICE_PREEMPTED == 7400109).assertTrue();
console.info(TAG + "--------------DEVICE_PREEMPTED --------------");
expect(camera.CameraErrorCode.SERVICE_FATAL_ERROR == 7400201).assertTrue();
console.info(TAG + "--------------SERVICE_FATAL_ERROR--------------");
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 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
{
"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.
先完成此消息的编辑!
想要评论请 注册