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 "UTTest_dm_deviceprofile_connector.h"
17
18 #include "dm_constants.h"
19 #include "deviceprofile_connector.h"
20
21 namespace OHOS {
22 namespace DistributedHardware {
SetUp()23 void DeviceProfileConnectorTest::SetUp()
24 {
25 }
26
TearDown()27 void DeviceProfileConnectorTest::TearDown()
28 {
29 }
30
SetUpTestCase()31 void DeviceProfileConnectorTest::SetUpTestCase()
32 {
33 }
34
TearDownTestCase()35 void DeviceProfileConnectorTest::TearDownTestCase()
36 {
37 }
38
HWTEST_F(DeviceProfileConnectorTest, GetAccessControlProfile_001, testing::ext::TestSize.Level0)39 HWTEST_F(DeviceProfileConnectorTest, GetAccessControlProfile_001, testing::ext::TestSize.Level0)
40 {
41 auto ret = DeviceProfileConnector::GetInstance().GetAccessControlProfile();
42 EXPECT_EQ(ret.empty(), false);
43 }
44
HWTEST_F(DeviceProfileConnectorTest, GetAppTrustDeviceList_001, testing::ext::TestSize.Level0)45 HWTEST_F(DeviceProfileConnectorTest, GetAppTrustDeviceList_001, testing::ext::TestSize.Level0)
46 {
47 std::string pkgName;
48 std::string deviceId = "deviceId";
49 auto ret = DeviceProfileConnector::GetInstance().GetAppTrustDeviceList(pkgName, deviceId);
50 EXPECT_EQ(ret.empty(), true);
51 }
52
HWTEST_F(DeviceProfileConnectorTest, GetAppTrustDeviceList_002, testing::ext::TestSize.Level0)53 HWTEST_F(DeviceProfileConnectorTest, GetAppTrustDeviceList_002, testing::ext::TestSize.Level0)
54 {
55 std::string pkgName = "bundleName";
56 std::string deviceId = "deviceId";
57 auto ret = DeviceProfileConnector::GetInstance().GetAppTrustDeviceList(pkgName, deviceId);
58 EXPECT_EQ(ret.empty(), true);
59 }
60
HWTEST_F(DeviceProfileConnectorTest, GetDeviceAclParam_001, testing::ext::TestSize.Level0)61 HWTEST_F(DeviceProfileConnectorTest, GetDeviceAclParam_001, testing::ext::TestSize.Level0)
62 {
63 DmDiscoveryInfo discoveryInfo;
64 bool isonline = true;
65 int32_t authForm = 0;
66 int32_t ret = DeviceProfileConnector::GetInstance().GetDeviceAclParam(discoveryInfo, isonline, authForm);
67 EXPECT_EQ(ret, DM_OK);
68 }
69
HWTEST_F(DeviceProfileConnectorTest, HandleDmAuthForm_001, testing::ext::TestSize.Level0)70 HWTEST_F(DeviceProfileConnectorTest, HandleDmAuthForm_001, testing::ext::TestSize.Level0)
71 {
72 DistributedDeviceProfile::AccessControlProfile profiles;
73 profiles.SetBindType(DM_IDENTICAL_ACCOUNT);
74 DmDiscoveryInfo discoveryInfo;
75 int32_t ret = DeviceProfileConnector::GetInstance().HandleDmAuthForm(profiles, discoveryInfo);
76 EXPECT_EQ(ret, IDENTICAL_ACCOUNT);
77 }
78
HWTEST_F(DeviceProfileConnectorTest, HandleDmAuthForm_002, testing::ext::TestSize.Level0)79 HWTEST_F(DeviceProfileConnectorTest, HandleDmAuthForm_002, testing::ext::TestSize.Level0)
80 {
81 DistributedDeviceProfile::AccessControlProfile profiles;
82 profiles.SetBindType(DM_POINT_TO_POINT);
83 profiles.SetBindLevel(DEVICE);
84 DmDiscoveryInfo discoveryInfo;
85 int32_t ret = DeviceProfileConnector::GetInstance().HandleDmAuthForm(profiles, discoveryInfo);
86 EXPECT_EQ(ret, PEER_TO_PEER);
87 }
88
HWTEST_F(DeviceProfileConnectorTest, HandleDmAuthForm_003, testing::ext::TestSize.Level0)89 HWTEST_F(DeviceProfileConnectorTest, HandleDmAuthForm_003, testing::ext::TestSize.Level0)
90 {
91 DistributedDeviceProfile::AccessControlProfile profiles;
92 profiles.SetBindType(DM_POINT_TO_POINT);
93 profiles.SetBindLevel(APP);
94 profiles.accesser_.SetAccesserBundleName("ohos_test");
95 profiles.accesser_.SetAccesserDeviceId("localDeviceId");
96 DmDiscoveryInfo discoveryInfo;
97 discoveryInfo.pkgname = "ohos_test";
98 discoveryInfo.localDeviceId = "localDeviceId";
99 int32_t ret = DeviceProfileConnector::GetInstance().HandleDmAuthForm(profiles, discoveryInfo);
100 EXPECT_EQ(ret, PEER_TO_PEER);
101 }
102
HWTEST_F(DeviceProfileConnectorTest, HandleDmAuthForm_004, testing::ext::TestSize.Level0)103 HWTEST_F(DeviceProfileConnectorTest, HandleDmAuthForm_004, testing::ext::TestSize.Level0)
104 {
105 DistributedDeviceProfile::AccessControlProfile profiles;
106 profiles.SetBindType(DM_POINT_TO_POINT);
107 profiles.SetBindLevel(APP);
108 profiles.accessee_.SetAccesseeBundleName("ohos_test");
109 profiles.accessee_.SetAccesseeDeviceId("localDeviceId");
110 DmDiscoveryInfo discoveryInfo;
111 discoveryInfo.pkgname = "ohos_test";
112 discoveryInfo.localDeviceId = "localDeviceId";
113 int32_t ret = DeviceProfileConnector::GetInstance().HandleDmAuthForm(profiles, discoveryInfo);
114 EXPECT_EQ(ret, PEER_TO_PEER);
115 }
116
HWTEST_F(DeviceProfileConnectorTest, HandleDmAuthForm_005, testing::ext::TestSize.Level0)117 HWTEST_F(DeviceProfileConnectorTest, HandleDmAuthForm_005, testing::ext::TestSize.Level0)
118 {
119 DistributedDeviceProfile::AccessControlProfile profiles;
120 profiles.SetBindType(DM_ACROSS_ACCOUNT);
121 profiles.SetBindLevel(DEVICE);
122 DmDiscoveryInfo discoveryInfo;
123 int32_t ret = DeviceProfileConnector::GetInstance().HandleDmAuthForm(profiles, discoveryInfo);
124 EXPECT_EQ(ret, ACROSS_ACCOUNT);
125 }
126
HWTEST_F(DeviceProfileConnectorTest, HandleDmAuthForm_006, testing::ext::TestSize.Level0)127 HWTEST_F(DeviceProfileConnectorTest, HandleDmAuthForm_006, testing::ext::TestSize.Level0)
128 {
129 DistributedDeviceProfile::AccessControlProfile profiles;
130 profiles.SetBindType(DM_ACROSS_ACCOUNT);
131 profiles.SetBindLevel(APP);
132 profiles.accesser_.SetAccesserBundleName("pkgName");
133 profiles.accesser_.SetAccesserDeviceId("localDeviceId");
134 DmDiscoveryInfo discoveryInfo;
135 discoveryInfo.pkgname = "pkgName";
136 discoveryInfo.localDeviceId = "localDeviceId";
137 int32_t ret = DeviceProfileConnector::GetInstance().HandleDmAuthForm(profiles, discoveryInfo);
138 EXPECT_EQ(ret, ACROSS_ACCOUNT);
139 }
140
HWTEST_F(DeviceProfileConnectorTest, HandleDmAuthForm_007, testing::ext::TestSize.Level0)141 HWTEST_F(DeviceProfileConnectorTest, HandleDmAuthForm_007, testing::ext::TestSize.Level0)
142 {
143 DistributedDeviceProfile::AccessControlProfile profiles;
144 profiles.SetBindType(DM_ACROSS_ACCOUNT);
145 profiles.SetBindLevel(APP);
146 profiles.accessee_.SetAccesseeBundleName("pkgName");
147 profiles.accessee_.SetAccesseeDeviceId("localDeviceId");
148 DmDiscoveryInfo discoveryInfo;
149 discoveryInfo.pkgname = "pkgName";
150 discoveryInfo.localDeviceId = "localDeviceId";
151 int32_t ret = DeviceProfileConnector::GetInstance().HandleDmAuthForm(profiles, discoveryInfo);
152 EXPECT_EQ(ret, ACROSS_ACCOUNT);
153 }
154
HWTEST_F(DeviceProfileConnectorTest, HandleDmAuthForm_008, testing::ext::TestSize.Level0)155 HWTEST_F(DeviceProfileConnectorTest, HandleDmAuthForm_008, testing::ext::TestSize.Level0)
156 {
157 DistributedDeviceProfile::AccessControlProfile profiles;
158 uint32_t invalidType = 10;
159 profiles.SetBindType(invalidType);
160 DmDiscoveryInfo discoveryInfo;
161 int32_t ret = DeviceProfileConnector::GetInstance().HandleDmAuthForm(profiles, discoveryInfo);
162 EXPECT_EQ(ret, INVALID_TYPE);
163 }
164
HWTEST_F(DeviceProfileConnectorTest, CheckBindType_001, testing::ext::TestSize.Level0)165 HWTEST_F(DeviceProfileConnectorTest, CheckBindType_001, testing::ext::TestSize.Level0)
166 {
167 std::string trustDeviceId = "trustDeviceId";
168 std::string requestDeviceId = "requestDeviceId";
169 uint32_t ret = DeviceProfileConnector::GetInstance().CheckBindType(trustDeviceId, requestDeviceId);
170 EXPECT_EQ(ret, INVALIED_TYPE);
171 }
172
HWTEST_F(DeviceProfileConnectorTest, CheckBindType_002, testing::ext::TestSize.Level0)173 HWTEST_F(DeviceProfileConnectorTest, CheckBindType_002, testing::ext::TestSize.Level0)
174 {
175 std::string trustDeviceId = "deviceId";
176 std::string requestDeviceId = "requestDeviceId";
177 uint32_t ret = DeviceProfileConnector::GetInstance().CheckBindType(trustDeviceId, requestDeviceId);
178 EXPECT_EQ(ret, IDENTICAL_ACCOUNT_TYPE);
179 }
180
HWTEST_F(DeviceProfileConnectorTest, CheckBindType_003, testing::ext::TestSize.Level0)181 HWTEST_F(DeviceProfileConnectorTest, CheckBindType_003, testing::ext::TestSize.Level0)
182 {
183 std::string trustDeviceId = "deviceId";
184 std::string requestDeviceId = "deviceId";
185 uint32_t ret = DeviceProfileConnector::GetInstance().CheckBindType(trustDeviceId, requestDeviceId);
186 EXPECT_EQ(ret, IDENTICAL_ACCOUNT_TYPE);
187 }
188
HWTEST_F(DeviceProfileConnectorTest, GetBindTypeByPkgName_001, testing::ext::TestSize.Level0)189 HWTEST_F(DeviceProfileConnectorTest, GetBindTypeByPkgName_001, testing::ext::TestSize.Level0)
190 {
191 std::string pkgName;
192 std::string requestDeviceId;
193 std::string trustUdid;
194 auto ret = DeviceProfileConnector::GetInstance().GetBindTypeByPkgName(pkgName, requestDeviceId, trustUdid);
195 EXPECT_EQ(ret.empty(), true);
196 }
197
HWTEST_F(DeviceProfileConnectorTest, GetParamBindTypeVec_001, testing::ext::TestSize.Level0)198 HWTEST_F(DeviceProfileConnectorTest, GetParamBindTypeVec_001, testing::ext::TestSize.Level0)
199 {
200 DistributedDeviceProfile::AccessControlProfile profiles;
201 profiles.SetBindType(DM_IDENTICAL_ACCOUNT);
202 std::string pkgName;
203 std::string requestDeviceId;
204 std::vector<int32_t> bindTypeVec;
205 DeviceProfileConnector::GetInstance().GetParamBindTypeVec(profiles, pkgName, requestDeviceId, bindTypeVec);
206 EXPECT_EQ(bindTypeVec.empty(), false);
207 }
208
HWTEST_F(DeviceProfileConnectorTest, GetParamBindTypeVec_002, testing::ext::TestSize.Level0)209 HWTEST_F(DeviceProfileConnectorTest, GetParamBindTypeVec_002, testing::ext::TestSize.Level0)
210 {
211 DistributedDeviceProfile::AccessControlProfile profiles;
212 profiles.SetBindType(DM_POINT_TO_POINT);
213 profiles.SetBindLevel(DEVICE);
214 std::string pkgName;
215 std::string requestDeviceId;
216 std::vector<int32_t> bindTypeVec;
217 DeviceProfileConnector::GetInstance().GetParamBindTypeVec(profiles, pkgName, requestDeviceId, bindTypeVec);
218 EXPECT_EQ(bindTypeVec.empty(), false);
219 }
220
HWTEST_F(DeviceProfileConnectorTest, GetParamBindTypeVec_003, testing::ext::TestSize.Level0)221 HWTEST_F(DeviceProfileConnectorTest, GetParamBindTypeVec_003, testing::ext::TestSize.Level0)
222 {
223 DistributedDeviceProfile::AccessControlProfile profiles;
224 profiles.SetBindType(DM_POINT_TO_POINT);
225 profiles.SetBindLevel(APP);
226 profiles.accesser_.SetAccesserBundleName("pkgName");
227 profiles.accesser_.SetAccesserDeviceId("localDeviceId");
228 std::string pkgName = "pkgName";
229 std::string requestDeviceId = "localDeviceId";
230 std::vector<int32_t> bindTypeVec;
231 DeviceProfileConnector::GetInstance().GetParamBindTypeVec(profiles, pkgName, requestDeviceId, bindTypeVec);
232 EXPECT_EQ(bindTypeVec.empty(), false);
233 }
234
HWTEST_F(DeviceProfileConnectorTest, GetParamBindTypeVec_004, testing::ext::TestSize.Level0)235 HWTEST_F(DeviceProfileConnectorTest, GetParamBindTypeVec_004, testing::ext::TestSize.Level0)
236 {
237 DistributedDeviceProfile::AccessControlProfile profiles;
238 profiles.SetBindType(DM_POINT_TO_POINT);
239 profiles.SetBindLevel(APP);
240 profiles.accessee_.SetAccesseeBundleName("pkgName");
241 profiles.accessee_.SetAccesseeDeviceId("localDeviceId");
242 std::string pkgName = "pkgName";
243 std::string requestDeviceId = "localDeviceId";
244 std::vector<int32_t> bindTypeVec;
245 DeviceProfileConnector::GetInstance().GetParamBindTypeVec(profiles, pkgName, requestDeviceId, bindTypeVec);
246 EXPECT_EQ(bindTypeVec.empty(), false);
247 }
248
HWTEST_F(DeviceProfileConnectorTest, GetParamBindTypeVec_005, testing::ext::TestSize.Level0)249 HWTEST_F(DeviceProfileConnectorTest, GetParamBindTypeVec_005, testing::ext::TestSize.Level0)
250 {
251 DistributedDeviceProfile::AccessControlProfile profiles;
252 profiles.SetBindType(DM_ACROSS_ACCOUNT);
253 profiles.SetBindLevel(DEVICE);
254 std::string pkgName;
255 std::string requestDeviceId;
256 std::vector<int32_t> bindTypeVec;
257 DeviceProfileConnector::GetInstance().GetParamBindTypeVec(profiles, pkgName, requestDeviceId, bindTypeVec);
258 EXPECT_EQ(bindTypeVec.empty(), false);
259 }
260
HWTEST_F(DeviceProfileConnectorTest, GetParamBindTypeVec_006, testing::ext::TestSize.Level0)261 HWTEST_F(DeviceProfileConnectorTest, GetParamBindTypeVec_006, testing::ext::TestSize.Level0)
262 {
263 DistributedDeviceProfile::AccessControlProfile profiles;
264 profiles.SetBindType(DM_ACROSS_ACCOUNT);
265 profiles.SetBindLevel(APP);
266 profiles.accesser_.SetAccesserBundleName("pkgName");
267 profiles.accesser_.SetAccesserDeviceId("localDeviceId");
268 std::string pkgName = "pkgName";
269 std::string requestDeviceId = "localDeviceId";
270 std::vector<int32_t> bindTypeVec;
271 DeviceProfileConnector::GetInstance().GetParamBindTypeVec(profiles, pkgName, requestDeviceId, bindTypeVec);
272 EXPECT_EQ(bindTypeVec.empty(), false);
273 }
274
HWTEST_F(DeviceProfileConnectorTest, GetParamBindTypeVec_007, testing::ext::TestSize.Level0)275 HWTEST_F(DeviceProfileConnectorTest, GetParamBindTypeVec_007, testing::ext::TestSize.Level0)
276 {
277 DistributedDeviceProfile::AccessControlProfile profiles;
278 profiles.SetBindType(DM_ACROSS_ACCOUNT);
279 profiles.SetBindLevel(APP);
280 profiles.accessee_.SetAccesseeBundleName("pkgName");
281 profiles.accessee_.SetAccesseeDeviceId("localDeviceId");
282 std::string pkgName = "pkgName";
283 std::string requestDeviceId = "localDeviceId";
284 std::vector<int32_t> bindTypeVec;
285 DeviceProfileConnector::GetInstance().GetParamBindTypeVec(profiles, pkgName, requestDeviceId, bindTypeVec);
286 EXPECT_EQ(bindTypeVec.empty(), false);
287 }
288
HWTEST_F(DeviceProfileConnectorTest, CompareBindType_001, testing::ext::TestSize.Level0)289 HWTEST_F(DeviceProfileConnectorTest, CompareBindType_001, testing::ext::TestSize.Level0)
290 {
291 DistributedDeviceProfile::AccessControlProfile profile;
292 profile.SetTrustDeviceId("deviceId");
293 profile.SetStatus(INACTIVE);
294 std::vector<DistributedDeviceProfile::AccessControlProfile> profiles;
295 profiles.push_back(profile);
296 std::string pkgName;
297 std::vector<int32_t> sinkBindType;
298 std::string localDeviceId;
299 std::string targetDeviceId = "targetDeviceId";
300 auto ret = DeviceProfileConnector::GetInstance().CompareBindType(profiles, pkgName, sinkBindType, localDeviceId,
301 targetDeviceId);
302 EXPECT_EQ(ret.empty(), true);
303 }
304
HWTEST_F(DeviceProfileConnectorTest, CompareBindType_002, testing::ext::TestSize.Level0)305 HWTEST_F(DeviceProfileConnectorTest, CompareBindType_002, testing::ext::TestSize.Level0)
306 {
307 DistributedDeviceProfile::AccessControlProfile profile;
308 profile.SetTrustDeviceId("targetDeviceId");
309 profile.SetStatus(ACTIVE);
310 std::vector<DistributedDeviceProfile::AccessControlProfile> profiles;
311 profiles.push_back(profile);
312 std::string pkgName;
313 std::vector<int32_t> sinkBindType;
314 std::string localDeviceId;
315 std::string targetDeviceId = "targetDeviceId";
316 auto ret = DeviceProfileConnector::GetInstance().CompareBindType(profiles, pkgName, sinkBindType, localDeviceId,
317 targetDeviceId);
318 EXPECT_EQ(ret.empty(), true);
319 }
320
HWTEST_F(DeviceProfileConnectorTest, CompareBindType_003, testing::ext::TestSize.Level0)321 HWTEST_F(DeviceProfileConnectorTest, CompareBindType_003, testing::ext::TestSize.Level0)
322 {
323 DistributedDeviceProfile::AccessControlProfile profile;
324 profile.SetTrustDeviceId("targetDeviceId");
325 profile.SetStatus(INACTIVE);
326 std::vector<DistributedDeviceProfile::AccessControlProfile> profiles;
327 profiles.push_back(profile);
328 std::string pkgName;
329 std::vector<int32_t> sinkBindType;
330 std::string localDeviceId;
331 std::string targetDeviceId = "targetDeviceId";
332 auto ret = DeviceProfileConnector::GetInstance().CompareBindType(profiles, pkgName, sinkBindType, localDeviceId,
333 targetDeviceId);
334 EXPECT_EQ(ret.empty(), true);
335 }
336
HWTEST_F(DeviceProfileConnectorTest, ProcessBindType_001, testing::ext::TestSize.Level0)337 HWTEST_F(DeviceProfileConnectorTest, ProcessBindType_001, testing::ext::TestSize.Level0)
338 {
339 DistributedDeviceProfile::AccessControlProfile profiles;
340 profiles.SetBindType(DM_IDENTICAL_ACCOUNT);
341 DmDiscoveryInfo paramInfo;
342 std::vector<int32_t> sinkBindType;
343 std::vector<int32_t> bindTypeIndex;
344 uint32_t index = 0;
345 DeviceProfileConnector::GetInstance().ProcessBindType(profiles, paramInfo, sinkBindType, bindTypeIndex, index);
346 EXPECT_EQ(sinkBindType.empty(), false);
347 }
348
HWTEST_F(DeviceProfileConnectorTest, ProcessBindType_002, testing::ext::TestSize.Level0)349 HWTEST_F(DeviceProfileConnectorTest, ProcessBindType_002, testing::ext::TestSize.Level0)
350 {
351 DistributedDeviceProfile::AccessControlProfile profiles;
352 profiles.SetBindType(DM_POINT_TO_POINT);
353 profiles.SetBindLevel(DEVICE);
354 DmDiscoveryInfo paramInfo;
355 std::vector<int32_t> sinkBindType;
356 std::vector<int32_t> bindTypeIndex;
357 uint32_t index = 0;
358 DeviceProfileConnector::GetInstance().ProcessBindType(profiles, paramInfo, sinkBindType, bindTypeIndex, index);
359 EXPECT_EQ(sinkBindType.empty(), false);
360 }
361
HWTEST_F(DeviceProfileConnectorTest, ProcessBindType_003, testing::ext::TestSize.Level0)362 HWTEST_F(DeviceProfileConnectorTest, ProcessBindType_003, testing::ext::TestSize.Level0)
363 {
364 DistributedDeviceProfile::AccessControlProfile profiles;
365 profiles.SetBindType(DM_POINT_TO_POINT);
366 profiles.SetBindLevel(APP);
367 profiles.accesser_.SetAccesserBundleName("pkgName");
368 profiles.accesser_.SetAccesserDeviceId("localDeviceId");
369 DmDiscoveryInfo paramInfo;
370 paramInfo.pkgname = "pkgName";
371 paramInfo.localDeviceId = "localDeviceId";
372 std::vector<int32_t> sinkBindType;
373 std::vector<int32_t> bindTypeIndex;
374 uint32_t index = 0;
375 DeviceProfileConnector::GetInstance().ProcessBindType(profiles, paramInfo, sinkBindType, bindTypeIndex, index);
376 EXPECT_EQ(sinkBindType.empty(), false);
377 }
378
HWTEST_F(DeviceProfileConnectorTest, ProcessBindType_004, testing::ext::TestSize.Level0)379 HWTEST_F(DeviceProfileConnectorTest, ProcessBindType_004, testing::ext::TestSize.Level0)
380 {
381 DistributedDeviceProfile::AccessControlProfile profiles;
382 profiles.SetBindType(DM_POINT_TO_POINT);
383 profiles.SetBindLevel(APP);
384 profiles.accessee_.SetAccesseeBundleName("pkgName");
385 profiles.accessee_.SetAccesseeDeviceId("localDeviceId");
386 DmDiscoveryInfo paramInfo;
387 paramInfo.pkgname = "pkgName";
388 paramInfo.localDeviceId = "localDeviceId";
389 std::vector<int32_t> sinkBindType;
390 std::vector<int32_t> bindTypeIndex;
391 uint32_t index = 0;
392 DeviceProfileConnector::GetInstance().ProcessBindType(profiles, paramInfo, sinkBindType, bindTypeIndex, index);
393 EXPECT_EQ(sinkBindType.empty(), false);
394 }
395
HWTEST_F(DeviceProfileConnectorTest, ProcessBindType_005, testing::ext::TestSize.Level0)396 HWTEST_F(DeviceProfileConnectorTest, ProcessBindType_005, testing::ext::TestSize.Level0)
397 {
398 DistributedDeviceProfile::AccessControlProfile profiles;
399 profiles.SetBindType(DM_ACROSS_ACCOUNT);
400 profiles.SetBindLevel(DEVICE);
401 DmDiscoveryInfo paramInfo;
402 std::vector<int32_t> sinkBindType;
403 std::vector<int32_t> bindTypeIndex;
404 uint32_t index = 0;
405 DeviceProfileConnector::GetInstance().ProcessBindType(profiles, paramInfo, sinkBindType, bindTypeIndex, index);
406 EXPECT_EQ(sinkBindType.empty(), false);
407 }
408
HWTEST_F(DeviceProfileConnectorTest, ProcessBindType_006, testing::ext::TestSize.Level0)409 HWTEST_F(DeviceProfileConnectorTest, ProcessBindType_006, testing::ext::TestSize.Level0)
410 {
411 DistributedDeviceProfile::AccessControlProfile profiles;
412 profiles.SetBindType(DM_ACROSS_ACCOUNT);
413 profiles.SetBindLevel(APP);
414 profiles.accesser_.SetAccesserBundleName("pkgName");
415 profiles.accesser_.SetAccesserDeviceId("localDeviceId");
416 DmDiscoveryInfo paramInfo;
417 paramInfo.pkgname = "pkgName";
418 paramInfo.localDeviceId = "localDeviceId";
419 std::vector<int32_t> sinkBindType;
420 std::vector<int32_t> bindTypeIndex;
421 uint32_t index = 0;
422 DeviceProfileConnector::GetInstance().ProcessBindType(profiles, paramInfo, sinkBindType, bindTypeIndex, index);
423 EXPECT_EQ(sinkBindType.empty(), false);
424 }
425
HWTEST_F(DeviceProfileConnectorTest, ProcessBindType_007, testing::ext::TestSize.Level0)426 HWTEST_F(DeviceProfileConnectorTest, ProcessBindType_007, testing::ext::TestSize.Level0)
427 {
428 DistributedDeviceProfile::AccessControlProfile profiles;
429 profiles.SetBindType(DM_ACROSS_ACCOUNT);
430 profiles.SetBindLevel(APP);
431 profiles.accessee_.SetAccesseeBundleName("pkgName");
432 profiles.accessee_.SetAccesseeDeviceId("localDeviceId");
433 DmDiscoveryInfo paramInfo;
434 paramInfo.pkgname = "pkgName";
435 paramInfo.localDeviceId = "localDeviceId";
436 std::vector<int32_t> sinkBindType;
437 std::vector<int32_t> bindTypeIndex;
438 uint32_t index = 0;
439 DeviceProfileConnector::GetInstance().ProcessBindType(profiles, paramInfo, sinkBindType, bindTypeIndex, index);
440 EXPECT_EQ(sinkBindType.empty(), false);
441 }
442
HWTEST_F(DeviceProfileConnectorTest, SyncAclByBindType_001, testing::ext::TestSize.Level0)443 HWTEST_F(DeviceProfileConnectorTest, SyncAclByBindType_001, testing::ext::TestSize.Level0)
444 {
445 std::string pkgName;
446 std::vector<int32_t> bindTypeVec;
447 std::string localDeviceId;
448 std::string targetDeviceId;
449 auto ret = DeviceProfileConnector::GetInstance().SyncAclByBindType(pkgName, bindTypeVec, localDeviceId,
450 targetDeviceId);
451 EXPECT_EQ(ret.empty(), true);
452 }
453
HWTEST_F(DeviceProfileConnectorTest, GetPkgNameFromAcl_001, testing::ext::TestSize.Level0)454 HWTEST_F(DeviceProfileConnectorTest, GetPkgNameFromAcl_001, testing::ext::TestSize.Level0)
455 {
456 std::string localDeviceId = "localDeviceId";
457 std::string targetDeviceId = "targetDeviceId";
458 auto ret = DeviceProfileConnector::GetInstance().GetPkgNameFromAcl(localDeviceId, targetDeviceId);
459 EXPECT_EQ(ret.empty(), true);
460 }
461
HWTEST_F(DeviceProfileConnectorTest, GetPkgNameFromAcl_002, testing::ext::TestSize.Level0)462 HWTEST_F(DeviceProfileConnectorTest, GetPkgNameFromAcl_002, testing::ext::TestSize.Level0)
463 {
464 std::string localDeviceId = "123456";
465 std::string targetDeviceId = "deviceId";
466 auto ret = DeviceProfileConnector::GetInstance().GetPkgNameFromAcl(localDeviceId, targetDeviceId);
467 EXPECT_EQ(ret.empty(), true);
468 }
469
HWTEST_F(DeviceProfileConnectorTest, GetPkgNameFromAcl_003, testing::ext::TestSize.Level0)470 HWTEST_F(DeviceProfileConnectorTest, GetPkgNameFromAcl_003, testing::ext::TestSize.Level0)
471 {
472 std::string localDeviceId = "deviceId";
473 std::string targetDeviceId = "deviceId";
474 auto ret = DeviceProfileConnector::GetInstance().GetPkgNameFromAcl(localDeviceId, targetDeviceId);
475 EXPECT_EQ(ret.empty(), false);
476 }
477
HWTEST_F(DeviceProfileConnectorTest, GetOfflineParamFromAcl_001, testing::ext::TestSize.Level0)478 HWTEST_F(DeviceProfileConnectorTest, GetOfflineParamFromAcl_001, testing::ext::TestSize.Level0)
479 {
480 std::string trustDeviceId = "trustDeviceId";
481 std::string requestDeviceId = "deviceId";
482 auto ret = DeviceProfileConnector::GetInstance().GetOfflineParamFromAcl(trustDeviceId, requestDeviceId);
483 EXPECT_EQ(ret.bindType, INVALIED_TYPE);
484 }
485
HWTEST_F(DeviceProfileConnectorTest, GetOfflineParamFromAcl_002, testing::ext::TestSize.Level0)486 HWTEST_F(DeviceProfileConnectorTest, GetOfflineParamFromAcl_002, testing::ext::TestSize.Level0)
487 {
488 std::string trustDeviceId = "123456";
489 std::string requestDeviceId = "deviceId";
490 auto ret = DeviceProfileConnector::GetInstance().GetOfflineParamFromAcl(trustDeviceId, requestDeviceId);
491 EXPECT_EQ(ret.bindType, INVALIED_TYPE);
492 }
493
HWTEST_F(DeviceProfileConnectorTest, GetOfflineParamFromAcl_003, testing::ext::TestSize.Level0)494 HWTEST_F(DeviceProfileConnectorTest, GetOfflineParamFromAcl_003, testing::ext::TestSize.Level0)
495 {
496 std::string trustDeviceId = "deviceId";
497 std::string requestDeviceId = "deviceId";
498 auto ret = DeviceProfileConnector::GetInstance().GetOfflineParamFromAcl(trustDeviceId, requestDeviceId);
499 EXPECT_EQ(ret.bindType, IDENTICAL_ACCOUNT_TYPE);
500 }
501
HWTEST_F(DeviceProfileConnectorTest, PutAccessControlList_001, testing::ext::TestSize.Level0)502 HWTEST_F(DeviceProfileConnectorTest, PutAccessControlList_001, testing::ext::TestSize.Level0)
503 {
504 DmAclInfo aclInfo;
505 DmAccesser dmAccesser;
506 DmAccessee dmAccessee;
507 int32_t ret = DeviceProfileConnector::GetInstance().PutAccessControlList(aclInfo, dmAccesser, dmAccessee);
508 EXPECT_EQ(ret, DM_OK);
509 }
510
HWTEST_F(DeviceProfileConnectorTest, UpdateAccessControlList_001, testing::ext::TestSize.Level0)511 HWTEST_F(DeviceProfileConnectorTest, UpdateAccessControlList_001, testing::ext::TestSize.Level0)
512 {
513 int32_t userId = 0;
514 std::string oldAccountId;
515 std::string newAccountId;
516 int32_t ret = DeviceProfileConnector::GetInstance().UpdateAccessControlList(userId, oldAccountId, newAccountId);
517 EXPECT_EQ(ret, DM_OK);
518 }
519
HWTEST_F(DeviceProfileConnectorTest, UpdateAccessControlList_002, testing::ext::TestSize.Level0)520 HWTEST_F(DeviceProfileConnectorTest, UpdateAccessControlList_002, testing::ext::TestSize.Level0)
521 {
522 int32_t userId = 123456;
523 std::string oldAccountId = "oldAccountId";
524 std::string newAccountId = "newAccountId";
525 int32_t ret = DeviceProfileConnector::GetInstance().UpdateAccessControlList(userId, oldAccountId, newAccountId);
526 EXPECT_EQ(ret, DM_OK);
527 }
528
HWTEST_F(DeviceProfileConnectorTest, UpdateAccessControlList_003, testing::ext::TestSize.Level0)529 HWTEST_F(DeviceProfileConnectorTest, UpdateAccessControlList_003, testing::ext::TestSize.Level0)
530 {
531 int32_t userId = 123456;
532 std::string oldAccountId = "accountId";
533 std::string newAccountId = "newAccountId";
534 int32_t ret = DeviceProfileConnector::GetInstance().UpdateAccessControlList(userId, oldAccountId, newAccountId);
535 EXPECT_EQ(ret, DM_OK);
536 }
537
HWTEST_F(DeviceProfileConnectorTest, UpdateAccessControlList_004, testing::ext::TestSize.Level0)538 HWTEST_F(DeviceProfileConnectorTest, UpdateAccessControlList_004, testing::ext::TestSize.Level0)
539 {
540 int32_t userId = 123456;
541 std::string oldAccountId = "accountId";
542 std::string newAccountId = "accountId";
543 int32_t ret = DeviceProfileConnector::GetInstance().UpdateAccessControlList(userId, oldAccountId, newAccountId);
544 EXPECT_EQ(ret, DM_OK);
545 }
546
HWTEST_F(DeviceProfileConnectorTest, CheckIdenticalAccount_001, testing::ext::TestSize.Level0)547 HWTEST_F(DeviceProfileConnectorTest, CheckIdenticalAccount_001, testing::ext::TestSize.Level0)
548 {
549 int32_t userId = 0;
550 std::string accountId;
551 bool ret = DeviceProfileConnector::GetInstance().CheckIdenticalAccount(userId, accountId);
552 EXPECT_EQ(ret, true);
553 }
554
HWTEST_F(DeviceProfileConnectorTest, CheckSrcDevIdInAclForDevBind_001, testing::ext::TestSize.Level0)555 HWTEST_F(DeviceProfileConnectorTest, CheckSrcDevIdInAclForDevBind_001, testing::ext::TestSize.Level0)
556 {
557 std::string pkgName;
558 std::string deviceId;
559 bool ret = DeviceProfileConnector::GetInstance().CheckSrcDevIdInAclForDevBind(pkgName, deviceId);
560 EXPECT_EQ(ret, false);
561 }
562
HWTEST_F(DeviceProfileConnectorTest, CheckSrcDevIdInAclForDevBind_002, testing::ext::TestSize.Level0)563 HWTEST_F(DeviceProfileConnectorTest, CheckSrcDevIdInAclForDevBind_002, testing::ext::TestSize.Level0)
564 {
565 std::string pkgName = "bundleName";
566 std::string deviceId = "123456";
567 bool ret = DeviceProfileConnector::GetInstance().CheckSrcDevIdInAclForDevBind(pkgName, deviceId);
568 EXPECT_EQ(ret, false);
569 }
570
HWTEST_F(DeviceProfileConnectorTest, CheckSrcDevIdInAclForDevBind_003, testing::ext::TestSize.Level0)571 HWTEST_F(DeviceProfileConnectorTest, CheckSrcDevIdInAclForDevBind_003, testing::ext::TestSize.Level0)
572 {
573 std::string pkgName = "bundleName";
574 std::string deviceId = "deviceId";
575 bool ret = DeviceProfileConnector::GetInstance().CheckSrcDevIdInAclForDevBind(pkgName, deviceId);
576 EXPECT_EQ(ret, false);
577 }
578
HWTEST_F(DeviceProfileConnectorTest, CheckSinkDevIdInAclForDevBind_001, testing::ext::TestSize.Level0)579 HWTEST_F(DeviceProfileConnectorTest, CheckSinkDevIdInAclForDevBind_001, testing::ext::TestSize.Level0)
580 {
581 std::string pkgName;
582 std::string deviceId;
583 bool ret = DeviceProfileConnector::GetInstance().CheckSinkDevIdInAclForDevBind(pkgName, deviceId);
584 EXPECT_EQ(ret, false);
585 }
586
HWTEST_F(DeviceProfileConnectorTest, CheckSinkDevIdInAclForDevBind_002, testing::ext::TestSize.Level0)587 HWTEST_F(DeviceProfileConnectorTest, CheckSinkDevIdInAclForDevBind_002, testing::ext::TestSize.Level0)
588 {
589 std::string pkgName = "bundleName";
590 std::string deviceId = "123456";
591 bool ret = DeviceProfileConnector::GetInstance().CheckSinkDevIdInAclForDevBind(pkgName, deviceId);
592 EXPECT_EQ(ret, false);
593 }
594
HWTEST_F(DeviceProfileConnectorTest, CheckSinkDevIdInAclForDevBind_003, testing::ext::TestSize.Level0)595 HWTEST_F(DeviceProfileConnectorTest, CheckSinkDevIdInAclForDevBind_003, testing::ext::TestSize.Level0)
596 {
597 std::string pkgName = "bundleName";
598 std::string deviceId = "deviceId";
599 bool ret = DeviceProfileConnector::GetInstance().CheckSinkDevIdInAclForDevBind(pkgName, deviceId);
600 EXPECT_EQ(ret, false);
601 }
602
HWTEST_F(DeviceProfileConnectorTest, CheckDevIdInAclForDevBind_001, testing::ext::TestSize.Level0)603 HWTEST_F(DeviceProfileConnectorTest, CheckDevIdInAclForDevBind_001, testing::ext::TestSize.Level0)
604 {
605 std::string pkgName;
606 std::string deviceId;
607 bool ret = DeviceProfileConnector::GetInstance().CheckDevIdInAclForDevBind(pkgName, deviceId);
608 EXPECT_EQ(ret, false);
609 }
610
HWTEST_F(DeviceProfileConnectorTest, DeleteTimeOutAcl_001, testing::ext::TestSize.Level0)611 HWTEST_F(DeviceProfileConnectorTest, DeleteTimeOutAcl_001, testing::ext::TestSize.Level0)
612 {
613 std::string deviceId;
614 uint32_t ret = DeviceProfileConnector::GetInstance().DeleteTimeOutAcl(deviceId);
615 EXPECT_EQ(ret, 0);
616 }
617
HWTEST_F(DeviceProfileConnectorTest, GetTrustNumber_001, testing::ext::TestSize.Level0)618 HWTEST_F(DeviceProfileConnectorTest, GetTrustNumber_001, testing::ext::TestSize.Level0)
619 {
620 std::string deviceId;
621 int32_t ret = DeviceProfileConnector::GetInstance().GetTrustNumber(deviceId);
622 EXPECT_EQ(ret, DM_OK);
623 }
624
HWTEST_F(DeviceProfileConnectorTest, IsSameAccount_001, testing::ext::TestSize.Level0)625 HWTEST_F(DeviceProfileConnectorTest, IsSameAccount_001, testing::ext::TestSize.Level0)
626 {
627 std::string udid = "udid";
628 int32_t ret = DeviceProfileConnector::GetInstance().IsSameAccount(udid);
629 EXPECT_EQ(ret, ERR_DM_FAILED);
630 }
631
HWTEST_F(DeviceProfileConnectorTest, IsSameAccount_002, testing::ext::TestSize.Level0)632 HWTEST_F(DeviceProfileConnectorTest, IsSameAccount_002, testing::ext::TestSize.Level0)
633 {
634 std::string udid = "deviceId";
635 int32_t ret = DeviceProfileConnector::GetInstance().IsSameAccount(udid);
636 EXPECT_EQ(ret, DM_OK);
637 }
638
HWTEST_F(DeviceProfileConnectorTest, GetAuthForm_001, testing::ext::TestSize.Level0)639 HWTEST_F(DeviceProfileConnectorTest, GetAuthForm_001, testing::ext::TestSize.Level0)
640 {
641 DistributedDeviceProfile::AccessControlProfile profile;
642 std::string trustDev = "";
643 std::string reqDev = "";
644 int32_t ret = DeviceProfileConnector::GetInstance().GetAuthForm(profile, trustDev, reqDev);
645 EXPECT_EQ(ret, INVALIED_TYPE);
646 profile.SetBindType(DM_IDENTICAL_ACCOUNT);
647 ret = DeviceProfileConnector::GetInstance().GetAuthForm(profile, trustDev, reqDev);
648 EXPECT_EQ(ret, IDENTICAL_ACCOUNT_TYPE);
649 profile.SetBindType(DM_POINT_TO_POINT);
650 profile.SetBindLevel(DEVICE);
651 ret = DeviceProfileConnector::GetInstance().GetAuthForm(profile, trustDev, reqDev);
652 EXPECT_EQ(ret, DEVICE_PEER_TO_PEER_TYPE);
653 profile.SetBindType(DM_ACROSS_ACCOUNT);
654 profile.SetBindLevel(DEVICE);
655 ret = DeviceProfileConnector::GetInstance().GetAuthForm(profile, trustDev, reqDev);
656 EXPECT_EQ(ret, DEVICE_ACROSS_ACCOUNT_TYPE);
657 profile.SetBindLevel(APP);
658 ret = DeviceProfileConnector::GetInstance().GetAuthForm(profile, trustDev, reqDev);
659 EXPECT_EQ(ret, APP_ACROSS_ACCOUNT_TYPE);
660 profile.SetBindType(INVALIED_TYPE);
661 ret = DeviceProfileConnector::GetInstance().GetAuthForm(profile, trustDev, reqDev);
662 EXPECT_EQ(ret, INVALIED_TYPE);
663 }
664
HWTEST_F(DeviceProfileConnectorTest, DeleteAccessControlList_001, testing::ext::TestSize.Level0)665 HWTEST_F(DeviceProfileConnectorTest, DeleteAccessControlList_001, testing::ext::TestSize.Level0)
666 {
667 std::string pkgName = "bundleName";
668 std::string localDeviceId = "localDeviceId";
669 std::string remoteDeviceId = "remoteDeviceId";
670 int32_t bindLevel = INVALIED_TYPE;
671
672 DmOfflineParam offlineParam = DeviceProfileConnector::GetInstance()
673 .DeleteAccessControlList(pkgName, localDeviceId, remoteDeviceId, bindLevel);
674
675 EXPECT_EQ(offlineParam.bindType, INVALIED_TYPE);
676 }
677
HWTEST_F(DeviceProfileConnectorTest, DeleteAccessControlList_002, testing::ext::TestSize.Level0)678 HWTEST_F(DeviceProfileConnectorTest, DeleteAccessControlList_002, testing::ext::TestSize.Level0)
679 {
680 std::string pkgName = "bundleName";
681 std::string localDeviceId = "localDeviceId";
682 std::string remoteDeviceId = "remoteDeviceId";
683 int32_t bindLevel = APP;
684
685 DmOfflineParam offlineParam = DeviceProfileConnector::GetInstance()
686 .DeleteAccessControlList(pkgName, localDeviceId, remoteDeviceId, bindLevel);
687
688 EXPECT_EQ(offlineParam.bindType, APP);
689 }
690
HWTEST_F(DeviceProfileConnectorTest, DeleteAccessControlList_003, testing::ext::TestSize.Level0)691 HWTEST_F(DeviceProfileConnectorTest, DeleteAccessControlList_003, testing::ext::TestSize.Level0)
692 {
693 std::string pkgName = "bundleName";
694 std::string localDeviceId = "localDeviceId";
695 std::string remoteDeviceId = "remoteDeviceId";
696 int32_t bindLevel = SERVICE;
697
698 DmOfflineParam offlineParam = DeviceProfileConnector::GetInstance()
699 .DeleteAccessControlList(pkgName, localDeviceId, remoteDeviceId, bindLevel);
700
701 EXPECT_EQ(offlineParam.bindType, SERVICE);
702 }
703
HWTEST_F(DeviceProfileConnectorTest, DeleteAccessControlList_004, testing::ext::TestSize.Level0)704 HWTEST_F(DeviceProfileConnectorTest, DeleteAccessControlList_004, testing::ext::TestSize.Level0)
705 {
706 std::string pkgName = "bundleName";
707 std::string localDeviceId = "localDeviceId";
708 std::string remoteDeviceId = "remoteDeviceId";
709 int32_t bindLevel = DEVICE;
710
711 DmOfflineParam offlineParam = DeviceProfileConnector::GetInstance()
712 .DeleteAccessControlList(pkgName, localDeviceId, remoteDeviceId, bindLevel);
713
714 EXPECT_EQ(offlineParam.bindType, DEVICE);
715 }
716
HWTEST_F(DeviceProfileConnectorTest, GetBindLevel_001, testing::ext::TestSize.Level0)717 HWTEST_F(DeviceProfileConnectorTest, GetBindLevel_001, testing::ext::TestSize.Level0)
718 {
719 std::string pkgName = "bundleName";
720 std::string localUdid = "localDeviceId";
721 std::string udid = "remoteDeviceId";
722 uint64_t tokenId = 0;
723 int32_t bindLevel = INVALIED_TYPE;
724
725 bindLevel = DeviceProfileConnector::GetInstance()
726 .GetBindLevel(pkgName, localUdid, udid, tokenId);
727
728 EXPECT_EQ(bindLevel, DEVICE);
729 }
730
HWTEST_F(DeviceProfileConnectorTest, GetDeviceIdAndBindType_001, testing::ext::TestSize.Level0)731 HWTEST_F(DeviceProfileConnectorTest, GetDeviceIdAndBindType_001, testing::ext::TestSize.Level0)
732 {
733 int32_t userId = 123456;
734 std::string accountId = "oldAccountId";
735 std::string localUdid = "localDeviceId";
736 std::map<std::string, int32_t> deviceIdMap;
737
738 deviceIdMap = DeviceProfileConnector::GetInstance()
739 .GetDeviceIdAndBindType(userId, accountId, localUdid);
740
741 EXPECT_NE(deviceIdMap.size(), 0);
742 }
743
HWTEST_F(DeviceProfileConnectorTest, UpdateBindType_001, testing::ext::TestSize.Level0)744 HWTEST_F(DeviceProfileConnectorTest, UpdateBindType_001, testing::ext::TestSize.Level0)
745 {
746 std::string udid = "deviceId";
747 int32_t bindType = DEVICE;
748 std::map<std::string, int32_t> deviceMap;
749 deviceMap[udid] = APP;
750 DeviceProfileConnector::GetInstance().UpdateBindType(udid, bindType, deviceMap);
751 EXPECT_EQ(deviceMap[udid], DEVICE);
752 }
753
HWTEST_F(DeviceProfileConnectorTest, UpdateBindType_002, testing::ext::TestSize.Level0)754 HWTEST_F(DeviceProfileConnectorTest, UpdateBindType_002, testing::ext::TestSize.Level0)
755 {
756 std::string udid = "deviceId";
757 int32_t bindType = DEVICE;
758 std::map<std::string, int32_t> deviceMap;
759 DeviceProfileConnector::GetInstance().UpdateBindType(udid, bindType, deviceMap);
760 EXPECT_EQ(deviceMap[udid], DEVICE);
761 }
762
HWTEST_F(DeviceProfileConnectorTest, HandleAccountLogoutEvent_001, testing::ext::TestSize.Level0)763 HWTEST_F(DeviceProfileConnectorTest, HandleAccountLogoutEvent_001, testing::ext::TestSize.Level0)
764 {
765 int32_t remoteUserId = 0;
766 int32_t bindType = DM_INVALIED_BINDTYPE;
767 std::string remoteAccountHash = "remoteAccountHash";
768 std::string remoteUdid = "1";
769 std::string localUdid = "localDeviceId";
770
771 bindType = DeviceProfileConnector::GetInstance().HandleAccountLogoutEvent(remoteUserId,
772 remoteAccountHash, remoteUdid, localUdid);
773 EXPECT_EQ(bindType, DM_INVALIED_BINDTYPE);
774 }
775
HWTEST_F(DeviceProfileConnectorTest, HandleDevUnBindEvent_001, testing::ext::TestSize.Level0)776 HWTEST_F(DeviceProfileConnectorTest, HandleDevUnBindEvent_001, testing::ext::TestSize.Level0)
777 {
778 int32_t remoteUserId = 0;
779 std::string remoteUdid = "remoteDeviceId";
780 std::string localUdid = "localDeviceId";
781 int32_t bindType = DM_INVALIED_BINDTYPE;
782
783 bindType = DeviceProfileConnector::GetInstance().HandleDevUnBindEvent(remoteUserId, remoteUdid, localUdid);
784 EXPECT_EQ(bindType, SERVICE);
785 }
786
HWTEST_F(DeviceProfileConnectorTest, HandleAppUnBindEvent_001, testing::ext::TestSize.Level0)787 HWTEST_F(DeviceProfileConnectorTest, HandleAppUnBindEvent_001, testing::ext::TestSize.Level0)
788 {
789 int32_t remoteUserId = 0;
790 int32_t tokenId = 0;
791 std::string remoteUdid = "remoteDeviceId";
792 std::string localUdid = "localDeviceId";
793 std::string pkgName = "";
794 std::string res = "";
795
796 res = DeviceProfileConnector::GetInstance().HandleAppUnBindEvent(remoteUserId, remoteUdid, tokenId, localUdid);
797 EXPECT_EQ(pkgName, res);
798 }
799
HWTEST_F(DeviceProfileConnectorTest, SingleUserProcess_001, testing::ext::TestSize.Level0)800 HWTEST_F(DeviceProfileConnectorTest, SingleUserProcess_001, testing::ext::TestSize.Level0)
801 {
802 DistributedDeviceProfile::AccessControlProfile profile;
803 DmAccessCaller caller;
804 DmAccessCallee callee;
805 int32_t ret = DeviceProfileConnector::GetInstance().SingleUserProcess(profile, caller, callee);
806 EXPECT_EQ(ret, false);
807 profile.SetBindType(DM_IDENTICAL_ACCOUNT);
808 profile.accessee_.SetAccesseeBundleName("pkgName");
809 profile.accessee_.SetAccesseeDeviceId("localDeviceId");
810 ret = DeviceProfileConnector::GetInstance().SingleUserProcess(profile, caller, callee);
811 EXPECT_EQ(ret, true);
812 profile.SetBindType(DM_POINT_TO_POINT);
813 profile.SetBindLevel(DEVICE);
814 ret = DeviceProfileConnector::GetInstance().SingleUserProcess(profile, caller, callee);
815 EXPECT_EQ(ret, true);
816 profile.SetBindLevel(APP);
817 ret = DeviceProfileConnector::GetInstance().SingleUserProcess(profile, caller, callee);
818 EXPECT_EQ(ret, true);
819 profile.SetBindLevel(SERVICE);
820 ret = DeviceProfileConnector::GetInstance().SingleUserProcess(profile, caller, callee);
821 EXPECT_EQ(ret, true);
822 profile.SetBindType(DM_ACROSS_ACCOUNT);
823 profile.SetBindLevel(DEVICE);
824 ret = DeviceProfileConnector::GetInstance().SingleUserProcess(profile, caller, callee);
825 EXPECT_EQ(ret, true);
826 profile.SetBindLevel(APP);
827 ret = DeviceProfileConnector::GetInstance().SingleUserProcess(profile, caller, callee);
828 EXPECT_EQ(ret, true);
829 profile.SetBindLevel(SERVICE);
830 ret = DeviceProfileConnector::GetInstance().SingleUserProcess(profile, caller, callee);
831 EXPECT_EQ(ret, true);
832 profile.SetBindType(INVALIED_TYPE);
833 ret = DeviceProfileConnector::GetInstance().SingleUserProcess(profile, caller, callee);
834 EXPECT_EQ(ret, false);
835 }
836 } // namespace DistributedHardware
837 } // namespace OHOS
838