• 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 "bms_wrapper_test.h"
17 
18 #include <cstring>
19 #include <gtest/gtest.h>
20 
21 #include "asset_type.h"
22 #include "bms_wrapper.h"
23 
24 using namespace testing::ext;
25 namespace UnitTest::AssetBmsWrapperTest {
26 class AssetBmsWrapperTest : public testing::Test {
27 public:
28     static void SetUpTestCase(void);
29 
30     static void TearDownTestCase(void);
31 
32     void SetUp(void);
33 
34     void TearDown(void);
35 };
36 
SetUpTestCase(void)37 void AssetBmsWrapperTest::SetUpTestCase(void)
38 {
39 }
40 
TearDownTestCase(void)41 void AssetBmsWrapperTest::TearDownTestCase(void)
42 {
43 }
44 
SetUp(void)45 void AssetBmsWrapperTest::SetUp(void)
46 {
47 }
48 
TearDown(void)49 void AssetBmsWrapperTest::TearDown(void)
50 {
51 }
52 
53 /**
54  * @tc.name: AssetBmsWrapperTest.AssetBmsWrapperTest001
55  * @tc.desc: Test asset func GetOwnerInfo, expect SUCCESS
56  * @tc.type: FUNC
57  * @tc.result:0
58  */
59 HWTEST_F(AssetBmsWrapperTest, AssetBmsWrapperTest001, TestSize.Level0)
60 {
61     OwnerType ownerType = NATIVE;
62     uint8_t ownerInfo[256] = { 0 };
63     uint32_t infoLen = 256;
64     int32_t userId = 0;
65     uint64_t uid = 0;
66     ASSERT_EQ(ASSET_SUCCESS, GetOwnerInfo(userId, uid, &ownerType, ownerInfo, &infoLen));
67 }
68 
69 /**
70  * @tc.name: AssetBmsWrapperTest.AssetBmsWrapperTest002
71  * @tc.desc: Test asset func GetOwnerInfo, expect INVALID_ARGUMENT
72  * @tc.type: FUNC
73  * @tc.result:0
74  */
75 HWTEST_F(AssetBmsWrapperTest, AssetBmsWrapperTest002, TestSize.Level0)
76 {
77     OwnerType* ownerType = nullptr;
78     uint8_t ownerInfo[256] = { 0 };
79     uint32_t infoLen = 256;
80     int32_t userId = 0;
81     uint64_t uid = 0;
82     ASSERT_EQ(ASSET_INVALID_ARGUMENT, GetOwnerInfo(userId, uid, ownerType, ownerInfo, &infoLen));
83 }
84 
85 /**
86  * @tc.name: AssetBmsWrapperTest.AssetBmsWrapperTest003
87  * @tc.desc: Test asset func GetOwnerInfo, expect INVALID_ARGUMENT
88  * @tc.type: FUNC
89  * @tc.result:0
90  */
91 HWTEST_F(AssetBmsWrapperTest, AssetBmsWrapperTest003, TestSize.Level0)
92 {
93     OwnerType ownerType = NATIVE;
94     uint8_t* ownerInfo = nullptr;
95     uint32_t infoLen = 256;
96     int32_t userId = 0;
97     uint64_t uid = 0;
98     ASSERT_EQ(ASSET_INVALID_ARGUMENT, GetOwnerInfo(userId, uid, &ownerType, ownerInfo, &infoLen));
99 }
100 
101 /**
102  * @tc.name: AssetBmsWrapperTest.AssetBmsWrapperTest004
103  * @tc.desc: Test asset func GetOwnerInfo, expect INVALID_ARGUMENT
104  * @tc.type: FUNC
105  * @tc.result:0
106  */
107 HWTEST_F(AssetBmsWrapperTest, AssetBmsWrapperTest004, TestSize.Level0)
108 {
109     OwnerType ownerType = NATIVE;
110     uint8_t ownerInfo[256] = { 0 };
111     uint32_t* infoLen = nullptr;
112     int32_t userId = 0;
113     uint64_t uid = 0;
114     ASSERT_EQ(ASSET_INVALID_ARGUMENT, GetOwnerInfo(userId, uid, &ownerType, ownerInfo, infoLen));
115 }
116 
117 /**
118  * @tc.name: AssetBmsWrapperTest.AssetBmsWrapperTest005
119  * @tc.desc: Test asset func CheckPermission, expect BMS_ERROR
120  * @tc.type: FUNC
121  * @tc.result:0
122  */
123 HWTEST_F(AssetBmsWrapperTest, AssetBmsWrapperTest005, TestSize.Level0)
124 {
125     ASSERT_EQ(false, CheckPermission());
126 }
127 }