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 <string>
17 #include <vector>
18 #define private public
19 #define protected public
20 #include "gtest/gtest.h"
21 #include "refbase.h"
22 #include "distributed_device_profile_constants.h"
23 #include "distributed_device_profile_errors.h"
24 #include "distributed_device_profile_log.h"
25 #include "distributed_device_profile_enums.h"
26 #include "dp_inited_callback_stub.h"
27 #include "dp_inited_callback_proxy.h"
28 #include "device_profile.h"
29 #include "service_profile.h"
30 #include "dp_subscribe_info.h"
31 #include "i_sync_completed_callback.h"
32 #include "characteristic_profile.h"
33 #include "distributed_device_profile_client.h"
34 #undef private
35 #undef protected
36
37 namespace OHOS {
38 namespace DistributedDeviceProfile {
39 using namespace testing::ext;
40 using namespace std;
41
42 class DistributedDeviceProfileClientKvTest : public testing::Test {
43 public:
44 static void SetUpTestCase(void);
45 static void TearDownTestCase(void);
46 void SetUp();
47 void TearDown();
48 };
49
SetUpTestCase(void)50 void DistributedDeviceProfileClientKvTest::SetUpTestCase(void) {
51 }
52
TearDownTestCase(void)53 void DistributedDeviceProfileClientKvTest::TearDownTestCase(void) {
54 }
55
SetUp()56 void DistributedDeviceProfileClientKvTest::SetUp() {
57 }
58
TearDown()59 void DistributedDeviceProfileClientKvTest::TearDown() {
60 }
61
62 class SubscribeDPChangeListener : public ProfileChangeListenerStub {
63 public:
SubscribeDPChangeListener()64 SubscribeDPChangeListener()
65 {
66 }
~SubscribeDPChangeListener()67 ~SubscribeDPChangeListener()
68 {
69 }
OnTrustDeviceProfileAdd(const TrustDeviceProfile & profile)70 int32_t OnTrustDeviceProfileAdd(const TrustDeviceProfile &profile)
71 {
72 return 0;
73 }
OnTrustDeviceProfileDelete(const TrustDeviceProfile & profile)74 int32_t OnTrustDeviceProfileDelete(const TrustDeviceProfile &profile)
75 {
76 return 0;
77 }
OnTrustDeviceProfileUpdate(const TrustDeviceProfile & oldProfile,const TrustDeviceProfile & newProfile)78 int32_t OnTrustDeviceProfileUpdate(const TrustDeviceProfile &oldProfile, const TrustDeviceProfile &newProfile)
79 {
80 return 0;
81 }
OnDeviceProfileAdd(const DeviceProfile & profile)82 int32_t OnDeviceProfileAdd(const DeviceProfile &profile)
83 {
84 return 0;
85 }
OnDeviceProfileDelete(const DeviceProfile & profile)86 int32_t OnDeviceProfileDelete(const DeviceProfile &profile)
87 {
88 return 0;
89 }
OnDeviceProfileUpdate(const DeviceProfile & oldProfile,const DeviceProfile & newProfile)90 int32_t OnDeviceProfileUpdate(const DeviceProfile &oldProfile, const DeviceProfile &newProfile)
91 {
92 return 0;
93 }
OnServiceProfileAdd(const ServiceProfile & profile)94 int32_t OnServiceProfileAdd(const ServiceProfile &profile)
95 {
96 return 0;
97 }
OnServiceProfileDelete(const ServiceProfile & profile)98 int32_t OnServiceProfileDelete(const ServiceProfile &profile)
99 {
100 return 0;
101 }
OnServiceProfileUpdate(const ServiceProfile & oldProfile,const ServiceProfile & newProfile)102 int32_t OnServiceProfileUpdate(const ServiceProfile &oldProfile, const ServiceProfile &newProfile)
103 {
104 return 0;
105 }
OnCharacteristicProfileAdd(const CharacteristicProfile & profile)106 int32_t OnCharacteristicProfileAdd(const CharacteristicProfile &profile)
107 {
108 return 0;
109 }
OnCharacteristicProfileDelete(const CharacteristicProfile & profile)110 int32_t OnCharacteristicProfileDelete(const CharacteristicProfile &profile)
111 {
112 return 0;
113 }
OnCharacteristicProfileUpdate(const CharacteristicProfile & oldProfile,const CharacteristicProfile & newProfile)114 int32_t OnCharacteristicProfileUpdate(const CharacteristicProfile &oldProfile,
115 const CharacteristicProfile &newProfile)
116 {
117 return 0;
118 }
119 };
120
121 class DpInitedCallback : public DpInitedCallbackStub {
122 public:
DpInitedCallback()123 DpInitedCallback()
124 {
125 }
~DpInitedCallback()126 ~DpInitedCallback()
127 {
128 }
OnDpInited()129 int32_t OnDpInited()
130 {
131 return 0;
132 }
133 };
134
135 class MockDpInitedCallbackStub : public DpInitedCallbackStub {
136 public:
OnDpInited()137 int32_t OnDpInited()
138 {
139 return 0;
140 }
141 };
142
143 /**
144 * @tc.name:PutServiceProfile001
145 * @tc.desc: PutServiceProfile success
146 * @tc.type: FUNC
147 * @tc.require:
148 */
149 HWTEST_F(DistributedDeviceProfileClientKvTest, PutServiceProfile001, TestSize.Level1)
150 {
151 ServiceProfile serviceProfile;
152 serviceProfile.SetDeviceId("deviceId");
153 serviceProfile.SetServiceName("serviceName");
154 serviceProfile.SetServiceType("serviceType");
155
156 int32_t errCode = DistributedDeviceProfileClient::GetInstance().PutServiceProfile(serviceProfile);
157 EXPECT_EQ(errCode, DP_PERMISSION_DENIED);
158 }
159
160 /**
161 * @tc.name:PutServiceProfileBatch001
162 * @tc.desc: PutServiceProfileBatch success
163 * @tc.type: FUNC
164 * @tc.require:
165 */
166 HWTEST_F(DistributedDeviceProfileClientKvTest, PutServiceProfileBatch001, TestSize.Level1)
167 {
168 vector<ServiceProfile> serviceProfiles;
169
170 ServiceProfile serviceProfile1;
171 serviceProfile1.SetDeviceId("deviceId1");
172 serviceProfile1.SetServiceName("serviceName1");
173 serviceProfile1.SetServiceType("serviceType1");
174 ServiceProfile serviceProfile2;
175 serviceProfile2.SetDeviceId("deviceId2");
176 serviceProfile2.SetServiceName("serviceName2");
177 serviceProfile2.SetServiceType("serviceType2");
178 serviceProfiles.push_back(serviceProfile1);
179 serviceProfiles.push_back(serviceProfile2);
180
181 int32_t errCode = DistributedDeviceProfileClient::GetInstance().PutServiceProfileBatch(serviceProfiles);
182 EXPECT_EQ(errCode, DP_PERMISSION_DENIED);
183 }
184
185 /**
186 * @tc.name:PutServiceProfileBatch002
187 * @tc.desc: PutServiceProfileBatch failed, ServiceProfiles size is invalid
188 * @tc.type: FUNC
189 * @tc.require:
190 */
191 HWTEST_F(DistributedDeviceProfileClientKvTest, PutServiceProfileBatch002, TestSize.Level1)
192 {
193 vector<ServiceProfile> serviceProfiles;
194
195 int32_t errCode = DistributedDeviceProfileClient::GetInstance().PutServiceProfileBatch(serviceProfiles);
196 EXPECT_EQ(errCode, DP_INVALID_PARAMS);
197 }
198
199 /**
200 * @tc.name:PutCharacteristicProfile001
201 * @tc.desc: PutCharacteristicProfile success
202 * @tc.type: FUNC
203 * @tc.require:
204 */
205 HWTEST_F(DistributedDeviceProfileClientKvTest, PutCharacteristicProfile001, TestSize.Level1)
206 {
207 CharacteristicProfile charProfile;
208 charProfile.SetDeviceId("deviceId");
209 charProfile.SetServiceName("serviceName");
210 charProfile.SetCharacteristicKey("characteristicKey");
211 charProfile.SetCharacteristicValue("characteristicValue");
212
213 int32_t errCode = DistributedDeviceProfileClient::GetInstance().PutCharacteristicProfile(charProfile);
214 EXPECT_EQ(errCode, DP_PERMISSION_DENIED);
215 }
216
217 /**
218 * @tc.name:PutCharacteristicProfileBatch001
219 * @tc.desc: PutCharacteristicProfileBatch success
220 * @tc.type: FUNC
221 * @tc.require:
222 */
223 HWTEST_F(DistributedDeviceProfileClientKvTest, PutCharacteristicProfileBatch001, TestSize.Level1)
224 {
225 vector<CharacteristicProfile> charProfiles;
226
227 CharacteristicProfile charProfile1;
228 charProfile1.SetDeviceId("deviceId1");
229 charProfile1.SetServiceName("serviceName1");
230 charProfile1.SetCharacteristicKey("characteristicKey1");
231 charProfile1.SetCharacteristicValue("characteristicValue1");
232 CharacteristicProfile charProfile2;
233 charProfile2.SetDeviceId("deviceId2");
234 charProfile2.SetServiceName("serviceName2");
235 charProfile2.SetCharacteristicKey("characteristicKey2");
236 charProfile2.SetCharacteristicValue("characteristicValue2");
237 charProfiles.push_back(charProfile1);
238 charProfiles.push_back(charProfile2);
239
240 int32_t errCode = DistributedDeviceProfileClient::GetInstance().PutCharacteristicProfileBatch(charProfiles);
241 EXPECT_EQ(errCode, DP_PERMISSION_DENIED);
242 }
243
244 /**
245 * @tc.name:PutCharacteristicProfileBatch002
246 * @tc.desc: PutCharacteristicProfileBatch failed, CharacteristicProfiles size is invalid
247 * @tc.type: FUNC
248 * @tc.require:
249 */
250 HWTEST_F(DistributedDeviceProfileClientKvTest, PutCharacteristicProfileBatch002, TestSize.Level1)
251 {
252 vector<CharacteristicProfile> charProfiles;
253
254 int32_t errCode = DistributedDeviceProfileClient::GetInstance().PutCharacteristicProfileBatch(charProfiles);
255 EXPECT_EQ(errCode, DP_INVALID_PARAMS);
256 }
257
258 /**
259 * @tc.name: GetDeviceProfile001
260 * @tc.desc: GetDeviceProfile success, DeviceProfile Set and Get
261 * @tc.type: FUNC
262 * @tc.require:
263 */
264 HWTEST_F(DistributedDeviceProfileClientKvTest, GetDeviceProfile001, TestSize.Level1)
265 {
266 string deviceId = "deviceId";
267 DeviceProfile deviceProfile;
268
269 int32_t errCode = DistributedDeviceProfileClient::GetInstance().GetDeviceProfile(deviceId, deviceProfile);
270 EXPECT_EQ(errCode, DP_PERMISSION_DENIED);
271
272 DeviceProfile deviceProfile1;
273 deviceProfile1.SetDeviceId("anything");
274 deviceProfile1.SetDeviceTypeName("anything");
275 deviceProfile1.SetDeviceTypeId(0);
276 deviceProfile1.SetDeviceName("anything");
277 deviceProfile1.SetManufactureName("anything");
278 deviceProfile1.SetDeviceModel("anything");
279 deviceProfile1.SetStorageCapability(1);
280 deviceProfile1.SetOsSysCap("anything");
281 deviceProfile1.SetOsApiLevel(1);
282 deviceProfile1.SetOsVersion("anything");
283 deviceProfile1.SetOsType(1);
284
285 deviceProfile1.GetDeviceId();
286 deviceProfile1.GetDeviceTypeName();
287 deviceProfile1.GetDeviceTypeId();
288 deviceProfile1.GetDeviceName();
289 deviceProfile1.GetManufactureName();
290 deviceProfile1.GetDeviceModel();
291 deviceProfile1.GetStorageCapability();
292 deviceProfile1.GetOsSysCap();
293 deviceProfile1.GetOsApiLevel();
294 deviceProfile1.GetOsVersion();
295 deviceProfile1.GetOsType();
296 }
297
298 /**
299 * @tc.name: GetServiceProfile001
300 * @tc.desc: GetServiceProfile success, ServiceProfile Get
301 * @tc.type: FUNC
302 * @tc.require:
303 */
304 HWTEST_F(DistributedDeviceProfileClientKvTest, GetServiceProfile001, TestSize.Level1)
305 {
306 string deviceId = "deviceId";
307 string serviceName = "serviceName";
308 ServiceProfile serviceProfile;
309
310 int32_t errCode = DistributedDeviceProfileClient::GetInstance().GetServiceProfile(
311 deviceId, serviceName, serviceProfile);
312 EXPECT_EQ(errCode, DP_PERMISSION_DENIED);
313 }
314
315 /**
316 * @tc.name: GetCharacteristicProfile001
317 * @tc.desc: GetCharacteristicProfile success, CharacteristicProfile Get
318 * @tc.type: FUNC
319 * @tc.require:
320 */
321 HWTEST_F(DistributedDeviceProfileClientKvTest, GetCharacteristicProfile001, TestSize.Level1)
322 {
323 string deviceId = "deviceId";
324 string serviceName = "serviceName";
325 string characteristicKey = "characteristicKey";
326 CharacteristicProfile characteristicProfile;
327
328 int32_t errCode = DistributedDeviceProfileClient::GetInstance().GetCharacteristicProfile(
329 deviceId, serviceName, characteristicKey, characteristicProfile);
330 EXPECT_EQ(errCode, DP_PERMISSION_DENIED);
331
332 characteristicProfile.GetDeviceId();
333 characteristicProfile.GetServiceName();
334 characteristicProfile.GetCharacteristicKey();
335 }
336
337 /**
338 * @tc.name: DeleteServiceProfile001
339 * @tc.desc: DeleteServiceProfile success
340 * @tc.type: FUNC
341 * @tc.require:
342 */
343 HWTEST_F(DistributedDeviceProfileClientKvTest, DeleteServiceProfile001, TestSize.Level1)
344 {
345 int32_t errCode = DistributedDeviceProfileClient::GetInstance().DeleteServiceProfile(
346 "deviceId", "serviceName");
347 EXPECT_EQ(errCode, DP_PERMISSION_DENIED);
348 }
349
350 /**
351 * @tc.name: DeleteCharacteristicProfile001
352 * @tc.desc: DeleteCharacteristicProfile success
353 * @tc.type: FUNC
354 * @tc.require:
355 */
356 HWTEST_F(DistributedDeviceProfileClientKvTest, DeleteCharacteristicProfile001, TestSize.Level1)
357 {
358 int32_t errCode = DistributedDeviceProfileClient::GetInstance().DeleteCharacteristicProfile(
359 "deviceId", "serviceName", "characteristicKey");
360 EXPECT_EQ(errCode, DP_PERMISSION_DENIED);
361 }
362
363 /**
364 * @tc.name: SubscribeDeviceProfile001
365 * @tc.desc: SubscribeDeviceProfile success
366 * @tc.type: FUNC
367 * @tc.require:
368 */
369 HWTEST_F(DistributedDeviceProfileClientKvTest, SubscribeDeviceProfile001, TestSize.Level1)
370 {
371 string subscribeKey = "subscribeKey";
372 int32_t saId = 4801;
373 unordered_set<ProfileChangeType> subscribeTypes = {
374 ProfileChangeType::SERVICE_PROFILE_ADD,
375 ProfileChangeType::SERVICE_PROFILE_UPDATE,
376 ProfileChangeType::SERVICE_PROFILE_DELETE
377 };
378 OHOS::sptr<IProfileChangeListener> subscribeDPChangeListener =
379 OHOS::sptr<ProfileChangeListenerStub>(new SubscribeDPChangeListener);
380 SubscribeInfo subscribeInfo(saId, subscribeKey, subscribeTypes, subscribeDPChangeListener);
381
382 int32_t errCode = DistributedDeviceProfileClient::GetInstance().SubscribeDeviceProfile(subscribeInfo);
383 EXPECT_EQ(errCode, DP_PERMISSION_DENIED);
384 }
385
386 /**
387 * @tc.name: UnSubscribeDeviceProfile001
388 * @tc.desc: UnSubscribeDeviceProfile success
389 * @tc.type: FUNC
390 * @tc.require:
391 */
392 HWTEST_F(DistributedDeviceProfileClientKvTest, UnSubscribeDeviceProfile001, TestSize.Level1)
393 {
394 string subscribeKey = "subscribeKey";
395 int32_t saId = 4801;
396 unordered_set<ProfileChangeType> subscribeTypes = {
397 ProfileChangeType::SERVICE_PROFILE_ADD,
398 ProfileChangeType::SERVICE_PROFILE_UPDATE,
399 ProfileChangeType::SERVICE_PROFILE_DELETE
400 };
401 OHOS::sptr<IProfileChangeListener> subscribeDPChangeListener =
402 OHOS::sptr<ProfileChangeListenerStub>(new SubscribeDPChangeListener);
403 SubscribeInfo subscribeInfo(saId, subscribeKey, subscribeTypes, subscribeDPChangeListener);
404
405 int32_t errCode = DistributedDeviceProfileClient::GetInstance().UnSubscribeDeviceProfile(subscribeInfo);
406 EXPECT_EQ(errCode, DP_PERMISSION_DENIED);
407 }
408
409 /**
410 * @tc.name: SyncDeviceProfile001
411 * @tc.desc: SyncDeviceProfile failed, SyncCb is nullptr!
412 * @tc.type: FUNC
413 * @tc.require:
414 */
415 HWTEST_F(DistributedDeviceProfileClientKvTest, SyncDeviceProfile001, TestSize.Level1)
416 {
417 DistributedDeviceProfile::DpSyncOptions syncOptions;
418 OHOS::sptr<ISyncCompletedCallback> syncCb = nullptr;
419
420 syncOptions.AddDevice("deviceId1");
421 syncOptions.AddDevice("deviceId2");
422 syncOptions.SetSyncMode(SyncMode::MIN);
423
424 int32_t errCode = DistributedDeviceProfileClient::GetInstance().SyncDeviceProfile(syncOptions, syncCb);
425 EXPECT_EQ(errCode, DP_SYNC_DEVICE_FAIL);
426 }
427
428 /**
429 * @tc.name: OnServiceDied001
430 * @tc.desc: OnServiceDied
431 * @tc.type: FUNC
432 * @tc.require:
433 */
434 HWTEST_F(DistributedDeviceProfileClientKvTest, OnServiceDied001, TestSize.Level1)
435 {
436 OHOS::wptr<OHOS::IRemoteObject> remsotes = nullptr;
437 DistributedDeviceProfileClient::DeviceProfileDeathRecipient deathRecipient;
438 deathRecipient.OnRemoteDied(remsotes);
439
440 OHOS::sptr<OHOS::IRemoteObject> remote = nullptr;
441 DistributedDeviceProfileClient::GetInstance().OnServiceDied(remote);
442 EXPECT_EQ(nullptr, DistributedDeviceProfileClient::GetInstance().dpProxy_);
443 }
444
445 /**
446 * @tc.name: SubscribeDeviceProfileInited_001
447 * @tc.desc: succeed
448 * @tc.type: FUNC
449 * @tc.require:
450 */
451 HWTEST_F(DistributedDeviceProfileClientKvTest, SubscribeDeviceProfileInited_001, TestSize.Level1)
452 {
453 OHOS::sptr<IDpInitedCallback> initedCb = sptr<IDpInitedCallback>(new DpInitedCallback());
454 int32_t ret = DistributedDeviceProfileClient::GetInstance().SubscribeDeviceProfileInited(1000, initedCb);
455 EXPECT_EQ(ret, DP_PERMISSION_DENIED);
456 }
457
458 /**
459 * @tc.name: SubscribeDeviceProfileInited_002
460 * @tc.desc: saId < 0
461 * @tc.type: FUNC
462 * @tc.require:
463 */
464 HWTEST_F(DistributedDeviceProfileClientKvTest, SubscribeDeviceProfileInited_002, TestSize.Level1)
465 {
466 OHOS::sptr<IDpInitedCallback> initedCb = sptr<IDpInitedCallback>(new DpInitedCallback());
467 int32_t ret = DistributedDeviceProfileClient::GetInstance().SubscribeDeviceProfileInited(-1, initedCb);
468 EXPECT_EQ(ret, DP_INVALID_PARAM);
469 }
470
471 /**
472 * @tc.name: SubscribeDeviceProfileInited_003
473 * @tc.desc: saId > MAX_SAID
474 * @tc.type: FUNC
475 * @tc.require:
476 */
477 HWTEST_F(DistributedDeviceProfileClientKvTest, SubscribeDeviceProfileInited_003, TestSize.Level1)
478 {
479 OHOS::sptr<IDpInitedCallback> initedCb = sptr<IDpInitedCallback>(new DpInitedCallback());
480 int32_t ret = DistributedDeviceProfileClient::GetInstance().SubscribeDeviceProfileInited(MAX_SAID + 1, initedCb);
481 EXPECT_EQ(ret, DP_INVALID_PARAM);
482 }
483
484 /**
485 * @tc.name: SubscribeDeviceProfileInited_004
486 * @tc.desc: initedCb == nullptr
487 * @tc.type: FUNC
488 * @tc.require:
489 */
490 HWTEST_F(DistributedDeviceProfileClientKvTest, SubscribeDeviceProfileInited_004, TestSize.Level1)
491 {
492 OHOS::sptr<IDpInitedCallback> initedCb = nullptr;
493 int32_t ret = DistributedDeviceProfileClient::GetInstance().SubscribeDeviceProfileInited(MAX_SAID + 1, initedCb);
494 EXPECT_EQ(ret, DP_INVALID_PARAM);
495 }
496
497 /**
498 * @tc.name: UnSubscribeDeviceProfileInited_001
499 * @tc.desc: succeed
500 * @tc.type: FUNC
501 * @tc.require:
502 */
503 HWTEST_F(DistributedDeviceProfileClientKvTest, UnSubscribeDeviceProfileInited_001, TestSize.Level1)
504 {
505 OHOS::sptr<IDpInitedCallback> initedCb = sptr<IDpInitedCallback>(new DpInitedCallback());
506 DistributedDeviceProfileClient::GetInstance().dpInitedCallback_ = initedCb;
507 int32_t ret = DistributedDeviceProfileClient::GetInstance().UnSubscribeDeviceProfileInited(1000);
508 EXPECT_EQ(ret, DP_PERMISSION_DENIED);
509 }
510
511 /**
512 * @tc.name: UnSubscribeDeviceProfileInited_002
513 * @tc.desc: dpInitedCallback_ == nullptr
514 * @tc.type: FUNC
515 * @tc.require:
516 */
517 HWTEST_F(DistributedDeviceProfileClientKvTest, UnSubscribeDeviceProfileInited_002, TestSize.Level1)
518 {
519 DistributedDeviceProfileClient::GetInstance().dpInitedCallback_ = nullptr;
520 int32_t ret = DistributedDeviceProfileClient::GetInstance().UnSubscribeDeviceProfileInited(1000);
521 EXPECT_EQ(ret, DP_SUCCESS);
522 }
523
524 /**
525 * @tc.name: UnSubscribeDeviceProfileInited_003
526 * @tc.desc: saId < 0
527 * @tc.type: FUNC
528 * @tc.require:
529 */
530 HWTEST_F(DistributedDeviceProfileClientKvTest, UnSubscribeDeviceProfileInited_003, TestSize.Level1)
531 {
532 OHOS::sptr<IDpInitedCallback> initedCb = sptr<IDpInitedCallback>(new DpInitedCallback());
533 DistributedDeviceProfileClient::GetInstance().dpInitedCallback_ = initedCb;
534 int32_t ret = DistributedDeviceProfileClient::GetInstance().UnSubscribeDeviceProfileInited(-1);
535 EXPECT_EQ(ret, DP_INVALID_PARAM);
536 }
537
538 /**
539 * @tc.name: UnSubscribeDeviceProfileInited_004
540 * @tc.desc: saId > MAX_SAID
541 * @tc.type: FUNC
542 * @tc.require:
543 */
544 HWTEST_F(DistributedDeviceProfileClientKvTest, UnSubscribeDeviceProfileInited_004, TestSize.Level1)
545 {
546 OHOS::sptr<IDpInitedCallback> initedCb = sptr<IDpInitedCallback>(new DpInitedCallback());
547 DistributedDeviceProfileClient::GetInstance().dpInitedCallback_ = initedCb;
548 int32_t ret = DistributedDeviceProfileClient::GetInstance().UnSubscribeDeviceProfileInited(MAX_SAID + 1);
549 EXPECT_EQ(ret, DP_INVALID_PARAM);
550 }
551
552 /**
553 * @tc.name: DpinitedCallback001
554 * @tc.desc: DP_SUCCESS
555 * @tc.type: FUNC
556 * @tc.require:
557 */
558 HWTEST_F(DistributedDeviceProfileClientKvTest, DpinitedCallback001, TestSize.Level1)
559 {
560 std::shared_ptr<DpInitedCallbackStub> DpinitedCallbackStub_ = std::make_shared<MockDpInitedCallbackStub>();
561 MessageParcel data;
562 MessageParcel reply;
563 DpInitedCallbackProxy proxy(nullptr);
564 proxy.OnDpInited();
565 int32_t ret = DpinitedCallbackStub_->OnDpInitedInner(data, reply);
566 EXPECT_EQ(DP_SUCCESS, ret);
567 }
568
569 /**
570 * @tc.name: OnRemoteRequest_001
571 * @tc.desc: succeed
572 * @tc.type: FUNC
573 * @tc.require:
574 */
575 HWTEST_F(DistributedDeviceProfileClientKvTest, OnRemoteRequest_001, TestSize.Level0)
576 {
577 std::shared_ptr<DpInitedCallbackStub> DpinitedCallbackStub_ = std::make_shared<MockDpInitedCallbackStub>();
578 uint32_t code = static_cast<uint32_t>(DPInterfaceCode::ON_DEVICE_PROFILE_INITED);
579 MessageParcel data;
580 MessageParcel reply;
581 MessageOption option;
582 int32_t ret = DpinitedCallbackStub_->OnRemoteRequest(code, data, reply, option);
583 EXPECT_EQ(DP_INTERFACE_CHECK_FAILED, ret);
584 }
585 } // namespace DistributedDeviceProfile
586 } // namespace OHOS
587