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