• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 userAuth from '@ohos.userIAM.userAuth';
20import { WantParams } from '../../../../main/ets/common/vm/Constants';
21import Want from '@ohos.app.ability.Want';
22
23const delegator = abilityDelegatorRegistry.getAbilityDelegator();
24const bundleName = abilityDelegatorRegistry.getArguments().bundleName;
25
26const delayTime: number = 1000;
27
28export default function FaceTest() {
29  describe('FaceTest', () => {
30    beforeAll(async () => {
31      const authParam : userAuth.AuthParam = {
32        challenge: new Uint8Array([49, 49, 49, 49, 49, 49]),
33        authType: [2],
34        authTrustLevel: 10000,
35      };
36      const widgetParam : userAuth.WidgetParam = {
37        title: '使用人脸验证',
38        windowMode: 1,
39        navigationButtonText: '确认',
40      };
41      let userAuthInstance = await userAuth.getUserAuthInstance(authParam, widgetParam);
42      userAuthInstance.start();
43
44      const data: WantParams = {
45        "cmd": [{
46          "event": "CMD_NOTIFY_AUTH_START",
47          "payload": {
48            "lockoutDuration": 0,
49            "remainAttempts": 5,
50            "type": "face",
51            "result": 0
52          },
53        }],
54        "title": "请输入密码",
55        "type": ["face"],
56        "widgetContextId": 13808827370146417000,
57        "windowModeType": "DIALOG_BOX",
58        "pinSubType": "PIN_SIX"
59      }
60
61      let want: Want = {
62        bundleName: bundleName,
63        abilityName: 'FaceAbility',
64        parameters: {
65          useriamCmdData: data
66        }
67      }
68      await delegator.startAbility(want);
69    })
70
71    it('title_faceAuth_test', 0, async (done: Function) => {
72      let driver = Driver.create();
73      await driver.delayMs(delayTime);
74      await driver.findComponent(ON.id('titleFaceAuth'));
75      expect(true).assertTrue();
76      done();
77    })
78
79    it('image_faceAuth_test', 0, async (done: Function) => {
80      let driver = Driver.create();
81      await driver.delayMs(delayTime);
82      await driver.findComponent(ON.id('imageFaceAuth'));
83      expect(true).assertTrue();
84      done();
85    })
86
87    it('text_faceAuth_test', 0, async (done: Function) => {
88      let driver = Driver.create();
89      await driver.delayMs(delayTime);
90      await driver.findComponent(ON.id('textFaceAuth'));
91      expect(true).assertTrue();
92      done();
93    })
94
95    it('cancelBtn_allFace_test', 0, async (done: Function) => {
96      let driver = Driver.create();
97      await driver.delayMs(delayTime);
98      await driver.findComponent(ON.id('cancelBtnAllFace'));
99      expect(true).assertTrue();
100      done();
101    })
102  })
103}