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

!6879 【媒体子系统】camera更新框架

Merge pull request !6879 from liuxueqi/master
......@@ -13,7 +13,7 @@
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("camera_framework_ets_hap") {
hap_profile = "./src/main/config.json"
hap_profile = "./entry/src/config.json"
deps = [
":camera_ets_assets",
":camera_ets_resources",
......@@ -26,9 +26,9 @@ ohos_js_hap_suite("camera_framework_ets_hap") {
part_name = "multimedia_camera_framework"
}
ohos_js_assets("camera_ets_assets") {
source_dir = "./src/main/ets/MainAbility"
source_dir = "./entry/src/main/ets/MainAbility"
}
ohos_resources("camera_ets_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
sources = [ "./entry/src/resources" ]
hap_profile = "./entry/src/config.json"
}
{
"description": "Configuration for camerastandard Tests",
"driver": {
"type": "JSUnitTest",
"type": "OHJSUnitTest",
"test-timeout": "3000000",
"package": "com.open.harmony.multimedia.cameratest",
"bundle-name":"com.open.harmony.multimedia.cameratest",
"package-name": "com.open.harmony.multimedia.cameratest",
"shell-timeout": "60000"
},
"kits": [
......
......@@ -17,6 +17,7 @@
"package": "com.open.harmony.multimedia.cameratest",
"name": ".MyApplication",
"mainAbility": "com.open.harmony.multimedia.cameratest.MainAbility",
"srcPath": "",
"deviceType": [
"tablet",
"default",
......@@ -51,6 +52,19 @@
"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": [
......@@ -109,6 +123,20 @@
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
......
......@@ -13,9 +13,9 @@
* limitations under the License.
*/
import {Core, ExpectExtend} from "deccjsunit/index"
import cameraKit from "../test/Camera.test"
import featureAbility from "@ohos.ability.featureAbility"
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()
......@@ -43,30 +43,14 @@ struct CameraIndex {
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)
featureAbility.getWant()
.then((Want) => {
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
'id': 'extend'
})
console.info(TAG + 'Entering expectExtend')
core.addService('expect', expectExtend)
console.info(TAG + 'Entering addService')
core.init()
console.info(TAG + 'Entering core.init()')
console.info(TAG + 'Entering subscribeEvent')
const configService = core.getDefaultService('config')
Want.parameters['timeout'] = 600000
configService.setConfig(Want.parameters)
console.info(TAG + 'Entering configService')
cameraKit(surfaceId)
core.execute()
console.info(TAG + 'Operation successful. Data: ' + JSON.stringify(Want));
})
.catch((error) => {
console.error(TAG + 'Operation failed. Cause: ' + JSON.stringify(error));
})
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
......@@ -27,18 +27,16 @@ import cameraEnumTest from './CameraEnumTest.test.ets'
let TAG = 'CameraModuleTest: '
export default function cameraKit(surfaceId: any) {
export default function cameraKit() {
console.info(TAG + 'Entering cameraKit')
console.info(TAG + 'surfaceId: ' + surfaceId)
cameraInputTest(surfaceId)
cameraJSUnitOutput(surfaceId)
cameraSessionFlashTest(surfaceId)
cameraSessionExposureTest(surfaceId)
cameraSessionFocusTest(surfaceId)
cameraSessionZoomRatioTest(surfaceId)
cameraSessionVideoStabilizationTest(surfaceId)
cameraSessionBaseTest(surfaceId)
cameraManagerTest(surfaceId)
cameraEnumTest(surfaceId)
cameraInputTest()
cameraJSUnitOutput()
cameraSessionFlashTest()
cameraSessionExposureTest()
cameraSessionFocusTest()
cameraSessionZoomRatioTest()
cameraSessionVideoStabilizationTest()
cameraSessionBaseTest()
cameraManagerTest()
cameraEnumTest()
}
\ No newline at end of file
......@@ -14,11 +14,11 @@
*/
import camera from '@ohos.multimedia.camera';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
const TAG = "CameraEnumTest: ";
export default function cameraEnumTest(surfaceId: any) {
export default function cameraEnumTest() {
function isEmpty(data) {
if (data == null || data == undefined) {
......
......@@ -14,10 +14,9 @@
*/
import cameraObj from '@ohos.multimedia.camera';
import image from '@ohos.multimedia.image';
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
import bundle from '@ohos.bundle'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index';
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: ";
......@@ -31,7 +30,7 @@ let mCameraNum;
let mCameraInput;
let mPreviewOutput;
export default function CameraInputTest(surfaceId) {
export default function CameraInputTest() {
function sleep(ms) {
console.info(TAG + "Entering sleep -> Promise constructor");
return new Promise(resolve => setTimeout(resolve, ms));
......@@ -44,65 +43,32 @@ export default function CameraInputTest(surfaceId) {
return false;
}
async function applyPermission() {
let appInfo = await bundle.getApplicationInfo('com.open.harmony.multimedia.cameratest', 0, 100);
let atManager = abilityAccessCtrl.createAtManager();
if (atManager != null) {
let tokenID = appInfo.accessTokenId;
console.info('[permission] case accessTokenID is ' + tokenID);
let permissionName1 = 'ohos.permission.CAMERA';
let permissionName2 = 'ohos.permission.MICROPHONE';
let permissionName3 = 'ohos.permission.MEDIA_LOCATION';
let permissionName4 = 'ohos.permission.READ_MEDIA';
let permissionName5 = 'ohos.permission.WRITE_MEDIA';
let permissionName6 = 'ohos.permission.START_ABILIIES_FROM_BACKGROUND';
let permissionName7 = 'ohos.permission.START_INVISIBLE_ABILITY';
let permissionName8 = 'ohos.permission.ABILITY_BACKGROUND_COMMUNICATION';
await atManager.grantUserGrantedPermission(tokenID, permissionName1, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName2, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName3, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName4, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName5, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName6, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName7, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName8, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
} else {
console.info('[permission] case apply permission failed, createAtManager failed');
async function 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('允许'));
}
}
async function getCameraManagerInstance() {
console.info('Enter getCameraManagerInstance');
......@@ -282,7 +248,7 @@ export default function CameraInputTest(surfaceId) {
if (!isEmpty(cameraOutputCap.previewProfiles)) {
console.info(TAG + "cameraOutputCap.previewProfiles.length: " + cameraOutputCap.previewProfiles.length);
for (let i = 0; i < cameraOutputCap.previewProfiles.length; i++) {
mPreviewOutput = await mCameraManager.createPreviewOutput(cameraOutputCap.previewProfiles[i], surfaceId);
mPreviewOutput = await mCameraManager.createPreviewOutput(cameraOutputCap.previewProfiles[i], globalThis.surfaceId);
if (!isEmpty(mPreviewOutput)) {
break;
}
......@@ -365,7 +331,9 @@ export default function CameraInputTest(surfaceId) {
describe('CameraInputTest', function () {
console.info(TAG + '----------CameraInputTest--------------');
beforeAll(async function () {
await applyPermission();
await getPermission();
sleep(1000);
await driveFn();
await getCameraManagerInstance();
await getCameraSupportDevicesArray();
await createCameraSessionInstance();
......
......@@ -14,11 +14,9 @@
*/
import cameraObj from '@ohos.multimedia.camera';
import image from '@ohos.multimedia.image';
import media from '@ohos.multimedia.media'
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
import bundle from '@ohos.bundle'
import mediaLibrary from '@ohos.multimedia.mediaLibrary'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index';
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: ";
......@@ -80,7 +78,7 @@ let fdNumber;
let mMetadataObjectTypeArray;
let mMetadataObjectArray;
export default function cameraJSUnitOutput(surfaceId: any) {
export default function cameraJSUnitOutput() {
async function getImageReceiverSurfaceId() {
console.log(TAG + 'Entering create Image receiver')
......@@ -179,65 +177,6 @@ export default function cameraJSUnitOutput(surfaceId: any) {
return false;
}
async function applyPermission() {
let appInfo = await bundle.getApplicationInfo('com.open.harmony.multimedia.cameratest', 0, 100);
let atManager = abilityAccessCtrl.createAtManager();
if (atManager != null) {
let tokenID = appInfo.accessTokenId;
console.info('[permission] case accessTokenID is ' + tokenID);
let permissionName1 = 'ohos.permission.CAMERA';
let permissionName2 = 'ohos.permission.MICROPHONE';
let permissionName3 = 'ohos.permission.MEDIA_LOCATION';
let permissionName4 = 'ohos.permission.READ_MEDIA';
let permissionName5 = 'ohos.permission.WRITE_MEDIA';
let permissionName6 = 'ohos.permission.START_ABILIIES_FROM_BACKGROUND';
let permissionName7 = 'ohos.permission.START_INVISIBLE_ABILITY';
let permissionName8 = 'ohos.permission.ABILITY_BACKGROUND_COMMUNICATION';
await atManager.grantUserGrantedPermission(tokenID, permissionName1, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName2, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName3, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName4, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName5, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName6, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName7, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName8, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
} else {
console.info('[permission] case apply permission failed, createAtManager failed');
}
}
function getSupportedOutputCapabilityInPromise(cameraDevice) {
if (isEmpty(cameraManager)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_GET_CAMERAS_PROMISE_0100 cameraManager == null || undefined")
......@@ -255,7 +194,6 @@ export default function cameraJSUnitOutput(surfaceId: any) {
console.info(TAG + '----------cameraJSUnitOutput begin--------------')
beforeAll(async function () {
await applyPermission();
await getImageReceiverSurfaceId();
await getvideosurface();
console.info('beforeAll case');
......@@ -420,7 +358,7 @@ export default function cameraJSUnitOutput(surfaceId: any) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_PREVIEW_OUTPUT_CALLBACK_0100 previewProfilesArray == null || undefined")
expect(isEmpty(previewProfilesArray)).assertFalse();
}
cameraManager.createPreviewOutput(previewProfilesArray[0], surfaceId, async (err, data) => {
cameraManager.createPreviewOutput(previewProfilesArray[0], globalThis.surfaceId, async (err, data) => {
if (!err) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_PREVIEW_OUTPUT_CALLBACK_0100 is not error");
expect(isEmpty(data)).assertFalse();
......
......@@ -15,12 +15,9 @@
import cameraObj from '@ohos.multimedia.camera';
import image from '@ohos.multimedia.image';
import fileio from '@ohos.fileio';
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
import bundle from '@ohos.bundle'
import mediaLibrary from '@ohos.multimedia.mediaLibrary'
import media from '@ohos.multimedia.media'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index';
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: ";
......@@ -63,7 +60,7 @@ let mVideoConfig = {
maxDuration: 500
}
export default function cameraManagerTest(surfaceId: any) {
export default function cameraManagerTest() {
async function getImageReceiverSurfaceId() {
console.log(TAG + 'Entering create Image receiver')
......@@ -262,70 +259,10 @@ export default function cameraManagerTest(surfaceId: any) {
return outputCapabilityPromise;
}
async function applyPermission() {
let appInfo = await bundle.getApplicationInfo('com.open.harmony.multimedia.cameratest', 0, 100);
let atManager = abilityAccessCtrl.createAtManager();
if (atManager != null) {
let tokenID = appInfo.accessTokenId;
console.info('[permission] case accessTokenID is ' + tokenID);
let permissionName1 = 'ohos.permission.CAMERA';
let permissionName2 = 'ohos.permission.MICROPHONE';
let permissionName3 = 'ohos.permission.MEDIA_LOCATION';
let permissionName4 = 'ohos.permission.READ_MEDIA';
let permissionName5 = 'ohos.permission.WRITE_MEDIA';
let permissionName6 = 'ohos.permission.START_ABILIIES_FROM_BACKGROUND';
let permissionName7 = 'ohos.permission.START_INVISIBLE_ABILITY';
let permissionName8 = 'ohos.permission.ABILITY_BACKGROUND_COMMUNICATION';
await atManager.grantUserGrantedPermission(tokenID, permissionName1, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName2, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName3, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName4, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName5, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName6, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName7, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName8, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
} else {
console.info('[permission] case apply permission failed, createAtManager failed');
}
}
describe('CameraManagerTest', function () {
console.info(TAG + '----------CameraManagerTest--------------')
beforeAll(async function () {
await applyPermission();
await getCameraManagerInstance();
await getImageReceiverSurfaceId();
await getVideoReceiveSurface();
......@@ -855,7 +792,7 @@ describe('CameraManagerTest', function () {
expect().assertFail();
} else {
for (let j = 0; j < previewProfilesArray.length; j++) {
mCameraManager.createPreviewOutput(previewProfilesArray[j], surfaceId, async (err, data) => {
mCameraManager.createPreviewOutput(previewProfilesArray[j], globalThis.surfaceId, async (err, data) => {
if (isEmpty(data)) {
console.info(TAG + "Entering SUB_MULTIMEDIA_CAMERA_CREATE_CAMERA_PREVIEW_OUTPUT_CALLBACK_0100 data == null || undefined")
expect().assertFail();
......@@ -893,7 +830,7 @@ describe('CameraManagerTest', function () {
expect().assertFail();
} else {
for (let j = 0; j < previewProfilesArray.length; j++) {
let previewOutputPromise = await mCameraManager.createPreviewOutput(previewProfilesArray[j], surfaceId);
let previewOutputPromise = await 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();
......
......@@ -17,13 +17,10 @@
import cameraObj from '@ohos.multimedia.camera';
import image from '@ohos.multimedia.image';
import media from '@ohos.multimedia.media'
import mediaLibrary from '@ohos.multimedia.mediaLibrary'
import fileio from '@ohos.fileio';
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
import bundle from '@ohos.bundle'
import 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 'deccjsunit/index';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium';
const TAG = "CameraModuleTest: ";
......@@ -72,7 +69,7 @@ let mVideoConfig = {
maxDuration: 500
}
export default function cameraSessionTest(surfaceId: any) {
export default function cameraSessionTest() {
function sleep(ms) {
console.info(TAG + "Entering sleep -> Promise constructor");
......@@ -118,65 +115,6 @@ export default function cameraSessionTest(surfaceId: any) {
}
}
async function applyPermission() {
let appInfo = await bundle.getApplicationInfo('com.open.harmony.multimedia.cameratest', 0, 100);
let atManager = abilityAccessCtrl.createAtManager();
if (atManager != null) {
let tokenID = appInfo.accessTokenId;
console.info('[permission] case accessTokenID is ' + tokenID);
let permissionName1 = 'ohos.permission.CAMERA';
let permissionName2 = 'ohos.permission.MICROPHONE';
let permissionName3 = 'ohos.permission.MEDIA_LOCATION';
let permissionName4 = 'ohos.permission.READ_MEDIA';
let permissionName5 = 'ohos.permission.WRITE_MEDIA';
let permissionName6 = 'ohos.permission.START_ABILIIES_FROM_BACKGROUND';
let permissionName7 = 'ohos.permission.START_INVISIBLE_ABILITY';
let permissionName8 = 'ohos.permission.ABILITY_BACKGROUND_COMMUNICATION';
await atManager.grantUserGrantedPermission(tokenID, permissionName1, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName2, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName3, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName4, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName5, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName6, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName7, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName8, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
} else {
console.info('[permission] case apply permission failed, createAtManager failed');
}
}
async function getPhotoReceiverSurface() {
console.log(TAG + 'Entering getPhotoReceiverSurface')
let receiver = image.createImageReceiver(640, 480, 4, 8)
......@@ -413,7 +351,7 @@ export default function cameraSessionTest(surfaceId: any) {
if (!isEmpty(cameraOutputCap.previewProfiles)) {
console.info(TAG + "cameraOutputCap.previewProfiles.length: " + cameraOutputCap.previewProfiles.length);
for (let i = 0; i < cameraOutputCap.previewProfiles.length; i++) {
mPreviewOutput = await mCameraManager.createPreviewOutput(cameraOutputCap.previewProfiles[i], surfaceId);
mPreviewOutput = await mCameraManager.createPreviewOutput(cameraOutputCap.previewProfiles[i], globalThis.surfaceId);
if (!isEmpty(mPreviewOutput)) {
break;
}
......@@ -592,7 +530,6 @@ export default function cameraSessionTest(surfaceId: any) {
beforeAll(async function () {
sleep(100);
await applyPermission();
await getPhotoReceiverSurface();
await getVideoReceiveSurface();
await getCameraManagerInstance();
......
......@@ -17,13 +17,10 @@
import cameraObj from '@ohos.multimedia.camera';
import image from '@ohos.multimedia.image';
import media from '@ohos.multimedia.media'
import mediaLibrary from '@ohos.multimedia.mediaLibrary'
import fileio from '@ohos.fileio';
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
import bundle from '@ohos.bundle'
import 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 'deccjsunit/index';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium';
const TAG = "CameraModuleTest: ";
......@@ -127,7 +124,7 @@ let mMETERINGPointInvalidRB = {
let mEnableCheckInvalidMETERINGPoint = false;
export default function cameraSessionExposureTest(surfaceId: any) {
export default function cameraSessionExposureTest() {
function sleep(ms) {
console.info(TAG + "Entering sleep -> Promise constructor");
......@@ -173,65 +170,6 @@ export default function cameraSessionExposureTest(surfaceId: any) {
}
}
async function applyPermission() {
let appInfo = await bundle.getApplicationInfo('com.open.harmony.multimedia.cameratest', 0, 100);
let atManager = abilityAccessCtrl.createAtManager();
if (atManager != null) {
let tokenID = appInfo.accessTokenId;
console.info('[permission] case accessTokenID is ' + tokenID);
let permissionName1 = 'ohos.permission.CAMERA';
let permissionName2 = 'ohos.permission.MICROPHONE';
let permissionName3 = 'ohos.permission.MEDIA_LOCATION';
let permissionName4 = 'ohos.permission.READ_MEDIA';
let permissionName5 = 'ohos.permission.WRITE_MEDIA';
let permissionName6 = 'ohos.permission.START_ABILIIES_FROM_BACKGROUND';
let permissionName7 = 'ohos.permission.START_INVISIBLE_ABILITY';
let permissionName8 = 'ohos.permission.ABILITY_BACKGROUND_COMMUNICATION';
await atManager.grantUserGrantedPermission(tokenID, permissionName1, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName2, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName3, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName4, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName5, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName6, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName7, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName8, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
} else {
console.info('[permission] case apply permission failed, createAtManager failed');
}
}
async function getPhotoReceiverSurface() {
console.log(TAG + 'Entering getPhotoReceiverSurface')
let receiver = image.createImageReceiver(640, 480, 4, 8)
......@@ -473,7 +411,7 @@ export default function cameraSessionExposureTest(surfaceId: any) {
if (!isEmpty(cameraOutputCap.previewProfiles)) {
console.info(TAG + "cameraOutputCap.previewProfiles.length: " + cameraOutputCap.previewProfiles.length);
for (let i = 0; i < cameraOutputCap.previewProfiles.length; i++) {
mPreviewOutput = await mCameraManager.createPreviewOutput(cameraOutputCap.previewProfiles[i], surfaceId);
mPreviewOutput = await mCameraManager.createPreviewOutput(cameraOutputCap.previewProfiles[i], globalThis.surfaceId);
if (!isEmpty(mPreviewOutput)) {
break;
}
......@@ -651,7 +589,6 @@ export default function cameraSessionExposureTest(surfaceId: any) {
beforeAll(async function () {
sleep(100);
await applyPermission();
await getPhotoReceiverSurface();
await getVideoReceiveSurface();
await getCameraManagerInstance();
......
......@@ -17,13 +17,10 @@
import cameraObj from '@ohos.multimedia.camera';
import image from '@ohos.multimedia.image';
import media from '@ohos.multimedia.media'
import mediaLibrary from '@ohos.multimedia.mediaLibrary'
import fileio from '@ohos.fileio';
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
import bundle from '@ohos.bundle'
import 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 'deccjsunit/index';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium';
const TAG = "CameraModuleTest: ";
......@@ -78,7 +75,7 @@ let mVideoConfig = {
let mPicWidthMax = 8192;
let mPicHeightMax = 8192;
export default function cameraSessionFlashTest(surfaceId: any) {
export default function cameraSessionFlashTest() {
function sleep(ms) {
console.info(TAG + "Entering sleep -> Promise constructor");
......@@ -124,65 +121,6 @@ export default function cameraSessionFlashTest(surfaceId: any) {
}
}
async function applyPermission() {
let appInfo = await bundle.getApplicationInfo('com.open.harmony.multimedia.cameratest', 0, 100);
let atManager = abilityAccessCtrl.createAtManager();
if (atManager != null) {
let tokenID = appInfo.accessTokenId;
console.info('[permission] case accessTokenID is ' + tokenID);
let permissionName1 = 'ohos.permission.CAMERA';
let permissionName2 = 'ohos.permission.MICROPHONE';
let permissionName3 = 'ohos.permission.MEDIA_LOCATION';
let permissionName4 = 'ohos.permission.READ_MEDIA';
let permissionName5 = 'ohos.permission.WRITE_MEDIA';
let permissionName6 = 'ohos.permission.START_ABILIIES_FROM_BACKGROUND';
let permissionName7 = 'ohos.permission.START_INVISIBLE_ABILITY';
let permissionName8 = 'ohos.permission.ABILITY_BACKGROUND_COMMUNICATION';
await atManager.grantUserGrantedPermission(tokenID, permissionName1, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName2, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName3, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName4, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName5, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName6, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName7, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName8, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
} else {
console.info('[permission] case apply permission failed, createAtManager failed');
}
}
async function getPhotoReceiverSurface() {
console.log(TAG + 'Entering getPhotoReceiverSurface')
let receiver = image.createImageReceiver(640, 480, 4, 8)
......@@ -424,7 +362,7 @@ export default function cameraSessionFlashTest(surfaceId: any) {
if (!isEmpty(cameraOutputCap.previewProfiles)) {
console.info(TAG + "cameraOutputCap.previewProfiles.length: " + cameraOutputCap.previewProfiles.length);
for (let i = 0; i < cameraOutputCap.previewProfiles.length; i++) {
mPreviewOutput = await mCameraManager.createPreviewOutput(cameraOutputCap.previewProfiles[i], surfaceId);
mPreviewOutput = await mCameraManager.createPreviewOutput(cameraOutputCap.previewProfiles[i], globalThis.surfaceId);
if (!isEmpty(mPreviewOutput)) {
break;
}
......@@ -602,7 +540,6 @@ export default function cameraSessionFlashTest(surfaceId: any) {
beforeAll(async function () {
sleep(100);
await applyPermission();
await getPhotoReceiverSurface();
await getVideoReceiveSurface();
await mgetCameraManagerInstance();
......
......@@ -17,13 +17,10 @@
import cameraObj from '@ohos.multimedia.camera';
import image from '@ohos.multimedia.image';
import media from '@ohos.multimedia.media'
import mediaLibrary from '@ohos.multimedia.mediaLibrary'
import fileio from '@ohos.fileio';
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
import bundle from '@ohos.bundle'
import 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 'deccjsunit/index';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium';
const TAG = "CameraModuleTest: ";
......@@ -124,7 +121,7 @@ let mFocusPointInvalidRB = {
let mEnableCheckInvalidFocusPoint = false;
export default function cameraSessionFocusTest(surfaceId: any) {
export default function cameraSessionFocusTest() {
function sleep(ms) {
console.info(TAG + "Entering sleep -> Promise constructor");
......@@ -170,65 +167,6 @@ export default function cameraSessionFocusTest(surfaceId: any) {
}
}
async function applyPermission() {
let appInfo = await bundle.getApplicationInfo('com.open.harmony.multimedia.cameratest', 0, 100);
let atManager = abilityAccessCtrl.createAtManager();
if (atManager != null) {
let tokenID = appInfo.accessTokenId;
console.info('[permission] case accessTokenID is ' + tokenID);
let permissionName1 = 'ohos.permission.CAMERA';
let permissionName2 = 'ohos.permission.MICROPHONE';
let permissionName3 = 'ohos.permission.MEDIA_LOCATION';
let permissionName4 = 'ohos.permission.READ_MEDIA';
let permissionName5 = 'ohos.permission.WRITE_MEDIA';
let permissionName6 = 'ohos.permission.START_ABILIIES_FROM_BACKGROUND';
let permissionName7 = 'ohos.permission.START_INVISIBLE_ABILITY';
let permissionName8 = 'ohos.permission.ABILITY_BACKGROUND_COMMUNICATION';
await atManager.grantUserGrantedPermission(tokenID, permissionName1, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName2, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName3, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName4, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName5, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName6, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName7, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName8, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
} else {
console.info('[permission] case apply permission failed, createAtManager failed');
}
}
async function getPhotoReceiverSurface() {
console.log(TAG + 'Entering getPhotoReceiverSurface')
let receiver = image.createImageReceiver(640, 480, 4, 8)
......@@ -469,7 +407,7 @@ export default function cameraSessionFocusTest(surfaceId: any) {
if (!isEmpty(cameraOutputCap.previewProfiles)) {
console.info(TAG + "cameraOutputCap.previewProfiles.length: " + cameraOutputCap.previewProfiles.length);
for (let i = 0; i < cameraOutputCap.previewProfiles.length; i++) {
mPreviewOutput = await mCameraManager.createPreviewOutput(cameraOutputCap.previewProfiles[i], surfaceId);
mPreviewOutput = await mCameraManager.createPreviewOutput(cameraOutputCap.previewProfiles[i], globalThis.surfaceId);
if (!isEmpty(mPreviewOutput)) {
break;
}
......@@ -647,7 +585,6 @@ export default function cameraSessionFocusTest(surfaceId: any) {
beforeAll(async function () {
sleep(100);
await applyPermission();
await getPhotoReceiverSurface();
await getVideoReceiveSurface();
await getCameraManagerInstance();
......
......@@ -17,13 +17,10 @@
import cameraObj from '@ohos.multimedia.camera';
import image from '@ohos.multimedia.image';
import media from '@ohos.multimedia.media'
import mediaLibrary from '@ohos.multimedia.mediaLibrary'
import fileio from '@ohos.fileio';
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
import bundle from '@ohos.bundle'
import 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 'deccjsunit/index';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium';
const TAG = "CameraModuleTest: ";
......@@ -77,7 +74,7 @@ let mVideoConfig = {
let mPicWidthMax = 8192;
let mPicHeightMax = 8192;
export default function cameraSessionVideoStabilizationTest(surfaceId: any) {
export default function cameraSessionVideoStabilizationTest() {
function sleep(ms) {
console.info(TAG + "Entering sleep -> Promise constructor");
......@@ -123,65 +120,6 @@ export default function cameraSessionVideoStabilizationTest(surfaceId: any) {
}
}
async function applyPermission() {
let appInfo = await bundle.getApplicationInfo('com.open.harmony.multimedia.cameratest', 0, 100);
let atManager = abilityAccessCtrl.createAtManager();
if (atManager != null) {
let tokenID = appInfo.accessTokenId;
console.info('[permission] case accessTokenID is ' + tokenID);
let permissionName1 = 'ohos.permission.CAMERA';
let permissionName2 = 'ohos.permission.MICROPHONE';
let permissionName3 = 'ohos.permission.MEDIA_LOCATION';
let permissionName4 = 'ohos.permission.READ_MEDIA';
let permissionName5 = 'ohos.permission.WRITE_MEDIA';
let permissionName6 = 'ohos.permission.START_ABILIIES_FROM_BACKGROUND';
let permissionName7 = 'ohos.permission.START_INVISIBLE_ABILITY';
let permissionName8 = 'ohos.permission.ABILITY_BACKGROUND_COMMUNICATION';
await atManager.grantUserGrantedPermission(tokenID, permissionName1, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName2, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName3, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName4, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName5, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName6, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName7, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName8, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
} else {
console.info('[permission] case apply permission failed, createAtManager failed');
}
}
async function getPhotoReceiverSurface() {
console.log(TAG + 'Entering getPhotoReceiverSurface')
let receiver = image.createImageReceiver(640, 480, 4, 8)
......@@ -422,7 +360,7 @@ export default function cameraSessionVideoStabilizationTest(surfaceId: any) {
if (!isEmpty(cameraOutputCap.previewProfiles)) {
console.info(TAG + "cameraOutputCap.previewProfiles.length: " + cameraOutputCap.previewProfiles.length);
for (let i = 0; i < cameraOutputCap.previewProfiles.length; i++) {
mPreviewOutput = await mCameraManager.createPreviewOutput(cameraOutputCap.previewProfiles[i], surfaceId);
mPreviewOutput = await mCameraManager.createPreviewOutput(cameraOutputCap.previewProfiles[i], globalThis.surfaceId);
if (!isEmpty(mPreviewOutput)) {
break;
}
......@@ -600,7 +538,6 @@ export default function cameraSessionVideoStabilizationTest(surfaceId: any) {
beforeAll(async function () {
sleep(100);
await applyPermission();
await getPhotoReceiverSurface();
await getVideoReceiveSurface();
await getCameraManagerInstance();
......
......@@ -17,13 +17,10 @@
import cameraObj from '@ohos.multimedia.camera';
import image from '@ohos.multimedia.image';
import media from '@ohos.multimedia.media'
import mediaLibrary from '@ohos.multimedia.mediaLibrary'
import fileio from '@ohos.fileio';
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
import bundle from '@ohos.bundle'
import 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 'deccjsunit/index';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium';
const TAG = "CameraModuleTest: ";
......@@ -79,7 +76,7 @@ let mVideoConfig = {
let mPicWidthMax = 8192;
let mPicHeightMax = 8192;
export default function cameraSessionZoomRatioTest(surfaceId: any) {
export default function cameraSessionZoomRatioTest() {
function sleep(ms) {
console.info(TAG + "Entering sleep -> Promise constructor");
......@@ -125,65 +122,6 @@ export default function cameraSessionZoomRatioTest(surfaceId: any) {
}
}
async function applyPermission() {
let appInfo = await bundle.getApplicationInfo('com.open.harmony.multimedia.cameratest', 0, 100);
let atManager = abilityAccessCtrl.createAtManager();
if (atManager != null) {
let tokenID = appInfo.accessTokenId;
console.info('[permission] case accessTokenID is ' + tokenID);
let permissionName1 = 'ohos.permission.CAMERA';
let permissionName2 = 'ohos.permission.MICROPHONE';
let permissionName3 = 'ohos.permission.MEDIA_LOCATION';
let permissionName4 = 'ohos.permission.READ_MEDIA';
let permissionName5 = 'ohos.permission.WRITE_MEDIA';
let permissionName6 = 'ohos.permission.START_ABILIIES_FROM_BACKGROUND';
let permissionName7 = 'ohos.permission.START_INVISIBLE_ABILITY';
let permissionName8 = 'ohos.permission.ABILITY_BACKGROUND_COMMUNICATION';
await atManager.grantUserGrantedPermission(tokenID, permissionName1, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName2, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName3, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName4, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName5, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName6, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName7, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
await atManager.grantUserGrantedPermission(tokenID, permissionName8, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + err);
});
} else {
console.info('[permission] case apply permission failed, createAtManager failed');
}
}
async function getPhotoReceiverSurface() {
console.log(TAG + 'Entering getPhotoReceiverSurface')
let receiver = image.createImageReceiver(640, 480, 4, 8)
......@@ -426,7 +364,7 @@ export default function cameraSessionZoomRatioTest(surfaceId: any) {
if (!isEmpty(cameraOutputCap.previewProfiles)) {
console.info(TAG + "cameraOutputCap.previewProfiles.length: " + cameraOutputCap.previewProfiles.length);
for (let i = 0; i < cameraOutputCap.previewProfiles.length; i++) {
mPreviewOutput = await mCameraManager.createPreviewOutput(cameraOutputCap.previewProfiles[i], surfaceId);
mPreviewOutput = await mCameraManager.createPreviewOutput(cameraOutputCap.previewProfiles[i], globalThis.surfaceId);
if (!isEmpty(mPreviewOutput)) {
break;
}
......@@ -604,8 +542,6 @@ export default function cameraSessionZoomRatioTest(surfaceId: any) {
beforeAll(async function () {
sleep(100);
await applyPermission();
await getPhotoReceiverSurface();
await getVideoReceiveSurface();
await getCameraManagerInstance();
......
......@@ -7,6 +7,14 @@
{
"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.
先完成此消息的编辑!
想要评论请 注册