diff --git a/services/core/test/unittest/distributed_device_profile_client_kv_test.cpp b/services/core/test/unittest/distributed_device_profile_client_kv_test.cpp index f156d9e460bd0953f7349b66b2611e80c6489626..cd587ebb6daec2986bea051d0dacc133e4af5289 100644 --- a/services/core/test/unittest/distributed_device_profile_client_kv_test.cpp +++ b/services/core/test/unittest/distributed_device_profile_client_kv_test.cpp @@ -135,6 +135,21 @@ public: } }; +class SyncCompletedCallbac : public SyncCompletedCallbackStub { +public: + SyncCompletedCallbac() + { + } + ~SyncCompletedCallbac() + { + } + void OnSyncCompleted(const SyncResult& syncResults) + { + (void)syncResults; + return; + } +}; + class MockDpInitedCallbackStub : public DpInitedCallbackStub { public: int32_t OnDpInited() @@ -454,6 +469,44 @@ HWTEST_F(DistributedDeviceProfileClientKvTest, SyncDeviceProfile001, TestSize.Le EXPECT_EQ(errCode, DP_SYNC_DEVICE_FAIL); } +/** + * @tc.name: SyncStaticProfile001 + * @tc.desc: SyncStaticProfile failed, SyncCb is nullptr! + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(DistributedDeviceProfileClientKvTest, SyncStaticProfile001, TestSize.Level1) +{ + DistributedDeviceProfile::DpSyncOptions syncOptions; + OHOS::sptr syncCb = nullptr; + + syncOptions.AddDevice("deviceId1"); + syncOptions.AddDevice("deviceId2"); + syncOptions.SetSyncMode(SyncMode::MIN); + + int32_t errCode = DistributedDeviceProfileClient::GetInstance().SyncStaticProfile(syncOptions, syncCb); + EXPECT_EQ(errCode, DP_SYNC_DEVICE_FAIL); +} + +/** + * @tc.name: SyncStaticProfile002 + * @tc.desc: SyncStaticProfile failed + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(DistributedDeviceProfileClientKvTest, SyncStaticProfile002, TestSize.Level1) +{ + DistributedDeviceProfile::DpSyncOptions syncOptions; + OHOS::sptr syncCb = sptr(new SyncCompletedCallbac()); + + syncOptions.AddDevice("deviceId1"); + syncOptions.AddDevice("deviceId2"); + syncOptions.SetSyncMode(SyncMode::MIN); + + int32_t errCode = DistributedDeviceProfileClient::GetInstance().SyncStaticProfile(syncOptions, syncCb); + EXPECT_NE(errCode, DP_SUCCESS); +} + /** * @tc.name: OnServiceDied001 * @tc.desc: OnServiceDied