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 FingerOutSideTest() {
28  describe('FingerOutSideTest', () => {
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\":\"OUT_OF_SCREEN_SENSOR\",\"outOfScreenSensorType\":\"SIDE\"}",
42            "type": "fingerprint",
43            "result": 0
44          },
45        }],
46        "pinSubType": "PIN_SIX",
47        "title": "请输入密码",
48        "type": ["fingerprint"],
49        "navigationButtonText": "按钮",
50        "widgetContextId": 10234972519197718021,
51        "windowModeType": "DIALOG_BOX"
52      }
53      sleep(delayTime);
54
55      let want: Want = {
56        bundleName: bundleName,
57        abilityName: 'FingerOutSideAbility',
58        parameters: {
59          useriamCmdData: data
60        }
61      }
62      await delegator.startAbility(want);
63      sleep(delayTime);
64    })
65
66    it('cancel_fingerSide_test', 0, async (done: Function) => {
67      let driver = Driver.create();
68      await driver.delayMs(delayTime);
69      await driver.findComponent(ON.id('outFingerImage'));
70      expect(true).assertTrue();
71      done();
72    })
73  })
74}