1 /*
2  * Copyright (c) 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 <gtest/gtest.h>
17 #include <string>
18 #include <vector>
19 #include <iostream>
20 
21 #include "distributed_device_profile_constants.h"
22 #include "distributed_device_profile_log.h"
23 #include "distributed_device_profile_errors.h"
24 #include "parameter.h"
25 #include "content_sensor_manager_utils.h"
26 
27 
28 using namespace testing::ext;
29 namespace OHOS {
30 namespace DistributedDeviceProfile {
31 using namespace std;
32 namespace {
33     const std::string TAG = "ContentSensorManagerUtilsTest";
34 }
35 class ContentSensorManagerUtilsTest : public testing::Test {
36 public:
37     static void SetUpTestCase();
38     static void TearDownTestCase();
39     void SetUp();
40     void TearDown();
41 };
42 
SetUpTestCase()43 void ContentSensorManagerUtilsTest::SetUpTestCase()
44 {
45 }
46 
TearDownTestCase()47 void ContentSensorManagerUtilsTest::TearDownTestCase()
48 {
49 }
50 
SetUp()51 void ContentSensorManagerUtilsTest::SetUp()
52 {
53 }
54 
TearDown()55 void ContentSensorManagerUtilsTest::TearDown()
56 {
57 }
58 
59 /*
60  * @tc.name: ObtainProductModel001
61  * @tc.desc: ObtainProductModel
62  * @tc.type: FUNC
63  * @tc.require:
64  */
65 HWTEST_F(ContentSensorManagerUtilsTest, ObtainProductModel001, TestSize.Level1)
66 {
67     std::string str = "123456";
68     DistributedDeviceProfile::ContentSensorManagerUtils::GetInstance().deviceModel_ = str;
69     std::string result = DistributedDeviceProfile::ContentSensorManagerUtils::GetInstance().ObtainProductModel();
70     EXPECT_EQ(result, str);
71 }
72 
73 /*
74  * @tc.name: ObtainDeviceType001
75  * @tc.desc: ObtainDeviceType
76  * @tc.type: FUNC
77  * @tc.require:
78  */
79 HWTEST_F(ContentSensorManagerUtilsTest, ObtainDeviceType001, TestSize.Level1)
80 {
81     std::string str = "123456";
82     DistributedDeviceProfile::ContentSensorManagerUtils::GetInstance().deviceType_ = str;
83     std::string result = DistributedDeviceProfile::ContentSensorManagerUtils::GetInstance().ObtainDeviceType();
84     EXPECT_EQ(result, str);
85 }
86 
87 /*
88  * @tc.name: ObtainManufacture001
89  * @tc.desc: ObtainManufacture
90  * @tc.type: FUNC
91  * @tc.require:
92  */
93 HWTEST_F(ContentSensorManagerUtilsTest, ObtainManufacture001, TestSize.Level1)
94 {
95     std::string str = "123456";
96     DistributedDeviceProfile::ContentSensorManagerUtils::GetInstance().manufacture_ = str;
97     std::string result = DistributedDeviceProfile::ContentSensorManagerUtils::GetInstance().ObtainManufacture();
98     EXPECT_EQ(result, str);
99 }
100 
101 /*
102  * @tc.name: ObtainSerial001
103  * @tc.desc: ObtainSerial
104  * @tc.type: FUNC
105  * @tc.require:
106  */
107 HWTEST_F(ContentSensorManagerUtilsTest, ObtainSerial001, TestSize.Level1)
108 {
109     std::string str = "123456";
110     DistributedDeviceProfile::ContentSensorManagerUtils::GetInstance().serial_ = str;
111     std::string result = DistributedDeviceProfile::ContentSensorManagerUtils::GetInstance().ObtainSerial();
112     EXPECT_EQ(result, str);
113 }
114 
115 
116 /*
117  * @tc.name: ObtainMarketName001
118  * @tc.desc: ObtainMarketName
119  * @tc.type: FUNC
120  * @tc.require:
121  */
122 HWTEST_F(ContentSensorManagerUtilsTest, ObtainMarketName001, TestSize.Level1)
123 {
124     std::string str = "123456";
125     DistributedDeviceProfile::ContentSensorManagerUtils::GetInstance().serial_ = str;
126     std::string result = DistributedDeviceProfile::ContentSensorManagerUtils::GetInstance().ObtainMarketName();
127     EXPECT_NE(result, str);
128 }
129 
130 /*
131  * @tc.name: ObtainOsFullName001
132  * @tc.desc: ObtainOsFullName
133  * @tc.type: FUNC
134  * @tc.require:
135  */
136 HWTEST_F(ContentSensorManagerUtilsTest, ObtainOsFullName001, TestSize.Level1)
137 {
138     std::string str = "123456";
139     DistributedDeviceProfile::ContentSensorManagerUtils::GetInstance().osFullName_ = str;
140     std::string result = DistributedDeviceProfile::ContentSensorManagerUtils::GetInstance().ObtainOsFullName();
141     EXPECT_EQ(result, str);
142 }
143 
144 /*
145  * @tc.name: ObtainDisplayVersion001
146  * @tc.desc: ObtainDisplayVersion
147  * @tc.type: FUNC
148  * @tc.require:
149  */
150 HWTEST_F(ContentSensorManagerUtilsTest, ObtainDisplayVersion001, TestSize.Level1)
151 {
152     std::string str = "123456";
153     DistributedDeviceProfile::ContentSensorManagerUtils::GetInstance().displayVersion_ = str;
154     std::string result = DistributedDeviceProfile::ContentSensorManagerUtils::GetInstance().ObtainDisplayVersion();
155     EXPECT_EQ(result, str);
156 }
157 
158 /*
159  * @tc.name: ObtainLocalUdid001
160  * @tc.desc: ObtainLocalUdid
161  * @tc.type: FUNC
162  * @tc.require:
163  */
164 HWTEST_F(ContentSensorManagerUtilsTest, ObtainLocalUdid001, TestSize.Level1)
165 {
166     std::string str = "123456";
167     DistributedDeviceProfile::ContentSensorManagerUtils::GetInstance().localUdid_ = str;
168     std::string result = DistributedDeviceProfile::ContentSensorManagerUtils::GetInstance().ObtainLocalUdid();
169     EXPECT_EQ(result, str);
170 }
171 } // namespace DistributedDeviceProfile
172 } // namespace OHOS
173