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 PinNumberTest() { 28 describe('PinNumberTest', () => { 29 beforeAll(async () => { 30 const data: WantParams = { 31 "cmd": [{ 32 "event": "CMD_NOTIFY_AUTH_START", 33 "payload": { 34 "type": "pin", 35 "lockoutDuration": 0, 36 "remainAttempts": 5, 37 "sensorInfo": "", 38 "result":0 39 }, 40 }], 41 "pinSubType": "PIN_NUMBER", 42 "title": "使用密码验证", 43 "type": ["pin"], 44 "widgetContextId": 7932856209793250000, 45 "windowModeType": "DIALOG_BOX" 46 }; 47 48 let want: Want = { 49 bundleName: bundleName, 50 abilityName: "PasswordAbility", 51 parameters: { 52 useriamCmdData: data 53 } 54 } 55 await delegator.startAbility(want); 56 }) 57 58 it('title_pwd_auth_test', 0, async (done: Function) => { 59 let driver = Driver.create(); 60 await driver.delayMs(delayTime); 61 await driver.findComponent(ON.id('titlePwdAuth')); 62 expect(true).assertTrue(); 63 done(); 64 }) 65 66 it('input_dialog_pwd_fail_test', 0, async (done: Function) => { 67 let driver = Driver.create(); 68 await driver.delayMs(delayTime); 69 await driver.findComponent(ON.id('pinInputMix')); 70 expect(true).assertTrue(); 71 done(); 72 }) 73 74 it('input_dialog_pwd_test', 0, async (done: Function) => { 75 let driver = Driver.create(); 76 await driver.delayMs(delayTime); 77 await driver.findComponent(ON.id('pinInputMix')); 78 await driver.delayMs(delayTime); 79 await driver.findComponent(ON.id('okBtn')); 80 expect(true).assertTrue(); 81 done(); 82 }) 83 84 it('cancelBtn_dialog_pwd_test', 0, async (done: Function) => { 85 let driver = Driver.create(); 86 await driver.delayMs(delayTime); 87 await driver.findComponent(ON.id('cancelBtnDialogPwd')); 88 expect(true).assertTrue(); 89 done(); 90 }) 91 }) 92}