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 Want from '@ohos.app.ability.Want';
20import { WantParams } from '../../../../main/ets/common/vm/Constants';
21
22const delegator = abilityDelegatorRegistry.getAbilityDelegator();
23const bundleName = abilityDelegatorRegistry.getArguments().bundleName;
24
25const delayTime: number = 1000;
26
27export default function PinFingerOutFrontTest() {
28  describe('PinFingerOutFrontTest', () => {
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            "type": "pin",
42            "result": 0
43          },
44        },
45          {
46            "event": "CMD_NOTIFY_AUTH_START", "payload": {
47            "lockoutDuration": 1123,
48            "remainAttempts": 0,
49            "sensorInfo": "{\"sensorType\":\"OUT_OF_SCREEN_SENSOR\",\"outOfScreenSensorType\":\"FRONT\"}",
50            "type": "fingerprint",
51            "result": 0
52          },
53          }],
54        "pinSubType": "PIN_NUMBER",
55        "title": "请输入密码",
56        "type": ["pin", "fingerprint"],
57        "widgetContextId": 10234972526197798021,
58        "windowModeType": "DIALOG_BOX"
59      }
60      sleep(delayTime);
61
62      let want: Want = {
63        bundleName: bundleName,
64        abilityName: 'PinFingerOutFrontAbility',
65        parameters: {
66          useriamCmdData: data
67        }
68      }
69      await delegator.startAbility(want);
70      sleep(delayTime);
71    })
72
73    it('cancel_pinFingerOutFront_test', 0, async (done: Function) => {
74      let driver = Driver.create();
75      await driver.delayMs(delayTime);
76      await driver.findComponent(ON.id('cancelStateMultiFingerprintAuth'));
77      expect(true).assertTrue();
78      done();
79    })
80  })
81}