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 PinFingerOutSideTest() {
28  describe('PinFingerOutSideTest', () => {
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          "event": "CMD_NOTIFY_AUTH_START", "payload": {
46            "lockoutDuration": 4556,
47            "remainAttempts": 0,
48            "sensorInfo": "{\"sensorType\":\"OUT_OF_SCREEN_SENSOR\",\"outOfScreenSensorType\":\"SIDE\"}",
49            "type": "fingerprint",
50            "result": 0
51          },
52        }],
53        "pinSubType": "PIN_MIXED",
54        "title": "请输入密码",
55        "type": ["pin", "fingerprint"],
56        "widgetContextId": 14234972519197718021,
57        "windowModeType": "DIALOG_BOX"
58      }
59      sleep(delayTime);
60
61      let want: Want = {
62        bundleName: bundleName,
63        abilityName: 'PinFingerOutSideAbility',
64        parameters: {
65          useriamCmdData: data
66        }
67      }
68      await delegator.startAbility(want);
69      sleep(delayTime);
70    })
71
72    it('cancel_pinFingerSide_test', 0, async (done: Function) => {
73      let driver = Driver.create();
74      await driver.delayMs(delayTime);
75      await driver.findComponent(ON.id('cancelStateMultiFingerprintAuth'));
76      expect(true).assertTrue();
77      done();
78    })
79  })
80}