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 "dp_radar_helper_test.h"
17 #include "dp_radar_helper.h"
18 
19 namespace OHOS {
20 namespace DistributedDeviceProfile {
SetUp()21 void DpRadarHelperTest::SetUp()
22 {
23 }
24 
TearDown()25 void DpRadarHelperTest::TearDown()
26 {
27 }
28 
SetUpTestCase()29 void DpRadarHelperTest::SetUpTestCase()
30 {
31 }
32 
TearDownTestCase()33 void DpRadarHelperTest::TearDownTestCase()
34 {
35 }
36 
37 HWTEST_F(DpRadarHelperTest, ReportPutACProfile_001, testing::ext::TestSize.Level0)
38 {
39     AccessControlProfile accessControlProfile;
40     int32_t errCode = static_cast<int32_t>(StageRes::STAGE_SUCC);
41     DpRadarHelper::GetInstance().ReportPutAclProfile(errCode, accessControlProfile);
42     errCode = static_cast<int32_t>(StageRes::STAGE_FAIL);
43     DpRadarHelper::GetInstance().ReportPutAclProfile(errCode, accessControlProfile);
44     std::vector<TrustDeviceProfile> trustDeviceProfiles;
45     std::string res = DpRadarHelper::GetInstance().GetPeerUdidList(trustDeviceProfiles);
46     EXPECT_EQ(res, "");
47 }
48 
49 HWTEST_F(DpRadarHelperTest, ReportUpdateACProfile_001, testing::ext::TestSize.Level0)
50 {
51     AccessControlProfile accessControlProfile;
52     int32_t errCode = static_cast<int32_t>(StageRes::STAGE_SUCC);
53     DpRadarHelper::GetInstance().ReportUpdateAclProfile(errCode, accessControlProfile);
54     errCode = static_cast<int32_t>(StageRes::STAGE_FAIL);
55     DpRadarHelper::GetInstance().ReportUpdateAclProfile(errCode, accessControlProfile);
56     std::vector<TrustDeviceProfile> trustDeviceProfiles;
57     std::string res = DpRadarHelper::GetInstance().GetPeerUdidList(trustDeviceProfiles);
58     EXPECT_EQ(res, "");
59 }
60 
61 HWTEST_F(DpRadarHelperTest, ReportGetTrustProfile_001, testing::ext::TestSize.Level0)
62 {
63     TrustDeviceProfile trustDeviceProfile;
64     std::string deviceId = "";
65     int32_t errCode = static_cast<int32_t>(StageRes::STAGE_SUCC);
66     DpRadarHelper::GetInstance().ReportGetTrustProfile(errCode, deviceId, trustDeviceProfile);
67     errCode = static_cast<int32_t>(StageRes::STAGE_FAIL);
68     DpRadarHelper::GetInstance().ReportGetTrustProfile(errCode, deviceId, trustDeviceProfile);
69 
70     std::vector<TrustDeviceProfile> trustDeviceProfiles;
71     std::string res = DpRadarHelper::GetInstance().GetPeerUdidList(trustDeviceProfiles);
72     EXPECT_EQ(res, "");
73 }
74 
75 HWTEST_F(DpRadarHelperTest, ReportGetAllTrustProfile_001, testing::ext::TestSize.Level0)
76 {
77     std::vector<TrustDeviceProfile> trustDeviceProfiles;
78     int32_t errCode = static_cast<int32_t>(StageRes::STAGE_SUCC);
79     DpRadarHelper::GetInstance().ReportGetAllTrustProfile(errCode, trustDeviceProfiles);
80     errCode = static_cast<int32_t>(StageRes::STAGE_FAIL);
81     DpRadarHelper::GetInstance().ReportGetAllTrustProfile(errCode, trustDeviceProfiles);
82     std::string res = DpRadarHelper::GetInstance().GetPeerUdidList(trustDeviceProfiles);
83     EXPECT_EQ(res, "");
84 }
85 
86 HWTEST_F(DpRadarHelperTest, ReportGetACProfile_001, testing::ext::TestSize.Level0)
87 {
88     std::vector<AccessControlProfile> accessControlProfiles;
89     int32_t errCode = static_cast<int32_t>(StageRes::STAGE_SUCC);
90     DpRadarHelper::GetInstance().ReportGetAclProfile(errCode, accessControlProfiles);
91     errCode = static_cast<int32_t>(StageRes::STAGE_FAIL);
92     DpRadarHelper::GetInstance().ReportGetAclProfile(errCode, accessControlProfiles);
93     std::vector<TrustDeviceProfile> trustDeviceProfiles;
94     std::string res = DpRadarHelper::GetInstance().GetPeerUdidList(trustDeviceProfiles);
95     EXPECT_EQ(res, "");
96 }
97 
98 HWTEST_F(DpRadarHelperTest, ReportGetAllACProfile_001, testing::ext::TestSize.Level0)
99 {
100     std::vector<AccessControlProfile> accessControlProfiles;
101     int32_t errCode = static_cast<int32_t>(StageRes::STAGE_SUCC);
102     DpRadarHelper::GetInstance().ReportGetAllAclProfile(errCode, accessControlProfiles);
103     errCode = static_cast<int32_t>(StageRes::STAGE_FAIL);
104     DpRadarHelper::GetInstance().ReportGetAllAclProfile(errCode, accessControlProfiles);
105     std::vector<TrustDeviceProfile> trustDeviceProfiles;
106     std::string res = DpRadarHelper::GetInstance().GetPeerUdidList(trustDeviceProfiles);
107     EXPECT_EQ(res, "");
108 }
109 
110 HWTEST_F(DpRadarHelperTest, ReportDeleteACProfile_001, testing::ext::TestSize.Level0)
111 {
112     int32_t errCode = static_cast<int32_t>(StageRes::STAGE_SUCC);
113     DpRadarHelper::GetInstance().ReportDeleteAclProfile(errCode);
114     errCode = static_cast<int32_t>(StageRes::STAGE_FAIL);
115     DpRadarHelper::GetInstance().ReportDeleteAclProfile(errCode);
116     std::vector<TrustDeviceProfile> trustDeviceProfiles;
117     std::string res = DpRadarHelper::GetInstance().GetPeerUdidList(trustDeviceProfiles);
118     EXPECT_EQ(res, "");
119 }
120 
121 HWTEST_F(DpRadarHelperTest, ReportPutServiceProfile_001, testing::ext::TestSize.Level0)
122 {
123     ServiceProfile serviceProfile;
124     int32_t errCode = static_cast<int32_t>(StageRes::STAGE_SUCC);
125     DpRadarHelper::GetInstance().ReportPutServiceProfile(errCode, serviceProfile);
126     errCode = static_cast<int32_t>(StageRes::STAGE_FAIL);
127     DpRadarHelper::GetInstance().ReportPutServiceProfile(errCode, serviceProfile);
128     std::vector<TrustDeviceProfile> trustDeviceProfiles;
129     std::string res = DpRadarHelper::GetInstance().GetPeerUdidList(trustDeviceProfiles);
130     EXPECT_EQ(res, "");
131 }
132 
133 HWTEST_F(DpRadarHelperTest, ReportPutServiceProfileBatch_001, testing::ext::TestSize.Level0)
134 {
135     std::vector<ServiceProfile> serviceProfiles;
136     int32_t errCode = static_cast<int32_t>(StageRes::STAGE_SUCC);
137     DpRadarHelper::GetInstance().ReportPutServiceProfileBatch(errCode, serviceProfiles);
138     errCode = static_cast<int32_t>(StageRes::STAGE_FAIL);
139     DpRadarHelper::GetInstance().ReportPutServiceProfileBatch(errCode, serviceProfiles);
140     std::vector<TrustDeviceProfile> trustDeviceProfiles;
141     std::string res = DpRadarHelper::GetInstance().GetPeerUdidList(trustDeviceProfiles);
142     EXPECT_EQ(res, "");
143 }
144 
145 HWTEST_F(DpRadarHelperTest, ReportPutChProfile_001, testing::ext::TestSize.Level0)
146 {
147     CharacteristicProfile characteristicProfile;
148     int32_t errCode = static_cast<int32_t>(StageRes::STAGE_SUCC);
149     DpRadarHelper::GetInstance().ReportPutCharProfile(errCode, characteristicProfile);
150     errCode = static_cast<int32_t>(StageRes::STAGE_FAIL);
151     DpRadarHelper::GetInstance().ReportPutCharProfile(errCode, characteristicProfile);
152     std::vector<TrustDeviceProfile> trustDeviceProfiles;
153     std::string res = DpRadarHelper::GetInstance().GetPeerUdidList(trustDeviceProfiles);
154     EXPECT_EQ(res, "");
155 }
156 
157 HWTEST_F(DpRadarHelperTest, ReportPutChProfileBatch_001, testing::ext::TestSize.Level0)
158 {
159     std::vector<CharacteristicProfile> characteristicProfiles;
160     int32_t errCode = static_cast<int32_t>(StageRes::STAGE_SUCC);
161     DpRadarHelper::GetInstance().ReportPutCharProfileBatch(errCode, characteristicProfiles);
162     errCode = static_cast<int32_t>(StageRes::STAGE_FAIL);
163     DpRadarHelper::GetInstance().ReportPutCharProfileBatch(errCode, characteristicProfiles);
164     std::vector<TrustDeviceProfile> trustDeviceProfiles;
165     std::string res = DpRadarHelper::GetInstance().GetPeerUdidList(trustDeviceProfiles);
166     EXPECT_EQ(res, "");
167 }
168 
169 HWTEST_F(DpRadarHelperTest, ReportGetDeviceProfile_001, testing::ext::TestSize.Level0)
170 {
171     std::string deviceId = "";
172     DeviceProfile deviceProfile;
173     int32_t errCode = static_cast<int32_t>(StageRes::STAGE_SUCC);
174     DpRadarHelper::GetInstance().ReportGetDeviceProfile(errCode, deviceId, deviceProfile);
175     errCode = static_cast<int32_t>(StageRes::STAGE_FAIL);
176     DpRadarHelper::GetInstance().ReportGetDeviceProfile(errCode, deviceId, deviceProfile);
177 
178     std::vector<TrustDeviceProfile> trustDeviceProfiles;
179     std::string res = DpRadarHelper::GetInstance().GetPeerUdidList(trustDeviceProfiles);
180     EXPECT_EQ(res, "");
181 }
182 
183 HWTEST_F(DpRadarHelperTest, ReportGetServiceProfile_001, testing::ext::TestSize.Level0)
184 {
185     std::string deviceId = "";
186     ServiceProfile serviceProfile;
187     int32_t errCode = static_cast<int32_t>(StageRes::STAGE_SUCC);
188     DpRadarHelper::GetInstance().ReportGetServiceProfile(errCode, deviceId, serviceProfile);
189     errCode = static_cast<int32_t>(StageRes::STAGE_FAIL);
190     DpRadarHelper::GetInstance().ReportGetServiceProfile(errCode, deviceId, serviceProfile);
191     std::vector<TrustDeviceProfile> trustDeviceProfiles;
192     std::string res = DpRadarHelper::GetInstance().GetPeerUdidList(trustDeviceProfiles);
193     EXPECT_EQ(res, "");
194 }
195 
196 HWTEST_F(DpRadarHelperTest, ReportGetChProfile_001, testing::ext::TestSize.Level0)
197 {
198     std::string deviceId = "";
199     CharacteristicProfile characteristicProfile;
200     int32_t errCode = static_cast<int32_t>(StageRes::STAGE_SUCC);
201     DpRadarHelper::GetInstance().ReportGetCharProfile(errCode, deviceId, characteristicProfile);
202     errCode = static_cast<int32_t>(StageRes::STAGE_FAIL);
203     DpRadarHelper::GetInstance().ReportGetCharProfile(errCode, deviceId, characteristicProfile);
204     std::vector<TrustDeviceProfile> trustDeviceProfiles;
205     std::string res = DpRadarHelper::GetInstance().GetPeerUdidList(trustDeviceProfiles);
206     EXPECT_EQ(res, "");
207 }
208 
209 HWTEST_F(DpRadarHelperTest, ReportDeleteServiceProfile_001, testing::ext::TestSize.Level0)
210 {
211     std::string deviceId = "";
212     int32_t errCode = static_cast<int32_t>(StageRes::STAGE_SUCC);
213     DpRadarHelper::GetInstance().ReportDeleteServiceProfile(errCode, deviceId);
214     errCode = static_cast<int32_t>(StageRes::STAGE_FAIL);
215     DpRadarHelper::GetInstance().ReportDeleteServiceProfile(errCode, deviceId);
216     std::vector<TrustDeviceProfile> trustDeviceProfiles;
217     std::string res = DpRadarHelper::GetInstance().GetPeerUdidList(trustDeviceProfiles);
218     EXPECT_EQ(res, "");
219 }
220 
221 HWTEST_F(DpRadarHelperTest, ReportDeleteChProfile_001, testing::ext::TestSize.Level0)
222 {
223     std::string deviceId = "";
224     int32_t errCode = static_cast<int32_t>(StageRes::STAGE_SUCC);
225     DpRadarHelper::GetInstance().ReportDeleteCharProfile(errCode, deviceId);
226     errCode = static_cast<int32_t>(StageRes::STAGE_FAIL);
227     DpRadarHelper::GetInstance().ReportDeleteCharProfile(errCode, deviceId);
228     std::vector<TrustDeviceProfile> trustDeviceProfiles;
229     std::string res = DpRadarHelper::GetInstance().GetPeerUdidList(trustDeviceProfiles);
230     EXPECT_EQ(res, "");
231 }
232 
233 HWTEST_F(DpRadarHelperTest, ReportSubscribeDeviceProfile_001, testing::ext::TestSize.Level0)
234 {
235     SubscribeInfo subscribeInfo;
236     int32_t errCode = static_cast<int32_t>(StageRes::STAGE_SUCC);
237     DpRadarHelper::GetInstance().ReportSubscribeDeviceProfile(errCode, subscribeInfo);
238     errCode = static_cast<int32_t>(StageRes::STAGE_FAIL);
239     DpRadarHelper::GetInstance().ReportSubscribeDeviceProfile(errCode, subscribeInfo);
240     std::vector<TrustDeviceProfile> trustDeviceProfiles;
241     std::string res = DpRadarHelper::GetInstance().GetPeerUdidList(trustDeviceProfiles);
242     EXPECT_EQ(res, "");
243 }
244 
245 HWTEST_F(DpRadarHelperTest, ReportUnSubscribeDeviceProfile_001, testing::ext::TestSize.Level0)
246 {
247     SubscribeInfo subscribeInfo;
248     int32_t errCode = static_cast<int32_t>(StageRes::STAGE_SUCC);
249     DpRadarHelper::GetInstance().ReportUnSubscribeDeviceProfile(errCode, subscribeInfo);
250     errCode = static_cast<int32_t>(StageRes::STAGE_FAIL);
251     DpRadarHelper::GetInstance().ReportUnSubscribeDeviceProfile(errCode, subscribeInfo);
252     std::vector<TrustDeviceProfile> trustDeviceProfiles;
253     std::string res = DpRadarHelper::GetInstance().GetPeerUdidList(trustDeviceProfiles);
254     EXPECT_EQ(res, "");
255 }
256 
257 HWTEST_F(DpRadarHelperTest, ReportSyncDeviceProfile_001, testing::ext::TestSize.Level0)
258 {
259     int32_t errCode = static_cast<int32_t>(StageRes::STAGE_SUCC);
260     DpRadarHelper::GetInstance().ReportSyncDeviceProfile(errCode);
261     errCode = static_cast<int32_t>(StageRes::STAGE_FAIL);
262     DpRadarHelper::GetInstance().ReportSyncDeviceProfile(errCode);
263     std::vector<TrustDeviceProfile> trustDeviceProfiles;
264     std::string res = DpRadarHelper::GetInstance().GetPeerUdidList(trustDeviceProfiles);
265     EXPECT_EQ(res, "");
266 }
267 
268 HWTEST_F(DpRadarHelperTest, ReportNotifyProfileChange_001, testing::ext::TestSize.Level0)
269 {
270     int32_t code = ProfileType::DEVICE_PROFILE * ChangeType::ADD;
271     DpRadarHelper::GetInstance().ReportNotifyProfileChange(code);
272     code = ProfileType::DEVICE_PROFILE * ChangeType::UPDATE;
273     DpRadarHelper::GetInstance().ReportNotifyProfileChange(code);
274     code = ProfileType::DEVICE_PROFILE * ChangeType::DELETE;
275     DpRadarHelper::GetInstance().ReportNotifyProfileChange(code);
276     code = ProfileType::SERVICE_PROFILE * ChangeType::ADD;
277     DpRadarHelper::GetInstance().ReportNotifyProfileChange(code);
278     code = ProfileType::SERVICE_PROFILE * ChangeType::UPDATE;
279     DpRadarHelper::GetInstance().ReportNotifyProfileChange(code);
280     code = ProfileType::SERVICE_PROFILE * ChangeType::DELETE;
281     DpRadarHelper::GetInstance().ReportNotifyProfileChange(code);
282     code = ProfileType::CHAR_PROFILE * ChangeType::ADD;
283     DpRadarHelper::GetInstance().ReportNotifyProfileChange(code);
284     code = ProfileType::CHAR_PROFILE * ChangeType::UPDATE;
285     DpRadarHelper::GetInstance().ReportNotifyProfileChange(code);
286     code = ProfileType::CHAR_PROFILE * ChangeType::DELETE;
287     DpRadarHelper::GetInstance().ReportNotifyProfileChange(code);
288     std::vector<TrustDeviceProfile> trustDeviceProfiles;
289     std::string res = DpRadarHelper::GetInstance().GetPeerUdidList(trustDeviceProfiles);
290     EXPECT_EQ(res, "");
291 }
292 
293 HWTEST_F(DpRadarHelperTest, GetPeerUdidList_001, testing::ext::TestSize.Level0)
294 {
295     std::vector<TrustDeviceProfile> trustDeviceProfiles;
296     std::string res = DpRadarHelper::GetInstance().GetPeerUdidList(trustDeviceProfiles);
297     EXPECT_EQ(res, "");
298 }
299 
300 HWTEST_F(DpRadarHelperTest, GetAnonyUdid_001, testing::ext::TestSize.Level0)
301 {
302     std::string udid = "";
303     std::string res = DpRadarHelper::GetInstance().GetAnonyUdid(udid);
304     EXPECT_EQ(res, "");
305 }
306 
307 HWTEST_F(DpRadarHelperTest, GetAnonyUdid_002, testing::ext::TestSize.Level0)
308 {
309     std::string udid = "123456";
310     std::string res = DpRadarHelper::GetInstance().GetAnonyUdid(udid);
311     EXPECT_EQ(res, "");
312 }
313 
314 HWTEST_F(DpRadarHelperTest, GetAnonyUdid_003, testing::ext::TestSize.Level0)
315 {
316     std::string udid = "12345678910";
317     std::string res = DpRadarHelper::GetInstance().GetAnonyUdid(udid);
318     EXPECT_EQ(res, "12345**78910");
319 }
320 } // namespace DistributedDeviceProfile
321 } // namespace OHOS
322