• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 "os_account_wrapper_test.h"
17 
18 #include <cstring>
19 #include <gtest/gtest.h>
20 
21 #include "os_account_wrapper.h"
22 
23 using namespace testing::ext;
24 namespace UnitTest::AssetOsAccountWrapperTest {
25 class AssetOsAccountWrapperTest : public testing::Test {
26 public:
27     static void SetUpTestCase(void);
28 
29     static void TearDownTestCase(void);
30 
31     void SetUp(void);
32 
33     void TearDown(void);
34 };
35 
SetUpTestCase(void)36 void AssetOsAccountWrapperTest::SetUpTestCase(void)
37 {
38 }
39 
TearDownTestCase(void)40 void AssetOsAccountWrapperTest::TearDownTestCase(void)
41 {
42 }
43 
SetUp(void)44 void AssetOsAccountWrapperTest::SetUp(void)
45 {
46 }
47 
TearDown(void)48 void AssetOsAccountWrapperTest::TearDown(void)
49 {
50 }
51 
52 /**
53  * @tc.name: AssetOsAccountWrapperTest.AssetOsAccountWrapperTest001
54  * @tc.desc: Test asset func GetOwnerInfo, expect ACCESS_TOKEN_ERROR
55  * @tc.type: FUNC
56  * @tc.result:0
57  */
58 HWTEST_F(AssetOsAccountWrapperTest, AssetOsAccountWrapperTest001, TestSize.Level0)
59 {
60     uint32_t userId = 1000;
61     uint32_t uid = 6226;
62     ASSERT_EQ(true, GetUserIdByUid(uid, &userId));
63 }
64 
65 /**
66  * @tc.name: AssetOsAccountWrapperTest.AssetOsAccountWrapperTest002
67  * @tc.desc: Test asset func IsUserIdExist, expect true
68  * @tc.type: FUNC
69  * @tc.result:0
70  */
71 HWTEST_F(AssetOsAccountWrapperTest, AssetOsAccountWrapperTest002, TestSize.Level0)
72 {
73     int32_t userId = 100;
74     bool exist;
75     ASSERT_EQ(true, IsUserIdExist(userId, &exist));
76 }
77 
78 /**
79  * @tc.name: AssetOsAccountWrapperTest.AssetOsAccountWrapperTest003
80  * @tc.desc: Test asset func IsUserIdExist, expect false
81  * @tc.type: FUNC
82  * @tc.result:0
83  */
84 HWTEST_F(AssetOsAccountWrapperTest, AssetOsAccountWrapperTest003, TestSize.Level0)
85 {
86     int32_t userId = -1;
87     bool exist;
88     ASSERT_EQ(false, IsUserIdExist(userId, &exist));
89 }
90 
91 /**
92  * @tc.name: AssetOsAccountWrapperTest.AssetOsAccountWrapperTest004
93  * @tc.desc: Test asset func IsUserIdExist, expect false
94  * @tc.type: FUNC
95  * @tc.result:0
96  */
97 HWTEST_F(AssetOsAccountWrapperTest, AssetOsAccountWrapperTest004, TestSize.Level0)
98 {
99     int32_t userIds[10];
100     uint32_t userIdsSize = 10;
101     ASSERT_EQ(0, GetUserIds(userIds, &userIdsSize));
102 }
103 
104 /**
105  * @tc.name: AssetOsAccountWrapperTest.AssetOsAccountWrapperTest005
106  * @tc.desc: Test asset func IsUserIdExist, expect false
107  * @tc.type: FUNC
108  * @tc.result:0
109  */
110 HWTEST_F(AssetOsAccountWrapperTest, AssetOsAccountWrapperTest005, TestSize.Level0)
111 {
112     uint32_t userIdsSize = 10;
113     ASSERT_EQ(0, GetUsersSize(&userIdsSize));
114 }
115 }