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 "enrolled_info_test.h"
17 #include "enrolled_info_impl.h"
18 #include "iam_common_defines.h"
19
20 namespace OHOS {
21 namespace UserIam {
22 namespace UserAuth {
23 using namespace testing;
24 using namespace testing::ext;
SetUpTestCase()25 void EnrolledInfoTest::SetUpTestCase()
26 {
27 }
28
TearDownTestCase()29 void EnrolledInfoTest::TearDownTestCase()
30 {
31 }
32
SetUp()33 void EnrolledInfoTest::SetUp()
34 {
35 }
36
TearDown()37 void EnrolledInfoTest::TearDown()
38 {
39 }
40
41 HWTEST_F(EnrolledInfoTest, GetUserId, TestSize.Level0)
42 {
43 int32_t userId = 100;
44 HdiEnrolledInfo info = {
45 .enrolledId = 200,
46 .authType = static_cast<HdiAuthType>(1),
47 };
48 EnrolledInfoImpl enrolledInfoImpl(userId, info);
49 int32_t ret = enrolledInfoImpl.GetUserId();
50 EXPECT_EQ(ret, userId);
51 }
52
53 HWTEST_F(EnrolledInfoTest, GetAuthType, TestSize.Level0)
54 {
55 int32_t userId = 100;
56 HdiEnrolledInfo info = {
57 .enrolledId = 200,
58 .authType = static_cast<HdiAuthType>(1),
59 };
60 EnrolledInfoImpl enrolledInfoImpl(userId, info);
61 AuthType ret = enrolledInfoImpl.GetAuthType();
62 EXPECT_EQ(ret, PIN);
63 }
64
65 HWTEST_F(EnrolledInfoTest, GetEnrolledId, TestSize.Level0)
66 {
67 int32_t userId = 100;
68 HdiEnrolledInfo info = {
69 .enrolledId = 200,
70 .authType = static_cast<HdiAuthType>(1),
71 };
72 EnrolledInfoImpl enrolledInfoImpl(userId, info);
73 uint64_t ret = enrolledInfoImpl.GetEnrolledId();
74 EXPECT_EQ(ret, 200U);
75 }
76 } // namespace UserAuth
77 } // namespace UserIam
78 } // namespace OHOS
79