1/* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License") 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16import { Driver, ON } from '@ohos.UiTest'; 17import { beforeAll, describe, expect, it } from '@ohos/hypium'; 18import abilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; 19import { WantParams } from '../../../../main/ets/common/vm/Constants'; 20import Want from '@ohos.app.ability.Want'; 21 22const delegator = abilityDelegatorRegistry.getAbilityDelegator(); 23const bundleName = abilityDelegatorRegistry.getArguments().bundleName; 24 25const delayTime: number = 1000; 26 27export default function FingerUnderTest() { 28 describe('FingerUnderTest', () => { 29 30 let sleep: (ms: number) => Promise<Function> = (ms: number): Promise<Function> => { 31 return new Promise(resolve => setTimeout(resolve, ms)); 32 } 33 34 beforeAll(async () => { 35 const data: WantParams = { 36 "cmd": [{ 37 "event": "CMD_NOTIFY_AUTH_START", 38 "payload": { 39 "lockoutDuration": 0, 40 "remainAttempts": 5, 41 "sensorInfo": "{\"sensorType\":\"UNDER_SCREEN_SENSOR\",\"udSensorCenterXInThousandth\":500,\"udSensorCenterYInThousandth\":980,\"udSensorRadiusInPx\":50}", 42 "type": "fingerprint", 43 "result": 0 44 }, 45 }], 46 "title": "请输入密码", 47 "type": ["fingerprint"], 48 "navigationButtonText": "按钮", 49 "widgetContextId": 10234972519197798021, 50 "windowModeType": "DIALOG_BOX", 51 "pinSubType": "PIN_SIX" 52 } 53 sleep(delayTime); 54 55 let want: Want = { 56 bundleName: bundleName, 57 abilityName: 'FingerUnderAbility', 58 parameters: { 59 useriamCmdData: data 60 } 61 } 62 await delegator.startAbility(want); 63 sleep(delayTime); 64 }) 65 66 it('cancel_fingerUnder_test', 0, async (done: Function) => { 67 let driver = Driver.create(); 68 await driver.delayMs(delayTime); 69 await driver.findComponent(ON.id('fingerUnderButton')); 70 expect(true).assertTrue(); 71 done(); 72 }) 73 }) 74}