From 8a49c60936d5d91eb920a69d1c26d5bafb59ee0c Mon Sep 17 00:00:00 2001 From: torrizo Date: Thu, 11 Jul 2024 12:50:59 +0000 Subject: [PATCH 01/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9UT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: torrizo --- services/core/test/unittest/trust_profile_manager_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/core/test/unittest/trust_profile_manager_test.cpp b/services/core/test/unittest/trust_profile_manager_test.cpp index d5f0205b..07cc4224 100644 --- a/services/core/test/unittest/trust_profile_manager_test.cpp +++ b/services/core/test/unittest/trust_profile_manager_test.cpp @@ -76,7 +76,7 @@ void TrustProfileManagerTest::TearDown() int TrustProfileManagerTest::ResultSize(std::shared_ptr &resultSet) { - if (resultSet->GoToFirstRow() != E_OK) { + if (resultSet->GoToFirstRow() != E_OK && resultSet == nullptr) { return 0; } int count; -- Gitee From 81981b466eab2c17e4ab5abd6e1e6d08898ac99a Mon Sep 17 00:00:00 2001 From: torrizo Date: Thu, 11 Jul 2024 13:04:52 +0000 Subject: [PATCH 02/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9UT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: torrizo --- services/core/test/unittest/sync_completed_callback_test.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/services/core/test/unittest/sync_completed_callback_test.cpp b/services/core/test/unittest/sync_completed_callback_test.cpp index 5983d54a..b2573302 100644 --- a/services/core/test/unittest/sync_completed_callback_test.cpp +++ b/services/core/test/unittest/sync_completed_callback_test.cpp @@ -142,6 +142,7 @@ HWTEST_F(SyncCompletedCallbackStubTest, OnRemoteRequest_003, TestSize.Level3) sptr stub(new SyncCompletedListener()); sptr proxy(new SyncCompletedCallbackProxy(stub)); + ASSERT_NE(proxy, nullptr); syncResults.emplace("testdeviceid", SUCCEEDED); proxy->OnSyncCompleted(syncResults); } -- Gitee From bf7e262ba84f40ea61f0389efe53cd25d972dee5 Mon Sep 17 00:00:00 2001 From: torrizo Date: Thu, 11 Jul 2024 13:05:32 +0000 Subject: [PATCH 03/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9UT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: torrizo --- services/core/test/unittest/dp_subscribe_info_test.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/services/core/test/unittest/dp_subscribe_info_test.cpp b/services/core/test/unittest/dp_subscribe_info_test.cpp index b7896d96..2387093a 100644 --- a/services/core/test/unittest/dp_subscribe_info_test.cpp +++ b/services/core/test/unittest/dp_subscribe_info_test.cpp @@ -250,6 +250,7 @@ HWTEST_F(DPSubscribeInfoTest, Stub_001, TestSize.Level1) OHOS::sptr proxy = OHOS::iface_cast(subscribeInfo.GetListener()); TrustDeviceProfile oldTrustProfile; TrustDeviceProfile newTrustProfile; + ASSERT_NE(proxy, nullptr); int32_t ret = proxy->OnTrustDeviceProfileAdd(oldTrustProfile); EXPECT_EQ(ret, DP_SUCCESS); ret = proxy->OnTrustDeviceProfileDelete(oldTrustProfile); -- Gitee From e62ddeebffbc66ca1886c216e6838f7ba2aed2e6 Mon Sep 17 00:00:00 2001 From: torrizo Date: Thu, 11 Jul 2024 13:06:45 +0000 Subject: [PATCH 04/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9UT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: torrizo --- .../unittest/distributed_device_profile_client_rdb_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/core/test/unittest/distributed_device_profile_client_rdb_test.cpp b/services/core/test/unittest/distributed_device_profile_client_rdb_test.cpp index 82e9cd17..2a67b82d 100644 --- a/services/core/test/unittest/distributed_device_profile_client_rdb_test.cpp +++ b/services/core/test/unittest/distributed_device_profile_client_rdb_test.cpp @@ -136,7 +136,7 @@ void DistributedDeviceProfileClientRdbTest::TearDown() int DistributedDeviceProfileClientRdbTest::ResultSize(std::shared_ptr &resultSet) { - if (resultSet->GoToFirstRow() != E_OK) { + if (resultSet->GoToFirstRow() != E_OK && resultSet == nullptr) { return 0; } int count; -- Gitee From 698fdc43390bd5415d780969decef93e8c9d2258 Mon Sep 17 00:00:00 2001 From: torrizo Date: Thu, 11 Jul 2024 13:09:12 +0000 Subject: [PATCH 05/10] =?UTF-8?q?unloadHandler=5F=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E6=9C=AA=E5=88=A4=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: torrizo --- services/core/src/distributed_device_profile_service_new.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/services/core/src/distributed_device_profile_service_new.cpp b/services/core/src/distributed_device_profile_service_new.cpp index bbe8f574..4f4d2a12 100644 --- a/services/core/src/distributed_device_profile_service_new.cpp +++ b/services/core/src/distributed_device_profile_service_new.cpp @@ -545,6 +545,9 @@ void DistributedDeviceProfileServiceNew::DelayUnloadTask() } HILOGI("kill dp svr success!"); }; + if (unloadHandler_ == nullptr) { + return; + } unloadHandler_->RemoveTask(UNLOAD_TASK_ID); HILOGI("delay unload task post task"); unloadHandler_->PostTask(task, UNLOAD_TASK_ID, DELAY_TIME); -- Gitee From f0056442e2f1ad9f84166df9c1a5f93f0c90f297 Mon Sep 17 00:00:00 2001 From: torrizo Date: Thu, 11 Jul 2024 13:10:04 +0000 Subject: [PATCH 06/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9UT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: torrizo --- .../core/test/unittest/event_subscribe_test.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/old/services/core/test/unittest/event_subscribe_test.cpp b/old/services/core/test/unittest/event_subscribe_test.cpp index a605f2e5..2cfaab34 100644 --- a/old/services/core/test/unittest/event_subscribe_test.cpp +++ b/old/services/core/test/unittest/event_subscribe_test.cpp @@ -29,6 +29,9 @@ using namespace std::chrono_literals; using namespace testing; using namespace testing::ext; +namespace { +const int32_t UT_ERROR = -1; +} class EventSubscribeTest : public testing::Test { public: static void SetUpTestCase(); @@ -117,6 +120,9 @@ int32_t PutFakeSystem() int32_t MockSubscribeEvents(const std::shared_ptr& eventCb, const std::list& serviceIds, const std::string& deviceId) { + if (eventCb == nullptr) { + return UT_ERROR; + } eventCb->SetSubServiceIds(serviceIds); ExtraInfo extraInfo; extraInfo["deviceId"] = deviceId; @@ -139,6 +145,9 @@ int32_t MockSubscribeEvents(const std::shared_ptr& eventCb int32_t MockUnsubscribeEvents(const std::shared_ptr& eventCb) { + if (eventCb == nullptr) { + return UT_ERROR; + } std::list profileEvents; profileEvents.emplace_back(ProfileEvent::EVENT_PROFILE_CHANGED); profileEvents.emplace_back(ProfileEvent::EVENT_SYNC_COMPLETED); @@ -150,6 +159,9 @@ int32_t MockUnsubscribeEvents(const std::shared_ptr& event int32_t MockSubscribeEvent(const std::shared_ptr& eventCb, const std::list& serviceIds, const std::string& deviceId) { + if (eventCb == nullptr) { + return UT_ERROR; + } eventCb->SetSubServiceIds(serviceIds); ExtraInfo extraInfo; extraInfo["deviceId"] = deviceId; -- Gitee From e1e2dc9e7e6c72936e20e10f170b659a9676c6df Mon Sep 17 00:00:00 2001 From: torrizo Date: Thu, 11 Jul 2024 13:10:28 +0000 Subject: [PATCH 07/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9UT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: torrizo --- .../core/test/unittest/profile_event_notifier_proxy_test.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/old/services/core/test/unittest/profile_event_notifier_proxy_test.cpp b/old/services/core/test/unittest/profile_event_notifier_proxy_test.cpp index 5813e964..8ab53223 100644 --- a/old/services/core/test/unittest/profile_event_notifier_proxy_test.cpp +++ b/old/services/core/test/unittest/profile_event_notifier_proxy_test.cpp @@ -69,6 +69,7 @@ HWTEST_F(ProfileEventNotifierProxyTest, OnSyncCompleted_001, TestSize.Level3) auto syncCb = std::make_shared(); sptr stub(new ProfileEventNotifierStub(syncCb)); sptr proxy(new ProfileEventNotifierProxy(stub)); + ASSERT_NE(proxy, nullptr); SyncResult syncResults; proxy->OnSyncCompleted(syncResults); EXPECT_EQ(syncCb->result, 0); @@ -85,6 +86,7 @@ HWTEST_F(ProfileEventNotifierProxyTest, OnSyncCompleted_002, TestSize.Level3) auto syncCb = std::make_shared(); sptr stub(new ProfileEventNotifierStub(syncCb)); sptr proxy(new ProfileEventNotifierProxy(stub)); + ASSERT_NE(proxy, nullptr); SyncResult syncResults; syncResults.emplace("testdeviceid", SUCCEEDED); proxy->OnSyncCompleted(syncResults); @@ -102,6 +104,7 @@ HWTEST_F(ProfileEventNotifierProxyTest, OnProfileChanged_001, TestSize.Level3) auto syncCb = std::make_shared(); sptr stub(new ProfileEventNotifierStub(syncCb)); sptr proxy(new ProfileEventNotifierProxy(stub)); + ASSERT_NE(proxy, nullptr); ProfileChangeNotification notification; proxy->OnProfileChanged(notification); EXPECT_EQ(syncCb->result, 0); -- Gitee From f4aea82688f76f0fb3e8f9bcfc00cdc3e640a8ae Mon Sep 17 00:00:00 2001 From: torrizo Date: Thu, 11 Jul 2024 13:11:47 +0000 Subject: [PATCH 08/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9UT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: torrizo --- services/core/test/unittest/trust_profile_manager_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/core/test/unittest/trust_profile_manager_test.cpp b/services/core/test/unittest/trust_profile_manager_test.cpp index 07cc4224..d5f0205b 100644 --- a/services/core/test/unittest/trust_profile_manager_test.cpp +++ b/services/core/test/unittest/trust_profile_manager_test.cpp @@ -76,7 +76,7 @@ void TrustProfileManagerTest::TearDown() int TrustProfileManagerTest::ResultSize(std::shared_ptr &resultSet) { - if (resultSet->GoToFirstRow() != E_OK && resultSet == nullptr) { + if (resultSet->GoToFirstRow() != E_OK) { return 0; } int count; -- Gitee From 18b67097400b199c1997bd78682e9dfb7786cd35 Mon Sep 17 00:00:00 2001 From: torrizo Date: Thu, 11 Jul 2024 13:21:32 +0000 Subject: [PATCH 09/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9UT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: torrizo --- .../unittest/distributed_device_profile_client_rdb_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/core/test/unittest/distributed_device_profile_client_rdb_test.cpp b/services/core/test/unittest/distributed_device_profile_client_rdb_test.cpp index 2a67b82d..3d0ba46b 100644 --- a/services/core/test/unittest/distributed_device_profile_client_rdb_test.cpp +++ b/services/core/test/unittest/distributed_device_profile_client_rdb_test.cpp @@ -136,7 +136,7 @@ void DistributedDeviceProfileClientRdbTest::TearDown() int DistributedDeviceProfileClientRdbTest::ResultSize(std::shared_ptr &resultSet) { - if (resultSet->GoToFirstRow() != E_OK && resultSet == nullptr) { + if (resultSet == nullptr && resultSet->GoToFirstRow() != E_OK) { return 0; } int count; -- Gitee From e91f6a9c62e6af6bfae20099468b8f9281b34d92 Mon Sep 17 00:00:00 2001 From: torrizo Date: Thu, 11 Jul 2024 13:34:44 +0000 Subject: [PATCH 10/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9UT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: torrizo --- .../unittest/distributed_device_profile_client_rdb_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/core/test/unittest/distributed_device_profile_client_rdb_test.cpp b/services/core/test/unittest/distributed_device_profile_client_rdb_test.cpp index 3d0ba46b..25b4adea 100644 --- a/services/core/test/unittest/distributed_device_profile_client_rdb_test.cpp +++ b/services/core/test/unittest/distributed_device_profile_client_rdb_test.cpp @@ -136,7 +136,7 @@ void DistributedDeviceProfileClientRdbTest::TearDown() int DistributedDeviceProfileClientRdbTest::ResultSize(std::shared_ptr &resultSet) { - if (resultSet == nullptr && resultSet->GoToFirstRow() != E_OK) { + if (resultSet == nullptr || resultSet->GoToFirstRow() != E_OK) { return 0; } int count; -- Gitee