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, GetSecUserId, TestSize.Level0)
53 {
54 constexpr int32_t userId = 100;
55 constexpr uint64_t secUserId = 200;
56 UserInfo info = {
57 .secureUid = secUserId,
58 };
59 UserInfoImpl UserInfoImpl(userId, info);
60 uint64_t ret = UserInfoImpl.GetSecUserId();
61 EXPECT_EQ(ret, secUserId);
62 }
63
64 } // namespace UserAuth
65 } // namespace UserIam
66 } // namespace OHOS
67