• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023-2024 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 "user_info_test.h"
17 
18 #include "iam_common_defines.h"
19 #include "user_info_impl.h"
20 
21 namespace OHOS {
22 namespace UserIam {
23 namespace UserAuth {
24 using namespace testing;
25 using namespace testing::ext;
26 
SetUpTestCase()27 void UserInfoTest::SetUpTestCase()
28 {
29 }
30 
TearDownTestCase()31 void UserInfoTest::TearDownTestCase()
32 {
33 }
34 
SetUp()35 void UserInfoTest::SetUp()
36 {
37 }
38 
TearDown()39 void UserInfoTest::TearDown()
40 {
41 }
42 
43 HWTEST_F(UserInfoTest, GetUserId, TestSize.Level0)
44 {
45     constexpr int32_t userId = 100;
46     UserInfo info = {};
47     UserInfoImpl UserInfoImpl(userId, info);
48     int32_t ret = UserInfoImpl.GetUserId();
49     EXPECT_EQ(ret, userId);
50 }
51 
52 HWTEST_F(UserInfoTest, GetPinSubType, TestSize.Level0)
53 {
54     constexpr int32_t userId = 100;
55     constexpr PinSubType pinSubType = PIN_MIXED;
56     constexpr uint64_t secUserId = 200;
57     UserInfo info = {
58         .secureUid = secUserId,
59         .pinSubType = static_cast<OHOS::HDI::UserAuth::V2_0::PinSubType>(pinSubType),
60     };
61     UserInfoImpl UserInfoImpl(userId, info);
62     EXPECT_EQ(UserInfoImpl.GetPinSubType(), pinSubType);
63 }
64 
65 HWTEST_F(UserInfoTest, GetSecUserId, TestSize.Level0)
66 {
67     constexpr int32_t userId = 100;
68     constexpr PinSubType pinSubType = PIN_MIXED;
69     constexpr uint64_t secUserId = 200;
70     UserInfo info = {
71         .secureUid = secUserId,
72         .pinSubType = static_cast<OHOS::HDI::UserAuth::V2_0::PinSubType>(pinSubType),
73     };
74     UserInfoImpl UserInfoImpl(userId, info);
75     uint64_t ret = UserInfoImpl.GetSecUserId();
76     EXPECT_EQ(ret, secUserId);
77 }
78 
79 } // namespace UserAuth
80 } // namespace UserIam
81 } // namespace OHOS
82