From e6233d9f8c40c43f5a32ed8e9dbff939e021570f Mon Sep 17 00:00:00 2001 From: wangzhaohao Date: Mon, 3 Mar 2025 16:16:45 +0800 Subject: [PATCH 1/7] add ut Signed-off-by: wangzhaohao --- .../profile_change_listener_stub_test.cpp | 28 ++ .../profile_change_listener_stub_test.h | 4 +- ...tributed_device_profile_client_kv_test.cpp | 279 +++++++++++++++--- .../profile_change_listener_proxy_test.cpp | 4 + 4 files changed, 266 insertions(+), 49 deletions(-) diff --git a/common/test/profilechangelistenerstubunittest/profile_change_listener_stub_test.cpp b/common/test/profilechangelistenerstubunittest/profile_change_listener_stub_test.cpp index e36fad2a..fcbedb4c 100644 --- a/common/test/profilechangelistenerstubunittest/profile_change_listener_stub_test.cpp +++ b/common/test/profilechangelistenerstubunittest/profile_change_listener_stub_test.cpp @@ -61,6 +61,18 @@ int32_t MockProfileChangeListenerStub::OnTrustDeviceProfileUpdate(const TrustDev return 0; } +int32_t MockProfileChangeListenerStub::OnTrustDeviceProfileInactive(const TrustDeviceProfile& profile) +{ + (void)profile; + return 0; +} + +int32_t MockProfileChangeListenerStub::OnTrustDeviceProfileActive(const TrustDeviceProfile& profile) +{ + (void)profile; + return 0; +} + int32_t MockProfileChangeListenerStub::OnDeviceProfileAdd(const DeviceProfile& profile) { (void)profile; @@ -148,6 +160,22 @@ HWTEST_F(ProfileChangeListenerStubTest, OnTrustDeviceProfileDeleteInner_001, Tes EXPECT_EQ(ERR_FLATTEN_OBJECT, ret); } +HWTEST_F(ProfileChangeListenerStubTest, OnTrustDeviceProfileInactiveInner_001, TestSize.Level0) +{ + MessageParcel data; + MessageParcel reply; + int32_t ret = listenerStub_->OnTrustDeviceProfileInactiveInner(data, reply); + EXPECT_EQ(ERR_FLATTEN_OBJECT, ret); +} + +HWTEST_F(ProfileChangeListenerStubTest, OnTrustDeviceProfileActive_001, TestSize.Level0) +{ + MessageParcel data; + MessageParcel reply; + int32_t ret = listenerStub_->OnTrustDeviceProfileActiveInner(data, reply); + EXPECT_EQ(ERR_FLATTEN_OBJECT, ret); +} + HWTEST_F(ProfileChangeListenerStubTest, OnTrustDeviceProfileUpdateInner_001, TestSize.Level0) { MessageParcel data; diff --git a/common/test/profilechangelistenerstubunittest/profile_change_listener_stub_test.h b/common/test/profilechangelistenerstubunittest/profile_change_listener_stub_test.h index 0531bd7c..7c87841e 100644 --- a/common/test/profilechangelistenerstubunittest/profile_change_listener_stub_test.h +++ b/common/test/profilechangelistenerstubunittest/profile_change_listener_stub_test.h @@ -41,6 +41,8 @@ public: int32_t OnTrustDeviceProfileDelete(const TrustDeviceProfile& profile) override; int32_t OnTrustDeviceProfileUpdate(const TrustDeviceProfile& oldProfile, const TrustDeviceProfile& newProfile) override; + int32_t OnTrustDeviceProfileInactive(const TrustDeviceProfile& profile) override; + int32_t OnTrustDeviceProfileActive(const TrustDeviceProfile& profile) override; int32_t OnDeviceProfileAdd(const DeviceProfile& profile) override; int32_t OnDeviceProfileDelete(const DeviceProfile& profile) override; int32_t OnDeviceProfileUpdate(const DeviceProfile& oldProfile, const DeviceProfile& newProfile) override; @@ -54,4 +56,4 @@ public: }; } // namespace DistributedDeviceProfile } // namespace OHOS -#endif // PROFILE_CHANGE_LISTENNER_STUB_TEST_H \ No newline at end of file +#endif // PROFILE_CHANGE_LISTENNER_STUB_TEST_H 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 b70e955d..b494525c 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 @@ -15,7 +15,7 @@ #include #include -#define private public +#define private public #define protected public #include "gtest/gtest.h" #include "refbase.h" @@ -48,26 +48,24 @@ public: void TearDown(); }; -void DistributedDeviceProfileClientKvTest::SetUpTestCase(void) { -} +void DistributedDeviceProfileClientKvTest::SetUpTestCase(void) +{} -void DistributedDeviceProfileClientKvTest::TearDownTestCase(void) { -} +void DistributedDeviceProfileClientKvTest::TearDownTestCase(void) +{} -void DistributedDeviceProfileClientKvTest::SetUp() { -} +void DistributedDeviceProfileClientKvTest::SetUp() +{} -void DistributedDeviceProfileClientKvTest::TearDown() { -} +void DistributedDeviceProfileClientKvTest::TearDown() +{} class SubscribeDPChangeListener : public ProfileChangeListenerStub { public: SubscribeDPChangeListener() - { - } + {} ~SubscribeDPChangeListener() - { - } + {} int32_t OnTrustDeviceProfileAdd(const TrustDeviceProfile &profile) { return 0; @@ -112,8 +110,8 @@ public: { return 0; } - int32_t OnCharacteristicProfileUpdate(const CharacteristicProfile &oldProfile, - const CharacteristicProfile &newProfile) + int32_t OnCharacteristicProfileUpdate( + const CharacteristicProfile &oldProfile, const CharacteristicProfile &newProfile) { return 0; } @@ -122,11 +120,9 @@ public: class DpInitedCallback : public DpInitedCallbackStub { public: DpInitedCallback() - { - } + {} ~DpInitedCallback() - { - } + {} int32_t OnDpInited() { return 0; @@ -167,7 +163,7 @@ HWTEST_F(DistributedDeviceProfileClientKvTest, PutServiceProfile001, TestSize.Le HWTEST_F(DistributedDeviceProfileClientKvTest, PutServiceProfileBatch001, TestSize.Level1) { vector serviceProfiles; - + ServiceProfile serviceProfile1; serviceProfile1.SetDeviceId("deviceId1"); serviceProfile1.SetServiceName("serviceName1"); @@ -178,7 +174,7 @@ HWTEST_F(DistributedDeviceProfileClientKvTest, PutServiceProfileBatch001, TestSi serviceProfile2.SetServiceType("serviceType2"); serviceProfiles.push_back(serviceProfile1); serviceProfiles.push_back(serviceProfile2); - + int32_t errCode = DistributedDeviceProfileClient::GetInstance().PutServiceProfileBatch(serviceProfiles); EXPECT_EQ(errCode, DP_PERMISSION_DENIED); } @@ -192,7 +188,7 @@ HWTEST_F(DistributedDeviceProfileClientKvTest, PutServiceProfileBatch001, TestSi HWTEST_F(DistributedDeviceProfileClientKvTest, PutServiceProfileBatch002, TestSize.Level1) { vector serviceProfiles; - + int32_t errCode = DistributedDeviceProfileClient::GetInstance().PutServiceProfileBatch(serviceProfiles); EXPECT_EQ(errCode, DP_INVALID_PARAMS); } @@ -210,7 +206,7 @@ HWTEST_F(DistributedDeviceProfileClientKvTest, PutCharacteristicProfile001, Test charProfile.SetServiceName("serviceName"); charProfile.SetCharacteristicKey("characteristicKey"); charProfile.SetCharacteristicValue("characteristicValue"); - + int32_t errCode = DistributedDeviceProfileClient::GetInstance().PutCharacteristicProfile(charProfile); EXPECT_EQ(errCode, DP_PERMISSION_DENIED); } @@ -224,7 +220,7 @@ HWTEST_F(DistributedDeviceProfileClientKvTest, PutCharacteristicProfile001, Test HWTEST_F(DistributedDeviceProfileClientKvTest, PutCharacteristicProfileBatch001, TestSize.Level1) { vector charProfiles; - + CharacteristicProfile charProfile1; charProfile1.SetDeviceId("deviceId1"); charProfile1.SetServiceName("serviceName1"); @@ -251,7 +247,7 @@ HWTEST_F(DistributedDeviceProfileClientKvTest, PutCharacteristicProfileBatch001, HWTEST_F(DistributedDeviceProfileClientKvTest, PutCharacteristicProfileBatch002, TestSize.Level1) { vector charProfiles; - + int32_t errCode = DistributedDeviceProfileClient::GetInstance().PutCharacteristicProfileBatch(charProfiles); EXPECT_EQ(errCode, DP_INVALID_PARAMS); } @@ -266,7 +262,7 @@ HWTEST_F(DistributedDeviceProfileClientKvTest, GetDeviceProfile001, TestSize.Lev { string deviceId = "deviceId"; DeviceProfile deviceProfile; - + int32_t errCode = DistributedDeviceProfileClient::GetInstance().GetDeviceProfile(deviceId, deviceProfile); EXPECT_EQ(errCode, DP_PERMISSION_DENIED); @@ -303,9 +299,9 @@ HWTEST_F(DistributedDeviceProfileClientKvTest, GetServiceProfile001, TestSize.Le string deviceId = "deviceId"; string serviceName = "serviceName"; ServiceProfile serviceProfile; - - int32_t errCode = DistributedDeviceProfileClient::GetInstance().GetServiceProfile( - deviceId, serviceName, serviceProfile); + + int32_t errCode = + DistributedDeviceProfileClient::GetInstance().GetServiceProfile(deviceId, serviceName, serviceProfile); EXPECT_EQ(errCode, DP_PERMISSION_DENIED); } @@ -321,9 +317,9 @@ HWTEST_F(DistributedDeviceProfileClientKvTest, GetCharacteristicProfile001, Test string serviceName = "serviceName"; string characteristicKey = "characteristicKey"; CharacteristicProfile characteristicProfile; - + int32_t errCode = DistributedDeviceProfileClient::GetInstance().GetCharacteristicProfile( - deviceId, serviceName, characteristicKey, characteristicProfile); + deviceId, serviceName, characteristicKey, characteristicProfile); EXPECT_EQ(errCode, DP_PERMISSION_DENIED); characteristicProfile.GetDeviceId(); @@ -340,7 +336,7 @@ HWTEST_F(DistributedDeviceProfileClientKvTest, GetCharacteristicProfile001, Test HWTEST_F(DistributedDeviceProfileClientKvTest, DeleteServiceProfile001, TestSize.Level1) { int32_t errCode = DistributedDeviceProfileClient::GetInstance().DeleteServiceProfile( - "deviceId", "serviceName", false, DEFAULT_USER_ID); + "deviceId", "serviceName", false, DEFAULT_USER_ID); EXPECT_EQ(errCode, DP_PERMISSION_DENIED); } @@ -353,7 +349,7 @@ HWTEST_F(DistributedDeviceProfileClientKvTest, DeleteServiceProfile001, TestSize HWTEST_F(DistributedDeviceProfileClientKvTest, DeleteCharacteristicProfile001, TestSize.Level1) { int32_t errCode = DistributedDeviceProfileClient::GetInstance().DeleteCharacteristicProfile( - "deviceId", "serviceName", "characteristicKey", false, DEFAULT_USER_ID); + "deviceId", "serviceName", "characteristicKey", false, DEFAULT_USER_ID); EXPECT_EQ(errCode, DP_PERMISSION_DENIED); } @@ -367,15 +363,13 @@ HWTEST_F(DistributedDeviceProfileClientKvTest, SubscribeDeviceProfile001, TestSi { string subscribeKey = "subscribeKey"; int32_t saId = 4801; - unordered_set subscribeTypes = { - ProfileChangeType::SERVICE_PROFILE_ADD, + unordered_set subscribeTypes = {ProfileChangeType::SERVICE_PROFILE_ADD, ProfileChangeType::SERVICE_PROFILE_UPDATE, - ProfileChangeType::SERVICE_PROFILE_DELETE - }; + ProfileChangeType::SERVICE_PROFILE_DELETE}; OHOS::sptr subscribeDPChangeListener = OHOS::sptr(new SubscribeDPChangeListener); SubscribeInfo subscribeInfo(saId, subscribeKey, subscribeTypes, subscribeDPChangeListener); - + int32_t errCode = DistributedDeviceProfileClient::GetInstance().SubscribeDeviceProfile(subscribeInfo); EXPECT_EQ(errCode, DP_PERMISSION_DENIED); } @@ -390,15 +384,13 @@ HWTEST_F(DistributedDeviceProfileClientKvTest, UnSubscribeDeviceProfile001, Test { string subscribeKey = "subscribeKey"; int32_t saId = 4801; - unordered_set subscribeTypes = { - ProfileChangeType::SERVICE_PROFILE_ADD, - ProfileChangeType::SERVICE_PROFILE_UPDATE, - ProfileChangeType::SERVICE_PROFILE_DELETE - }; + unordered_set subscribeTypes = {ProfileChangeType::SERVICE_PROFILE_ADD, + ProfileChangeType::SERVICE_PROFILE_UPDATE, + ProfileChangeType::SERVICE_PROFILE_DELETE}; OHOS::sptr subscribeDPChangeListener = OHOS::sptr(new SubscribeDPChangeListener); SubscribeInfo subscribeInfo(saId, subscribeKey, subscribeTypes, subscribeDPChangeListener); - + int32_t errCode = DistributedDeviceProfileClient::GetInstance().UnSubscribeDeviceProfile(subscribeInfo); EXPECT_EQ(errCode, DP_PERMISSION_DENIED); } @@ -413,11 +405,11 @@ HWTEST_F(DistributedDeviceProfileClientKvTest, SyncDeviceProfile001, TestSize.Le { DistributedDeviceProfile::DpSyncOptions syncOptions; OHOS::sptr syncCb = nullptr; - + syncOptions.AddDevice("deviceId1"); syncOptions.AddDevice("deviceId2"); syncOptions.SetSyncMode(SyncMode::MIN); - + int32_t errCode = DistributedDeviceProfileClient::GetInstance().SyncDeviceProfile(syncOptions, syncCb); EXPECT_EQ(errCode, DP_SYNC_DEVICE_FAIL); } @@ -606,5 +598,196 @@ HWTEST_F(DistributedDeviceProfileClientKvTest, PutAllTrustedDevices_002, TestSiz int32_t errCode = DistributedDeviceProfileClient::GetInstance().PutAllTrustedDevices(deviceInfos); EXPECT_EQ(errCode, DP_PERMISSION_DENIED); } -} // namespace DistributedDeviceProfile -} // namespace OHOS + +/** + * @tc.name: PutDeviceProfileBatch_001 + * @tc.desc: succeed + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(DistributedDeviceProfileClientKvTest, PutDeviceProfileBatch_001, TestSize.Level0) +{ + std::vector deviceProfiles; + int32_t errCode = DistributedDeviceProfileClient::GetInstance().PutDeviceProfileBatch(deviceProfiles); + EXPECT_EQ(errCode, DP_WRITE_PARCEL_FAIL); +} + +/** + * @tc.name: GetDeviceProfiles_001 + * @tc.desc: succeed + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(DistributedDeviceProfileClientKvTest, GetDeviceProfiles_001, TestSize.Level0) +{ + std::vector deviceProfiles; + DeviceProfileFilterOptions options; + int32_t errCode = DistributedDeviceProfileClient::GetInstance().GetDeviceProfiles(options, deviceProfiles); + EXPECT_EQ(errCode, DP_PERMISSION_DENIED); +} + +/** + * @tc.name: DeleteDeviceProfileBatch_001 + * @tc.desc: succeed + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(DistributedDeviceProfileClientKvTest, DeleteDeviceProfileBatch_001, TestSize.Level0) +{ + std::vector deviceProfiles; + int32_t errCode = DistributedDeviceProfileClient::GetInstance().DeleteDeviceProfileBatch(deviceProfiles); + EXPECT_EQ(errCode, DP_WRITE_PARCEL_FAIL); +} + +/** + * @tc.name: PutDeviceIconInfoBatch_001 + * @tc.desc: succeed + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(DistributedDeviceProfileClientKvTest, PutDeviceIconInfoBatch_001, TestSize.Level0) +{ + std::vector deviceIconInfos; + int32_t errCode = DistributedDeviceProfileClient::GetInstance().PutDeviceIconInfoBatch(deviceIconInfos); + EXPECT_EQ(errCode, DP_PERMISSION_DENIED); +} + +/** + * @tc.name: GetDeviceIconInfos_001 + * @tc.desc: succeed + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(DistributedDeviceProfileClientKvTest, GetDeviceIconInfos_001, TestSize.Level0) +{ + DeviceIconInfoFilterOptions filterOptions; + std::vector deviceIconInfos; + int32_t errCode = DistributedDeviceProfileClient::GetInstance().GetDeviceIconInfos(filterOptions, deviceIconInfos); + EXPECT_EQ(errCode, DP_PERMISSION_DENIED); +} + +/** + * @tc.name: SubscribePinCodeInvalid_001 + * @tc.desc: succeed + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(DistributedDeviceProfileClientKvTest, SubscribePinCodeInvalid_001, TestSize.Level0) +{ + std::string tokenId; + sptr pinCodeCallback; + int32_t errCode = DistributedDeviceProfileClient::GetInstance().SubscribePinCodeInvalid(tokenId, pinCodeCallback); + EXPECT_EQ(errCode, DP_INVALID_PARAM); +} + +/** + * @tc.name: UnSubscribePinCodeInvalid_001 + * @tc.desc: succeed + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(DistributedDeviceProfileClientKvTest, UnSubscribePinCodeInvalid_001, TestSize.Level0) +{ + std::string tokenId; + int32_t errCode = DistributedDeviceProfileClient::GetInstance().UnSubscribePinCodeInvalid(tokenId); + EXPECT_EQ(errCode, DP_SUCCESS); +} + +/** + * @tc.name: PutServiceInfoProfile_001 + * @tc.desc: succeed + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(DistributedDeviceProfileClientKvTest, PutServiceInfoProfile_001, TestSize.Level0) +{ + ServiceInfoProfile serviceInfoProfile; + int32_t errCode = DistributedDeviceProfileClient::GetInstance().PutServiceInfoProfile(serviceInfoProfile); + EXPECT_EQ(errCode, DP_PERMISSION_DENIED); +} + +/** + * @tc.name: DeleteServiceInfoProfile_001 + * @tc.desc: succeed + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(DistributedDeviceProfileClientKvTest, DeleteServiceInfoProfile_001, TestSize.Level0) +{ + ServiceInfoUniqueKey key; + int32_t errCode = DistributedDeviceProfileClient::GetInstance().DeleteServiceInfoProfile(key); + EXPECT_EQ(errCode, DP_PERMISSION_DENIED); +} + +/** + * @tc.name: UpdateServiceInfoProfile_001 + * @tc.desc: succeed + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(DistributedDeviceProfileClientKvTest, UpdateServiceInfoProfile_001, TestSize.Level0) +{ + ServiceInfoProfile serviceInfoProfile; + int32_t errCode = DistributedDeviceProfileClient::GetInstance().UpdateServiceInfoProfile(serviceInfoProfile); + EXPECT_EQ(errCode, DP_PERMISSION_DENIED); +} + + +/** + * @tc.name: GetServiceInfoProfileByUniqueKey_001 + * @tc.desc: succeed + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(DistributedDeviceProfileClientKvTest, GetServiceInfoProfileByUniqueKey_001, TestSize.Level0) +{ + ServiceInfoUniqueKey key; + ServiceInfoProfile serviceInfoProfile; + int32_t errCode = DistributedDeviceProfileClient::GetInstance().GetServiceInfoProfileByUniqueKey(key, serviceInfoProfile); + EXPECT_EQ(errCode, DP_PERMISSION_DENIED); +} + +/** + * @tc.name: GetServiceInfoProfileListByTokenId_001 + * @tc.desc: succeed + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(DistributedDeviceProfileClientKvTest, GetServiceInfoProfileListByTokenId_001, TestSize.Level0) +{ + ServiceInfoUniqueKey key; + std::vector serviceInfoProfiles; + int32_t errCode = + DistributedDeviceProfileClient::GetInstance().GetServiceInfoProfileListByTokenId(key, serviceInfoProfiles); + EXPECT_EQ(errCode, DP_PERMISSION_DENIED); +} + +/** + * @tc.name: GetAllServiceInfoProfileList_001 + * @tc.desc: succeed + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(DistributedDeviceProfileClientKvTest, GetAllServiceInfoProfileList_001, TestSize.Level0) +{ + std::vector serviceInfoProfiles; + int32_t errCode = DistributedDeviceProfileClient::GetInstance().GetAllServiceInfoProfileList(serviceInfoProfiles); + EXPECT_EQ(errCode, DP_PERMISSION_DENIED); +} + +/** + * @tc.name: GetServiceInfoProfileListByBundleName_001 + * @tc.desc: succeed + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(DistributedDeviceProfileClientKvTest, GetServiceInfoProfileListByBundleName_001, TestSize.Level0) +{ + ServiceInfoUniqueKey key; + std::vector serviceInfoProfiles; + int32_t errCode = + DistributedDeviceProfileClient::GetInstance().GetServiceInfoProfileListByBundleName(key, serviceInfoProfiles); + EXPECT_EQ(errCode, DP_PERMISSION_DENIED); +} +} // namespace DistributedDeviceProfile +} // namespace OHOS diff --git a/services/core/test/unittest/profile_change_listener_proxy_test.cpp b/services/core/test/unittest/profile_change_listener_proxy_test.cpp index dd0a9cab..4c5f49bd 100644 --- a/services/core/test/unittest/profile_change_listener_proxy_test.cpp +++ b/services/core/test/unittest/profile_change_listener_proxy_test.cpp @@ -75,6 +75,10 @@ HWTEST_F(ProfileChangeListenerProxyTest, OnTrustDeviceProfile_001, TestSize.Leve EXPECT_NE(ret, DP_SUCCESS); ret = proxy.OnTrustDeviceProfileDelete(oldProfile); EXPECT_NE(ret, DP_SUCCESS); + ret = proxy.OnTrustDeviceProfileInactive(oldProfile); + EXPECT_NE(ret, DP_SUCCESS); + ret = proxy.OnTrustDeviceProfileActive(oldProfile); + EXPECT_NE(ret, DP_SUCCESS); } /* -- Gitee From ad5f7a851847f4ec86a0a0ee5a8c127ea0d61db9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=87=E6=99=96?= Date: Mon, 3 Mar 2025 09:47:51 +0000 Subject: [PATCH 2/7] =?UTF-8?q?update=20services/core/test/unittest/distri?= =?UTF-8?q?buted=5Fdevice=5Fprofile=5Fclient=5Fkv=5Ftest.cpp.=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王宇晖 --- .../unittest/distributed_device_profile_client_kv_test.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 b494525c..3b54271e 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 @@ -743,7 +743,8 @@ HWTEST_F(DistributedDeviceProfileClientKvTest, GetServiceInfoProfileByUniqueKey_ { ServiceInfoUniqueKey key; ServiceInfoProfile serviceInfoProfile; - int32_t errCode = DistributedDeviceProfileClient::GetInstance().GetServiceInfoProfileByUniqueKey(key, serviceInfoProfile); + int32_t errCode = DistributedDeviceProfileClient::GetInstance().GetServiceInfoProfileByUniqueKey(key, + serviceInfoProfile); EXPECT_EQ(errCode, DP_PERMISSION_DENIED); } -- Gitee From df0c48c22e688f334281757e0cec9f38ad77f726 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=87=E6=99=96?= Date: Mon, 3 Mar 2025 12:15:36 +0000 Subject: [PATCH 3/7] =?UTF-8?q?update=20common/test/profilechangelisteners?= =?UTF-8?q?tubunittest/profile=5Fchange=5Flistener=5Fstub=5Ftest.cpp.=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王宇晖 --- .../profile_change_listener_stub_test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/test/profilechangelistenerstubunittest/profile_change_listener_stub_test.cpp b/common/test/profilechangelistenerstubunittest/profile_change_listener_stub_test.cpp index fcbedb4c..0242d1c6 100644 --- a/common/test/profilechangelistenerstubunittest/profile_change_listener_stub_test.cpp +++ b/common/test/profilechangelistenerstubunittest/profile_change_listener_stub_test.cpp @@ -151,7 +151,7 @@ HWTEST_F(ProfileChangeListenerStubTest, OnTrustDeviceProfileAddInner_001, TestSi EXPECT_EQ(ERR_FLATTEN_OBJECT, ret); } -HWTEST_F(ProfileChangeListenerStubTest, OnTrustDeviceProfileDeleteInner_001, TestSize.Level0) +HWTEST_F(ProfileChangeListenerStubTest, OnTrustDeviceProfileDeleteInner_002, TestSize.Level0) { MessageParcel data; MessageParcel reply; @@ -160,7 +160,7 @@ HWTEST_F(ProfileChangeListenerStubTest, OnTrustDeviceProfileDeleteInner_001, Tes EXPECT_EQ(ERR_FLATTEN_OBJECT, ret); } -HWTEST_F(ProfileChangeListenerStubTest, OnTrustDeviceProfileInactiveInner_001, TestSize.Level0) +HWTEST_F(ProfileChangeListenerStubTest, OnTrustDeviceProfileInactiveInner_002, TestSize.Level0) { MessageParcel data; MessageParcel reply; -- Gitee From 7ec804473c2e7cd3ee028bd2ea8cf36234b71401 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=87=E6=99=96?= Date: Mon, 3 Mar 2025 12:18:39 +0000 Subject: [PATCH 4/7] =?UTF-8?q?update=20common/test/profilechangelisteners?= =?UTF-8?q?tubunittest/profile=5Fchange=5Flistener=5Fstub=5Ftest.cpp.=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王宇晖 --- .../profile_change_listener_stub_test.cpp | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/common/test/profilechangelistenerstubunittest/profile_change_listener_stub_test.cpp b/common/test/profilechangelistenerstubunittest/profile_change_listener_stub_test.cpp index 0242d1c6..da76c6b9 100644 --- a/common/test/profilechangelistenerstubunittest/profile_change_listener_stub_test.cpp +++ b/common/test/profilechangelistenerstubunittest/profile_change_listener_stub_test.cpp @@ -151,7 +151,7 @@ HWTEST_F(ProfileChangeListenerStubTest, OnTrustDeviceProfileAddInner_001, TestSi EXPECT_EQ(ERR_FLATTEN_OBJECT, ret); } -HWTEST_F(ProfileChangeListenerStubTest, OnTrustDeviceProfileDeleteInner_002, TestSize.Level0) +HWTEST_F(ProfileChangeListenerStubTest, OnTrustDeviceProfileDeleteInner_001, TestSize.Level0) { MessageParcel data; MessageParcel reply; @@ -168,7 +168,7 @@ HWTEST_F(ProfileChangeListenerStubTest, OnTrustDeviceProfileInactiveInner_002, T EXPECT_EQ(ERR_FLATTEN_OBJECT, ret); } -HWTEST_F(ProfileChangeListenerStubTest, OnTrustDeviceProfileActive_001, TestSize.Level0) +HWTEST_F(ProfileChangeListenerStubTest, OnTrustDeviceProfileActive_002, TestSize.Level0) { MessageParcel data; MessageParcel reply; @@ -442,5 +442,28 @@ HWTEST_F(ProfileChangeListenerStubTest, OnTrustDeviceProfileInactivet_001, TestS int32_t ret = listenerStub_->OnTrustDeviceProfileInactive(profile); EXPECT_EQ(DP_SUCCESS, ret); } + +HWTEST_F(ProfileChangeListenerStubTest, OnTrustDeviceProfileInactiveInner_001, TestSize.Level0) +{ + MessageParcel data; + data.WriteInterfaceToken(IProfileChangeListener::GetDescriptor()); + MessageParcel reply; + int32_t ret = listenerStub_->OnTrustDeviceProfileInactiveInner(data, reply); + EXPECT_NE(DP_SUCCESS, ret); +} + +HWTEST_F(ProfileChangeListenerStubTest, OnTrustDeviceProfileActive_001, TestSize.Level0) +{ + TrustDeviceProfile profile; + int32_t ret = listenerStub_->OnTrustDeviceProfileActive(profile); + EXPECT_EQ(DP_SUCCESS, ret); +} + +HWTEST_F(ProfileChangeListenerStubTest, OnTrustDeviceProfileInactive_001, TestSize.Level0) +{ + TrustDeviceProfile profile; + int32_t ret = listenerStub_->OnTrustDeviceProfileInactive(profile); + EXPECT_EQ(DP_SUCCESS, ret); +} } // namespace DistributedDeviceProfile } // namespace OHOS -- Gitee From 0c54982c84eab1b0aec86be300a73f02d638e801 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=87=E6=99=96?= Date: Mon, 3 Mar 2025 12:20:54 +0000 Subject: [PATCH 5/7] =?UTF-8?q?update=20common/test/profilechangelisteners?= =?UTF-8?q?tubunittest/profile=5Fchange=5Flistener=5Fstub=5Ftest.cpp.=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0ut?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王宇晖 --- .../profile_change_listener_stub_test.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/common/test/profilechangelistenerstubunittest/profile_change_listener_stub_test.cpp b/common/test/profilechangelistenerstubunittest/profile_change_listener_stub_test.cpp index da76c6b9..02354928 100644 --- a/common/test/profilechangelistenerstubunittest/profile_change_listener_stub_test.cpp +++ b/common/test/profilechangelistenerstubunittest/profile_change_listener_stub_test.cpp @@ -443,6 +443,15 @@ HWTEST_F(ProfileChangeListenerStubTest, OnTrustDeviceProfileInactivet_001, TestS EXPECT_EQ(DP_SUCCESS, ret); } +HWTEST_F(ProfileChangeListenerStubTest, OnTrustDeviceProfileActiveInner_001, TestSize.Level0) +{ + MessageParcel data; + data.WriteInterfaceToken(IProfileChangeListener::GetDescriptor()); + MessageParcel reply; + int32_t ret = listenerStub_->OnTrustDeviceProfileActiveInner(data, reply); + EXPECT_NE(DP_SUCCESS, ret); +} + HWTEST_F(ProfileChangeListenerStubTest, OnTrustDeviceProfileInactiveInner_001, TestSize.Level0) { MessageParcel data; -- Gitee From c8f0e71bbb643d5054babbc1b87d48f2a2cf4f4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=87=E6=99=96?= Date: Mon, 3 Mar 2025 12:31:34 +0000 Subject: [PATCH 6/7] =?UTF-8?q?update=20services/core/src/profiledatamanag?= =?UTF-8?q?er/device=5Fprofile=5Fdao.cpp.=20=E4=BB=A3=E7=A0=81=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王宇晖 --- .../core/src/profiledatamanager/device_profile_dao.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/services/core/src/profiledatamanager/device_profile_dao.cpp b/services/core/src/profiledatamanager/device_profile_dao.cpp index f274e45e..34293244 100644 --- a/services/core/src/profiledatamanager/device_profile_dao.cpp +++ b/services/core/src/profiledatamanager/device_profile_dao.cpp @@ -94,10 +94,6 @@ int32_t DeviceProfileDao::PutDeviceProfile(const DeviceProfile& deviceProfile) profile.SetId(id); } resultSet->Close(); - std::string localUdid = ContentSensorManagerUtils::GetInstance().ObtainLocalUdid(); - if (localUdid == deviceProfile.GetDeviceId()) { - DeviceProfileManager::GetInstance().PutDeviceProfile(profile); - } HILOGI("end!"); return DP_SUCCESS; } @@ -164,10 +160,6 @@ int32_t DeviceProfileDao::UpdateDeviceProfile(const DeviceProfile &newProfile) return DP_UPDATE_TRUST_DEVICE_PROFILE_FAIL; } } - std::string localUdid = ContentSensorManagerUtils::GetInstance().ObtainLocalUdid(); - if (localUdid == newProfile.GetDeviceId()) { - DeviceProfileManager::GetInstance().PutDeviceProfile(newProfile); - } HILOGI("end!"); return DP_SUCCESS; } -- Gitee From 0753303fdcce04922c37680b5acc84da119516c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=87=E6=99=96?= Date: Mon, 3 Mar 2025 12:41:19 +0000 Subject: [PATCH 7/7] Revert "update services/core/src/profiledatamanager/device_profile_dao.cpp." This reverts commit c8f0e71bbb643d5054babbc1b87d48f2a2cf4f4a. --- .../core/src/profiledatamanager/device_profile_dao.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/services/core/src/profiledatamanager/device_profile_dao.cpp b/services/core/src/profiledatamanager/device_profile_dao.cpp index 34293244..f274e45e 100644 --- a/services/core/src/profiledatamanager/device_profile_dao.cpp +++ b/services/core/src/profiledatamanager/device_profile_dao.cpp @@ -94,6 +94,10 @@ int32_t DeviceProfileDao::PutDeviceProfile(const DeviceProfile& deviceProfile) profile.SetId(id); } resultSet->Close(); + std::string localUdid = ContentSensorManagerUtils::GetInstance().ObtainLocalUdid(); + if (localUdid == deviceProfile.GetDeviceId()) { + DeviceProfileManager::GetInstance().PutDeviceProfile(profile); + } HILOGI("end!"); return DP_SUCCESS; } @@ -160,6 +164,10 @@ int32_t DeviceProfileDao::UpdateDeviceProfile(const DeviceProfile &newProfile) return DP_UPDATE_TRUST_DEVICE_PROFILE_FAIL; } } + std::string localUdid = ContentSensorManagerUtils::GetInstance().ObtainLocalUdid(); + if (localUdid == newProfile.GetDeviceId()) { + DeviceProfileManager::GetInstance().PutDeviceProfile(newProfile); + } HILOGI("end!"); return DP_SUCCESS; } -- Gitee