• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 
16 #include "fingerprint_auth_hdi_test.h"
17 
18 #include <hdf_base.h>
19 
20 #include "iam_hat_test.h"
21 
22 #define LOG_LABEL OHOS::UserIam::Common::LABEL_FINGERPRINT_AUTH_IMPL
23 
24 using namespace std;
25 using namespace testing::ext;
26 using namespace OHOS::UserIam::Common;
27 using namespace OHOS::HDI::FingerprintAuth;
28 
29 static OHOS::Parcel parcel;
30 
SetUpTestCase()31 void FingerPrintTypeTest::SetUpTestCase()
32 {
33 }
34 
TearDownTestCase()35 void FingerPrintTypeTest::TearDownTestCase()
36 {
37 }
38 
SetUp()39 void FingerPrintTypeTest::SetUp()
40 {
41 }
42 
TearDown()43 void FingerPrintTypeTest::TearDown()
44 {
45 }
46 
47 /**
48  * @tc.number: Security_IAM_Fingerprint_HDI_FUNC_0201
49  * @tc.name: Test AuthType
50  * @tc.size: MediumTest
51  * @tc.type: Function
52  * @tc.level: Level1
53  */
54 HWTEST_F(FingerPrintTypeTest, Security_IAM_Fingerprint_HDI_FUNC_0201, Function | MediumTest | Level1)
55 {
56     cout << "start test AuthType" << endl;
57     AuthType pin = AuthType::PIN;
58     AuthType face = AuthType::FACE;
59     AuthType fingerprint = AuthType::FINGERPRINT;
60     EXPECT_EQ(pin, 1);
61     EXPECT_EQ(face, 2);
62     EXPECT_EQ(fingerprint, 4);
63 }
64 
65 /**
66  * @tc.number: Security_IAM_Fingerprint_HDI_FUNC_0202
67  * @tc.name: Test ExecutorRole
68  * @tc.size: MediumTest
69  * @tc.type: Function
70  * @tc.level: Level1
71  */
72 HWTEST_F(FingerPrintTypeTest, Security_IAM_Fingerprint_HDI_FUNC_0202, Function | MediumTest | Level1)
73 {
74     cout << "start test ExecutorRole" << endl;
75     ExecutorRole collector = ExecutorRole::COLLECTOR;
76     ExecutorRole verifier = ExecutorRole::VERIFIER;
77     ExecutorRole all_in_one = ExecutorRole::ALL_IN_ONE;
78     EXPECT_EQ(collector, 1);
79     EXPECT_EQ(verifier, 2);
80     EXPECT_EQ(all_in_one, 3);
81 }
82 
83 /**
84  * @tc.number: Security_IAM_Fingerprint_HDI_FUNC_0203
85  * @tc.name: Test ExecutorSecureLevel
86  * @tc.size: MediumTest
87  * @tc.type: Function
88  * @tc.level: Level1
89  */
90 HWTEST_F(FingerPrintTypeTest, Security_IAM_Fingerprint_HDI_FUNC_0203, Function | MediumTest | Level1)
91 {
92     cout << "start test ExecutorSecureLevel" << endl;
93     ExecutorSecureLevel esl0 = ExecutorSecureLevel::ESL0;
94     ExecutorSecureLevel esl1 = ExecutorSecureLevel::ESL1;
95     ExecutorSecureLevel esl2 = ExecutorSecureLevel::ESL2;
96     ExecutorSecureLevel esl3 = ExecutorSecureLevel::ESL3;
97     EXPECT_EQ(esl0, 0);
98     EXPECT_EQ(esl1, 1);
99     EXPECT_EQ(esl2, 2);
100     EXPECT_EQ(esl3, 3);
101 }
102 
103 /**
104  * @tc.number: Security_IAM_Fingerprint_HDI_FUNC_0204
105  * @tc.name: Test DriverCommandId
106  * @tc.size: MediumTest
107  * @tc.type: Function
108  * @tc.level: Level1
109  */
110 HWTEST_F(FingerPrintTypeTest, Security_IAM_Fingerprint_HDI_FUNC_0204, Function | MediumTest | Level1)
111 {
112     cout << "start test DriverCommandId" << endl;
113     DriverCommandId lock_template = DriverCommandId::LOCK_TEMPLATE;
114     DriverCommandId unlock_template = DriverCommandId::UNLOCK_TEMPLATE;
115     DriverCommandId vendor_command_begin = DriverCommandId::VENDOR_COMMAND_BEGIN;
116     DriverCommandId init_algorithm = DriverCommandId::INIT_ALGORITHM;
117     EXPECT_EQ(lock_template, 1);
118     EXPECT_EQ(unlock_template, 2);
119     EXPECT_EQ(vendor_command_begin, 10000);
120     EXPECT_EQ(init_algorithm, 3);
121 }
122 
123 /**
124  * @tc.number: Security_IAM_Fingerprint_HDI_NEW_FUNC_0201
125  * @tc.name: Test FingerprintTipsCode
126  * @tc.size: MediumTest
127  * @tc.type: Function
128  * @tc.level: Level1
129  */
130 HWTEST_F(FingerPrintTypeTest, Security_IAM_Fingerprint_HDI_NEW_FUNC_0201, Function | MediumTest | Level1)
131 {
132     cout << "start test FingerprintTipsCode" << endl;
133     FingerprintTipsCode f_good = FingerprintTipsCode::FINGERPRINT_AUTH_TIP_GOOD;
134     FingerprintTipsCode f_dirty = FingerprintTipsCode::FINGERPRINT_AUTH_TIP_DIRTY;
135     FingerprintTipsCode f_insufficient = FingerprintTipsCode::FINGERPRINT_AUTH_TIP_INSUFFICIENT;
136     FingerprintTipsCode f_partial = FingerprintTipsCode::FINGERPRINT_AUTH_TIP_PARTIAL;
137     FingerprintTipsCode f_fast = FingerprintTipsCode::FINGERPRINT_AUTH_TIP_TOO_FAST;
138     FingerprintTipsCode f_slow = FingerprintTipsCode::FINGERPRINT_AUTH_TIP_TOO_SLOW;
139     FingerprintTipsCode f_begin = FingerprintTipsCode::VENDOR_FINGERPRINT_AUTH_TIP_BEGIN;
140     FingerprintTipsCode g_down = FingerprintTipsCode::FINGERPRINT_AUTH_TIP_FINGER_DOWN;
141     FingerprintTipsCode g_up = FingerprintTipsCode::FINGERPRINT_AUTH_TIP_FINGER_UP;
142 
143     EXPECT_EQ(f_good, 0);
144     EXPECT_EQ(f_dirty, 1);
145     EXPECT_EQ(f_insufficient, 2);
146     EXPECT_EQ(f_partial, 3);
147     EXPECT_EQ(f_fast, 4);
148     EXPECT_EQ(f_slow, 5);
149     EXPECT_EQ(g_down, 6);
150     EXPECT_EQ(g_up, 7);
151     EXPECT_EQ(f_begin, 10000);
152 }
153 
154 /**
155  * @tc.number: Security_IAM_Fingerprint_HDI_NEW_FUNC_0202
156  * @tc.name: Test GetPropertyType
157  * @tc.size: MediumTest
158  * @tc.type: Function
159  * @tc.level: Level1
160  */
161 HWTEST_F(FingerPrintTypeTest, Security_IAM_Fingerprint_HDI_NEW_FUNC_0202, Function | MediumTest | Level1)
162 {
163     cout << "start test GetPropertyType" << endl;
164     GetPropertyType auth_sub_type = GetPropertyType::AUTH_SUB_TYPE;
165     GetPropertyType lockout_duration = GetPropertyType::LOCKOUT_DURATION;
166     GetPropertyType remain_attempts = GetPropertyType::REMAIN_ATTEMPTS;
167     GetPropertyType enroll_progress = GetPropertyType::ENROLL_PROGRESS;
168     GetPropertyType sensor_info = GetPropertyType::SENSOR_INFO;
169 
170     EXPECT_EQ(auth_sub_type, 1);
171     EXPECT_EQ(lockout_duration, 2);
172     EXPECT_EQ(remain_attempts, 3);
173     EXPECT_EQ(enroll_progress, 4);
174     EXPECT_EQ(sensor_info, 5);
175 }
176 
177 /**
178  * @tc.number: Security_IAM_Fingerprint_HDI_NEW_FUNC_0203
179  * @tc.name: Test SaCommandId
180  * @tc.size: MediumTest
181  * @tc.type: Function
182  * @tc.level: Level1
183  */
184 HWTEST_F(FingerPrintTypeTest, Security_IAM_Fingerprint_HDI_NEW_FUNC_0203, Function | MediumTest | Level1)
185 {
186     cout << "start test SaCommandId" << endl;
187     SaCommandId enable_sensor_illumination = SaCommandId::ENABLE_SENSOR_ILLUMINATION;
188     SaCommandId disable_sensor_illumination = SaCommandId::DISABLE_SENSOR_ILLUMINATION;
189     SaCommandId turn_on_sensor_illumination = SaCommandId::TURN_ON_SENSOR_ILLUMINATION;
190     SaCommandId turn_off_sensor_illumination = SaCommandId::TURN_OFF_SENSOR_ILLUMINATION;
191 
192     EXPECT_EQ(enable_sensor_illumination, 1);
193     EXPECT_EQ(disable_sensor_illumination, 2);
194     EXPECT_EQ(turn_on_sensor_illumination, 3);
195     EXPECT_EQ(turn_off_sensor_illumination, 4);
196 }