• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <gtest/gtest.h>
17 #include "accesstoken_kit.h"
18 #include "nativetoken_kit.h"
19 #include "token_setproc.h"
20 
21 #define private   public
22 #define protected public
23 #include "distributed_device_profile_service_new.h"
24 #include "system_ability_definition.h"
25 #include "profile_cache.h"
26 #include "distributed_device_profile_errors.h"
27 #include "trust_profile_manager.h"
28 #include "permission_manager.h"
29 #include "subscribe_profile_manager.h"
30 #include "event_handler_factory.h"
31 #include "distributed_device_profile_constants.h"
32 #include "dp_inited_callback_stub.h"
33 #include "i_dp_inited_callback.h"
34 #undef private
35 #undef protected
36 
37 
38 namespace OHOS {
39 namespace DistributedDeviceProfile {
40 using namespace testing;
41 using namespace testing::ext;
42 namespace {
43 const std::string PERMISSION_JSON_PATH = "/system/etc/deviceprofile/permission.json";
44 const int32_t PERMS_NUM = 2;
45 }
46 class DpProfileServiceTest : public testing::Test {
47 public:
48     static void SetUpTestCase();
49     static void TearDownTestCase();
50     void SetUp();
51     void TearDown();
52 };
53 
SetUpTestCase()54 void DpProfileServiceTest::SetUpTestCase()
55 {
56 }
57 
TearDownTestCase()58 void DpProfileServiceTest::TearDownTestCase()
59 {
60 }
61 
SetUp()62 void DpProfileServiceTest::SetUp()
63 {
64     const char *perms[PERMS_NUM] = {
65         "ohos.permission.DISTRIBUTED_DATASYNC",
66         "ohos.permission.DISTRIBUTED_SOFTBUS_CENTER"
67     };
68     uint64_t tokenId;
69     NativeTokenInfoParams infoInstance = {
70         .dcapsNum = 0,
71         .permsNum = PERMS_NUM,
72         .aclsNum = 0,
73         .dcaps = nullptr,
74         .perms = perms,
75         .acls = nullptr,
76         .processName = "deviceprofile",
77         .aplStr = "system_core",
78     };
79     tokenId = GetAccessTokenId(&infoInstance);
80     SetSelfTokenID(tokenId);
81     OHOS::Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo();
82 }
83 
TearDown()84 void DpProfileServiceTest::TearDown()
85 {
86 }
87 
88 class DpInitedCallback : public DpInitedCallbackStub {
89 public:
DpInitedCallback()90     DpInitedCallback()
91     {
92     }
~DpInitedCallback()93     ~DpInitedCallback()
94     {
95     }
OnDpInited()96     int32_t OnDpInited()
97     {
98         return 0;
99     }
100 };
101 
102 HWTEST_F(DpProfileServiceTest, Init_001, TestSize.Level1)
103 {
104     int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().Init();
105     EXPECT_EQ(DP_SUCCESS, ret);
106 }
107 
108 HWTEST_F(DpProfileServiceTest, UnInit_001, TestSize.Level1)
109 {
110     int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().UnInit();
111     EXPECT_EQ(DP_DEVICE_PROFILE_MANAGER_UNINIT_FAIL, ret);
112 }
113 
114 HWTEST_F(DpProfileServiceTest, CreateUnloadHandler_001, TestSize.Level1)
115 {
116     DistributedDeviceProfileServiceNew::GetInstance().unloadHandler_ = nullptr;
117     int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().CreateUnloadHandler();
118     EXPECT_EQ(DP_SUCCESS, ret);
119 
120     ret = DistributedDeviceProfileServiceNew::GetInstance().DestroyUnloadHandler();
121     EXPECT_EQ(DP_SUCCESS, ret);
122 
123     EventHandlerFactory::GetInstance().Init();
124     ret = DistributedDeviceProfileServiceNew::GetInstance().CreateUnloadHandler();
125     EXPECT_EQ(DP_SUCCESS, ret);
126 
127     ret = DistributedDeviceProfileServiceNew::GetInstance().DestroyUnloadHandler();
128     EXPECT_EQ(DP_SUCCESS, ret);
129 }
130 
131 HWTEST_F(DpProfileServiceTest, PutAccessControlProfile_001, TestSize.Level1)
132 {
133     AccessControlProfile accessControlProfile;
134     int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().PutAccessControlProfile(accessControlProfile);
135     EXPECT_EQ(DP_PERMISSION_DENIED, ret);
136     DistributedDeviceProfileServiceNew::GetInstance().DelayUnloadTask();
137 }
138 
139 HWTEST_F(DpProfileServiceTest, UpdateAccessControlProfile_001, TestSize.Level1)
140 {
141     AccessControlProfile accessControlProfile;
142     int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().UpdateAccessControlProfile(accessControlProfile);
143     EXPECT_EQ(DP_PERMISSION_DENIED, ret);
144 }
145 
146 HWTEST_F(DpProfileServiceTest, PutProductInfoBatch_001, TestSize.Level1)
147 {
148     std::vector<ProductInfo> productInfos;
149     int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().PutProductInfoBatch(productInfos);
150     EXPECT_EQ(DP_PERMISSION_DENIED, ret);
151 }
152 
153 HWTEST_F(DpProfileServiceTest, PutDeviceIconInfoBatch_001, TestSize.Level1)
154 {
155     std::vector<DeviceIconInfo> deviceIconInfos;
156     int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().PutDeviceIconInfoBatch(deviceIconInfos);
157     EXPECT_EQ(DP_PERMISSION_DENIED, ret);
158 }
159 
160 HWTEST_F(DpProfileServiceTest, GetDeviceIconInfos_001, TestSize.Level1)
161 {
162     DeviceIconInfoFilterOptions filterOptions;
163     std::vector<DeviceIconInfo> deviceIconInfos;
164     int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().GetDeviceIconInfos(filterOptions, deviceIconInfos);
165     EXPECT_EQ(DP_PERMISSION_DENIED, ret);
166 }
167 
168 HWTEST_F(DpProfileServiceTest, DeleteDeviceProfileBatch_001, TestSize.Level1)
169 {
170     std::vector<DeviceProfile> deviceProfiles;
171     int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().DeleteDeviceProfileBatch(deviceProfiles);
172     EXPECT_EQ(DP_PERMISSION_DENIED, ret);
173 }
174 
175 HWTEST_F(DpProfileServiceTest, GetTrustDeviceProfile_001, TestSize.Level1)
176 {
177     std::string devid;
178     TrustDeviceProfile trustDeviceProfile;
179     int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().GetTrustDeviceProfile(devid, trustDeviceProfile);
180     EXPECT_EQ(DP_PERMISSION_DENIED, ret);
181 }
182 
183 HWTEST_F(DpProfileServiceTest, GetAllTrustDeviceProfile_001, TestSize.Level1)
184 {
185     std::vector<TrustDeviceProfile> trustDeviceProfiles;
186     int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().GetAllTrustDeviceProfile(trustDeviceProfiles);
187     EXPECT_EQ(DP_PERMISSION_DENIED, ret);
188 }
189 
190 HWTEST_F(DpProfileServiceTest, GetAccessControlProfile_001, TestSize.Level1)
191 {
192     std::map<std::string, std::string> queryParams;
193     std::vector<AccessControlProfile> accessControlProfiles;
194     int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().GetAccessControlProfile(queryParams,
195         accessControlProfiles);
196     EXPECT_EQ(DP_PERMISSION_DENIED, ret);
197 }
198 
199 HWTEST_F(DpProfileServiceTest, GetAllAccessControlProfile_001, TestSize.Level1)
200 {
201     std::vector<AccessControlProfile> accessControlProfiles;
202     int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().GetAllAccessControlProfile(accessControlProfiles);
203     EXPECT_EQ(DP_PERMISSION_DENIED, ret);
204 }
205 
206 HWTEST_F(DpProfileServiceTest, GetAllAclIncludeLnnAcl_001, TestSize.Level1)
207 {
208     std::vector<AccessControlProfile> accessControlProfiles;
209     int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().GetAllAclIncludeLnnAcl(accessControlProfiles);
210     EXPECT_EQ(DP_PERMISSION_DENIED, ret);
211 }
212 
213 HWTEST_F(DpProfileServiceTest, DeleteAccessControlProfile_001, TestSize.Level1)
214 {
215     int32_t accessControlId = 0;
216     int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().DeleteAccessControlProfile(accessControlId);
217     EXPECT_EQ(DP_PERMISSION_DENIED, ret);
218 }
219 
220 HWTEST_F(DpProfileServiceTest, PutSessionKey_001, TestSize.Level1)
221 {
222     uint32_t userId = 0;
223     std::vector<uint8_t> sessionKey;
224     int32_t sessionKeyId = 0;
225     int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().PutSessionKey(userId, sessionKey, sessionKeyId);
226     EXPECT_EQ(DP_PERMISSION_DENIED, ret);
227 }
228 
229 HWTEST_F(DpProfileServiceTest, GetSessionKey_001, TestSize.Level1)
230 {
231     uint32_t userId = 0;
232     std::vector<uint8_t> sessionKey;
233     int32_t sessionKeyId = 0;
234     int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().GetSessionKey(userId, sessionKeyId, sessionKey);
235     EXPECT_EQ(DP_PERMISSION_DENIED, ret);
236 }
237 
238 HWTEST_F(DpProfileServiceTest, UpdateSessionKey_001, TestSize.Level1)
239 {
240     uint32_t userId = 0;
241     std::vector<uint8_t> sessionKey;
242     int32_t sessionKeyId = 0;
243     int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().UpdateSessionKey(userId, sessionKeyId, sessionKey);
244     EXPECT_EQ(DP_PERMISSION_DENIED, ret);
245 }
246 
247 HWTEST_F(DpProfileServiceTest, DeleteSessionKey_001, TestSize.Level1)
248 {
249     uint32_t userId = 0;
250     int32_t sessionKeyId = 0;
251     int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().DeleteSessionKey(userId, sessionKeyId);
252     EXPECT_EQ(DP_PERMISSION_DENIED, ret);
253 }
254 
255 HWTEST_F(DpProfileServiceTest, PutServiceProfile_001, TestSize.Level1)
256 {
257     std::string devid = "";
258     std::string serName = "serName_test";
259     std::string serviceType = "serviceType_test";
260     ServiceProfile serviceProfile(devid, serName, serviceType);
261     int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().PutServiceProfile(serviceProfile);
262     EXPECT_EQ(DP_PERMISSION_DENIED, ret);
263 }
264 
265 HWTEST_F(DpProfileServiceTest, PutServiceProfileBatch_001, TestSize.Level1)
266 {
267     std::vector<ServiceProfile> serviceProfiles;
268     int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().PutServiceProfileBatch(serviceProfiles);
269     EXPECT_EQ(DP_PERMISSION_DENIED, ret);
270 }
271 
272 HWTEST_F(DpProfileServiceTest, PutCharacteristicProfile_001, TestSize.Level1)
273 {
274     CharacteristicProfile charProfile;
275     int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().PutCharacteristicProfile(charProfile);
276     EXPECT_EQ(DP_PERMISSION_DENIED, ret);
277 }
278 
279 HWTEST_F(DpProfileServiceTest, PutServiceInfoProfile_001, TestSize.Level1)
280 {
281     ServiceInfoProfile serviceInfoProfile;
282     int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().PutServiceInfoProfile(serviceInfoProfile);
283     EXPECT_EQ(DP_PERMISSION_DENIED, ret);
284 }
285 
286 HWTEST_F(DpProfileServiceTest, DeleteServiceInfoProfile_001, TestSize.Level1)
287 {
288     ServiceInfoUniqueKey key;
289     int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().DeleteServiceInfoProfile(key);
290     EXPECT_EQ(DP_PERMISSION_DENIED, ret);
291 }
292 
293 HWTEST_F(DpProfileServiceTest, UpdateServiceInfoProfile_001, TestSize.Level1)
294 {
295     ServiceInfoProfile serviceInfoProfile;
296     int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().UpdateServiceInfoProfile(serviceInfoProfile);
297     EXPECT_EQ(DP_PERMISSION_DENIED, ret);
298 }
299 
300 HWTEST_F(DpProfileServiceTest, GetServiceInfoProfileByUniqueKey_001, TestSize.Level1)
301 {
302     ServiceInfoUniqueKey key;
303     ServiceInfoProfile serviceInfoProfile;
304     int32_t ret =
305         DistributedDeviceProfileServiceNew::GetInstance().GetServiceInfoProfileByUniqueKey(key, serviceInfoProfile);
306     EXPECT_EQ(DP_PERMISSION_DENIED, ret);
307 }
308 
309 HWTEST_F(DpProfileServiceTest, GetServiceInfoProfileListByTokenId_001, TestSize.Level1)
310 {
311     ServiceInfoUniqueKey key;
312     std::vector<ServiceInfoProfile> serviceInfoProfiles;
313     int32_t ret =
314         DistributedDeviceProfileServiceNew::GetInstance().GetServiceInfoProfileListByTokenId(key, serviceInfoProfiles);
315     EXPECT_EQ(DP_PERMISSION_DENIED, ret);
316 }
317 
318 HWTEST_F(DpProfileServiceTest, GetAllServiceInfoProfileList_001, TestSize.Level1)
319 {
320     std::vector<ServiceInfoProfile> serviceInfoProfiles;
321     int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().GetAllServiceInfoProfileList(serviceInfoProfiles);
322     EXPECT_EQ(DP_PERMISSION_DENIED, ret);
323 }
324 
325 HWTEST_F(DpProfileServiceTest, GetServiceInfoProfileListByBundleName_001, TestSize.Level1)
326 {
327     ServiceInfoUniqueKey key;
328     std::vector<ServiceInfoProfile> serviceInfoProfiles;
329     int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().GetServiceInfoProfileListByBundleName(
330         key, serviceInfoProfiles);
331     EXPECT_EQ(DP_PERMISSION_DENIED, ret);
332 }
333 
334 HWTEST_F(DpProfileServiceTest, PutCharacteristicProfileBatch_001, TestSize.Level1)
335 {
336     std::string devid = "";
337     std::string serName = "serName_test";
338     std::string charKey = "charKey_test";
339     std::string characteristicValue = "characteristicValue_test";
340     CharacteristicProfile charProfile(devid, serName, charKey, characteristicValue);
341     std::vector<CharacteristicProfile> charProfiles;
342     charProfiles.push_back(charProfile);
343     int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().PutCharacteristicProfileBatch(charProfiles);
344     EXPECT_EQ(DP_PERMISSION_DENIED, ret);
345 }
346 
347 HWTEST_F(DpProfileServiceTest, GetDeviceProfile_001, TestSize.Level1)
348 {
349     std::string devid = "";
350     DeviceProfile deviceProfile;
351     int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().GetDeviceProfile(devid, deviceProfile);
352     EXPECT_EQ(DP_PERMISSION_DENIED, ret);
353 }
354 
355 HWTEST_F(DpProfileServiceTest, GetDeviceProfiles_001, TestSize.Level1)
356 {
357     DeviceProfileFilterOptions options;
358     std::vector<DeviceProfile> deviceProfiles;
359     int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().GetDeviceProfiles(options, deviceProfiles);
360     EXPECT_EQ(DP_PERMISSION_DENIED, ret);
361 }
362 
363 HWTEST_F(DpProfileServiceTest, GetServiceProfile_001, TestSize.Level1)
364 {
365     std::string devid = "";
366     std::string serName = "";
367     ServiceProfile serviceProfile;
368     int32_t ret =
369             DistributedDeviceProfileServiceNew::GetInstance().GetServiceProfile(devid, serName, serviceProfile);
370     EXPECT_EQ(DP_PERMISSION_DENIED, ret);
371 }
372 
373 HWTEST_F(DpProfileServiceTest, GetCharacteristicProfile_001, TestSize.Level1)
374 {
375     std::string devid = "";
376     std::string serName = "";
377     std::string charKey = "";
378     CharacteristicProfile charProfile;
379     int32_t ret =
380             DistributedDeviceProfileServiceNew::GetInstance().GetCharacteristicProfile(devid,
381                                                                                        serName, charKey, charProfile);
382     EXPECT_EQ(DP_PERMISSION_DENIED, ret);
383 }
384 
385 HWTEST_F(DpProfileServiceTest, DeleteServiceProfile_001, TestSize.Level1)
386 {
387     std::string devid = "";
388     std::string serName = "";
389     int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().DeleteServiceProfile(devid, serName);
390     EXPECT_EQ(DP_PERMISSION_DENIED, ret);
391 }
392 
393 HWTEST_F(DpProfileServiceTest, DeleteCharacteristicProfile_001, TestSize.Level1)
394 {
395     std::string devid = "";
396     std::string serName = "";
397     std::string charKey = "";
398     int32_t ret =
399             DistributedDeviceProfileServiceNew::GetInstance().DeleteCharacteristicProfile(devid, serName, charKey);
400     EXPECT_EQ(DP_PERMISSION_DENIED, ret);
401 }
402 
403 HWTEST_F(DpProfileServiceTest, PutLocalServiceInfo_001, TestSize.Level1)
404 {
405     LocalServiceInfo localServiceInfo;
406     int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().PutLocalServiceInfo(localServiceInfo);
407     EXPECT_EQ(DP_PERMISSION_DENIED, ret);
408 }
409 
410 HWTEST_F(DpProfileServiceTest, UpdateLocalServiceInfo_001, TestSize.Level1)
411 {
412     LocalServiceInfo localServiceInfo;
413     int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().UpdateLocalServiceInfo(localServiceInfo);
414     EXPECT_EQ(DP_PERMISSION_DENIED, ret);
415 }
416 
417 HWTEST_F(DpProfileServiceTest, GetLocalServiceInfoByBundleAndPinType_001, TestSize.Level1)
418 {
419     std::string bundleName;
420     int32_t pinExchangeType = 0;
421     LocalServiceInfo localServiceInfo;
422     int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().GetLocalServiceInfoByBundleAndPinType(
423         bundleName, pinExchangeType, localServiceInfo);
424     EXPECT_EQ(DP_PERMISSION_DENIED, ret);
425 }
426 
427 HWTEST_F(DpProfileServiceTest, DeleteLocalServiceInfo_001, TestSize.Level1)
428 {
429     std::string bundleName;
430     int32_t pinExchangeType = 0;
431     int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().DeleteLocalServiceInfo(bundleName, pinExchangeType);
432     EXPECT_EQ(DP_PERMISSION_DENIED, ret);
433 }
434 
435 HWTEST_F(DpProfileServiceTest, SubscribeDeviceProfile_001, TestSize.Level1)
436 {
437     SubscribeInfo subscriberInfo;
438     int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().SubscribeDeviceProfile(subscriberInfo);
439     EXPECT_EQ(DP_PERMISSION_DENIED, ret);
440 }
441 
442 HWTEST_F(DpProfileServiceTest, UnSubscribeDeviceProfile_001, TestSize.Level1)
443 {
444     SubscribeInfo subscriberInfo;
445     int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().UnSubscribeDeviceProfile(subscriberInfo);
446     EXPECT_EQ(DP_PERMISSION_DENIED, ret);
447 }
448 
449 HWTEST_F(DpProfileServiceTest, SyncDeviceProfile_001, TestSize.Level1)
450 {
451     DistributedDeviceProfile::DpSyncOptions syncOptions;
452     sptr<IRemoteObject> syncCallback = nullptr;
453     int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().SyncDeviceProfile(syncOptions, syncCallback);
454     EXPECT_EQ(DP_PERMISSION_DENIED, ret);
455 }
456 
457 HWTEST_F(DpProfileServiceTest, Dump_001, TestSize.Level1)
458 {
459     int32_t fd = -1;
460     std::vector<std::u16string> args;
461     int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().Dump(fd, args);
462     EXPECT_EQ(DP_INVALID_PARAMS, ret);
463 }
464 
465 HWTEST_F(DpProfileServiceTest, SubscribeDeviceProfileInited_001, TestSize.Level1)
466 {
467     int32_t saId = 1000;
468     OHOS::sptr<IRemoteObject> initedCb = sptr<IRemoteObject>(new DpInitedCallback());
469     int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().SubscribeDeviceProfileInited(saId, initedCb);
470     EXPECT_EQ(DP_PERMISSION_DENIED, ret);
471 }
472 
473 HWTEST_F(DpProfileServiceTest, UnSubscribeDeviceProfileInited_001, TestSize.Level1)
474 {
475     int32_t saId = 1000;
476     DistributedDeviceProfileServiceNew::GetInstance().ExitIdleState();
477     DistributedDeviceProfileServiceNew::GetInstance().IsStopped();
478     int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().UnSubscribeDeviceProfileInited(saId);
479     EXPECT_EQ(DP_PERMISSION_DENIED, ret);
480 }
481 
482 HWTEST_F(DpProfileServiceTest, SubscribePinCodeInvalid_001, TestSize.Level1)
483 {
484     SystemAbilityOnDemandReason startReason;
485     DistributedDeviceProfileServiceNew::GetInstance().OnStart(startReason);
486     DistributedDeviceProfileServiceNew::GetInstance().OnStop();
487     std::string bundleName;
488     int32_t pinExchangeType = 0;
489     sptr<IRemoteObject> pinCodeCallback;
490     int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().SubscribePinCodeInvalid(
491         bundleName, pinExchangeType, pinCodeCallback);
492     EXPECT_EQ(DP_PERMISSION_DENIED, ret);
493 }
494 
495 HWTEST_F(DpProfileServiceTest, UnSubscribePinCodeInvalid_001, TestSize.Level1)
496 {
497     std::string bundleName;
498     int32_t pinExchangeType = 0;
499     int32_t ret =
500         DistributedDeviceProfileServiceNew::GetInstance().UnSubscribePinCodeInvalid(bundleName, pinExchangeType);
501     EXPECT_EQ(DP_PERMISSION_DENIED, ret);
502 }
503 
504 HWTEST_F(DpProfileServiceTest, NotifyPinCodeInvalid_001, TestSize.Level1)
505 {
506     LocalServiceInfo localServiceInfo;
507     int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().NotifyPinCodeInvalid(localServiceInfo);
508     EXPECT_EQ(DP_SUCCESS, ret);
509 }
510 
511 HWTEST_F(DpProfileServiceTest, NotifyPinCodeInvalid_002, TestSize.Level1)
512 {
513     LocalServiceInfo localServiceInfo;
514     localServiceInfo.SetBundleName("aaa");
515     int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().NotifyPinCodeInvalid(localServiceInfo);
516     EXPECT_EQ(0, ret);
517 }
518 
519 HWTEST_F(DpProfileServiceTest, PutAllTrustedDevices_001, TestSize.Level1)
520 {
521     std::vector<TrustedDeviceInfo> deviceInfos;
522     int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().PutAllTrustedDevices(deviceInfos);
523     EXPECT_EQ(DP_PERMISSION_DENIED, ret);
524 }
525 
526 HWTEST_F(DpProfileServiceTest, UnInitNext_001, TestSize.Level1)
527 {
528     int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().UnInitNext();
529     EXPECT_EQ(DP_SUCCESS, ret);
530 }
531 
532 HWTEST_F(DpProfileServiceTest, IsReadyIntoIdle_001, TestSize.Level1)
533 {
534     DistributedDeviceProfileServiceNew::GetInstance().runningIpcCount_.store(1);
535     bool ret = DistributedDeviceProfileServiceNew::GetInstance().IsReadyIntoIdle();
536     EXPECT_EQ(false, ret);
537 }
538 
539 HWTEST_F(DpProfileServiceTest, IsReadyIntoIdle_002, TestSize.Level1)
540 {
541     DistributedDeviceProfileServiceNew::GetInstance().runningIpcCount_.store(0);
542     bool ret = DistributedDeviceProfileServiceNew::GetInstance().IsReadyIntoIdle();
543     EXPECT_EQ(true, ret);
544 }
545 
546 HWTEST_F(DpProfileServiceTest, AddRunningIpcCount_001, TestSize.Level1)
547 {
548     DistributedDeviceProfileServiceNew::GetInstance().runningIpcCount_.store(0);
549     DistributedDeviceProfileServiceNew::GetInstance().AddRunningIpcCount();
550     bool ret = DistributedDeviceProfileServiceNew::GetInstance().IsReadyIntoIdle();
551     EXPECT_EQ(false, ret);
552 }
553 
554 HWTEST_F(DpProfileServiceTest, SubtractRunningIpcCount_001, TestSize.Level1)
555 {
556     DistributedDeviceProfileServiceNew::GetInstance().runningIpcCount_.store(1);
557     DistributedDeviceProfileServiceNew::GetInstance().SubtractRunningIpcCount();
558     bool ret = DistributedDeviceProfileServiceNew::GetInstance().IsReadyIntoIdle();
559     EXPECT_EQ(true, ret);
560 }
561 }
562 }
563