diff --git a/av_transport/av_trans_engine/filters/test/av_transport_input_filter_test/av_transport_input_filter_test.cpp b/av_transport/av_trans_engine/filters/test/av_transport_input_filter_test/av_transport_input_filter_test.cpp index 3b1f42f11dbc9353b491323ae0d8aa0933f558b6..d44e5fe926c5c499b7c05290ebf4c062c18b31d8 100644 --- a/av_transport/av_trans_engine/filters/test/av_transport_input_filter_test/av_transport_input_filter_test.cpp +++ b/av_transport/av_trans_engine/filters/test/av_transport_input_filter_test/av_transport_input_filter_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -311,9 +311,6 @@ HWTEST_F(AvTransportInputFilterTest, ConfigMeta_001, testing::ext::TestSize.Leve { std::shared_ptr avInputTest_ = FilterFactory::Instance().CreateFilterWithType(AVINPUT_NAME, FILTERNAME); - if (avInputTest_ == nullptr) { - return; - } ASSERT_TRUE(avInputTest_ != nullptr); Plugin::Meta meta; ErrorCode ret = avInputTest_->ConfigMeta(meta); diff --git a/interfaces/inner_kits/test/unittest/common/distributedhardwarefwkkit/src/distributed_hardware_fwk_kit_test.cpp b/interfaces/inner_kits/test/unittest/common/distributedhardwarefwkkit/src/distributed_hardware_fwk_kit_test.cpp index e6b8961fc56a85ab9f7867e8a5069f4fe39786bd..24f8e7da3f6711699b426d0276dfab8438313835 100644 --- a/interfaces/inner_kits/test/unittest/common/distributedhardwarefwkkit/src/distributed_hardware_fwk_kit_test.cpp +++ b/interfaces/inner_kits/test/unittest/common/distributedhardwarefwkkit/src/distributed_hardware_fwk_kit_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -81,9 +81,7 @@ uint32_t DistributedHardwareFwkKitTest::TestPublisherListener::GetTopicMsgCnt(co */ HWTEST_F(DistributedHardwareFwkKitTest, RegisterPublisherListener_001, testing::ext::TestSize.Level0) { - if (dhfwkPtr_ == nullptr) { - return; - } + ASSERT_TRUE(dhfwkPtr_ != nullptr); sptr listener1(new TestPublisherListener()); int32_t ret = dhfwkPtr_->RegisterPublisherListener(DHTopic::TOPIC_START_DSCREEN, listener1); EXPECT_EQ(DH_FWK_SUCCESS, ret); @@ -121,9 +119,7 @@ HWTEST_F(DistributedHardwareFwkKitTest, RegisterPublisherListener_001, testing:: */ HWTEST_F(DistributedHardwareFwkKitTest, PublishMessage_001, testing::ext::TestSize.Level0) { - if (dhfwkPtr_ == nullptr) { - return; - } + ASSERT_TRUE(dhfwkPtr_ != nullptr); uint32_t invalid = 7; DHTopic topic = static_cast(invalid); std::string message; @@ -138,9 +134,7 @@ HWTEST_F(DistributedHardwareFwkKitTest, PublishMessage_001, testing::ext::TestSi */ HWTEST_F(DistributedHardwareFwkKitTest, PublishMessage_002, testing::ext::TestSize.Level0) { - if (dhfwkPtr_ == nullptr) { - return; - } + ASSERT_TRUE(dhfwkPtr_ != nullptr); DHTopic topic = DHTopic::TOPIC_STOP_DSCREEN; std::string message; EXPECT_EQ(ERR_DH_FWK_PARA_INVALID, dhfwkPtr_->PublishMessage(topic, message)); @@ -154,9 +148,7 @@ HWTEST_F(DistributedHardwareFwkKitTest, PublishMessage_002, testing::ext::TestSi */ HWTEST_F(DistributedHardwareFwkKitTest, PublishMessage_003, testing::ext::TestSize.Level0) { - if (dhfwkPtr_ == nullptr) { - return; - } + ASSERT_TRUE(dhfwkPtr_ != nullptr); DHTopic topic = DHTopic::TOPIC_STOP_DSCREEN; std::string message = "TOPIC_STOP_DSCREEN"; EXPECT_EQ(ERR_DH_FWK_PUBLISH_MSG_FAILED, dhfwkPtr_->PublishMessage(topic, message)); @@ -170,9 +162,7 @@ HWTEST_F(DistributedHardwareFwkKitTest, PublishMessage_003, testing::ext::TestSi */ HWTEST_F(DistributedHardwareFwkKitTest, PublishMessage_004, testing::ext::TestSize.Level0) { - if (dhfwkPtr_ == nullptr) { - return; - } + ASSERT_TRUE(dhfwkPtr_ != nullptr); DHTopic topic = DHTopic::TOPIC_STOP_DSCREEN; std::string message; uint32_t MAX_MESSAGE_LEN = 40 * 1024 * 1024 + 10; @@ -188,9 +178,7 @@ HWTEST_F(DistributedHardwareFwkKitTest, PublishMessage_004, testing::ext::TestSi */ HWTEST_F(DistributedHardwareFwkKitTest, OnDHFWKOnLine_001, testing::ext::TestSize.Level0) { - if (dhfwkPtr_ == nullptr) { - return; - } + ASSERT_TRUE(dhfwkPtr_ != nullptr); bool isOnLine = true; dhfwkPtr_->OnDHFWKOnLine(isOnLine); EXPECT_EQ(nullptr, DHFWKSAManager::GetInstance().GetDHFWKProxy()); @@ -204,9 +192,7 @@ HWTEST_F(DistributedHardwareFwkKitTest, OnDHFWKOnLine_001, testing::ext::TestSiz */ HWTEST_F(DistributedHardwareFwkKitTest, RegisterPublisherListener_002, testing::ext::TestSize.Level0) { - if (dhfwkPtr_ == nullptr) { - return; - } + ASSERT_TRUE(dhfwkPtr_ != nullptr); DHTopic topic = DHTopic::TOPIC_MIN; sptr listener = nullptr; int32_t ret = dhfwkPtr_->RegisterPublisherListener(topic, listener); @@ -221,9 +207,7 @@ HWTEST_F(DistributedHardwareFwkKitTest, RegisterPublisherListener_002, testing:: */ HWTEST_F(DistributedHardwareFwkKitTest, RegisterPublisherListener_003, testing::ext::TestSize.Level0) { - if (dhfwkPtr_ == nullptr) { - return; - } + ASSERT_TRUE(dhfwkPtr_ != nullptr); DHTopic topic = DHTopic::TOPIC_START_DSCREEN; sptr listener = nullptr; int32_t ret = dhfwkPtr_->RegisterPublisherListener(topic, listener); @@ -238,9 +222,7 @@ HWTEST_F(DistributedHardwareFwkKitTest, RegisterPublisherListener_003, testing:: */ HWTEST_F(DistributedHardwareFwkKitTest, UnregisterPublisherListener_001, testing::ext::TestSize.Level0) { - if (dhfwkPtr_ == nullptr) { - return; - } + ASSERT_TRUE(dhfwkPtr_ != nullptr); DHTopic topic = DHTopic::TOPIC_MIN; sptr listener = nullptr; int32_t ret = dhfwkPtr_->UnregisterPublisherListener(topic, listener); @@ -255,9 +237,7 @@ HWTEST_F(DistributedHardwareFwkKitTest, UnregisterPublisherListener_001, testing */ HWTEST_F(DistributedHardwareFwkKitTest, UnregisterPublisherListener_002, testing::ext::TestSize.Level0) { - if (dhfwkPtr_ == nullptr) { - return; - } + ASSERT_TRUE(dhfwkPtr_ != nullptr); DHTopic topic = DHTopic::TOPIC_START_DSCREEN; sptr listener = nullptr; int32_t ret = dhfwkPtr_->UnregisterPublisherListener(topic, listener); @@ -272,9 +252,7 @@ HWTEST_F(DistributedHardwareFwkKitTest, UnregisterPublisherListener_002, testing */ HWTEST_F(DistributedHardwareFwkKitTest, QueryLocalSysSpec_001, testing::ext::TestSize.Level0) { - if (dhfwkPtr_ == nullptr) { - return; - } + ASSERT_TRUE(dhfwkPtr_ != nullptr); QueryLocalSysSpecType spec = QueryLocalSysSpecType::MIN; std::string ret = dhfwkPtr_->QueryLocalSysSpec(spec); EXPECT_EQ(true, ret.empty()); @@ -288,9 +266,7 @@ HWTEST_F(DistributedHardwareFwkKitTest, QueryLocalSysSpec_001, testing::ext::Tes */ HWTEST_F(DistributedHardwareFwkKitTest, QueryLocalSysSpec_002, testing::ext::TestSize.Level0) { - if (dhfwkPtr_ == nullptr) { - return; - } + ASSERT_TRUE(dhfwkPtr_ != nullptr); QueryLocalSysSpecType spec = QueryLocalSysSpecType::HISTREAMER_AUDIO_ENCODER; std::string ret = dhfwkPtr_->QueryLocalSysSpec(spec); EXPECT_EQ(true, ret.empty()); @@ -304,9 +280,7 @@ HWTEST_F(DistributedHardwareFwkKitTest, QueryLocalSysSpec_002, testing::ext::Tes */ HWTEST_F(DistributedHardwareFwkKitTest, InitializeAVCenter_001, testing::ext::TestSize.Level0) { - if (dhfwkPtr_ == nullptr) { - return; - } + ASSERT_TRUE(dhfwkPtr_ != nullptr); TransRole transRole = TransRole::UNKNOWN; int32_t engineId = 0; int32_t ret = dhfwkPtr_->InitializeAVCenter(transRole, engineId); @@ -321,9 +295,7 @@ HWTEST_F(DistributedHardwareFwkKitTest, InitializeAVCenter_001, testing::ext::Te */ HWTEST_F(DistributedHardwareFwkKitTest, ReleaseAVCenter_001, testing::ext::TestSize.Level0) { - if (dhfwkPtr_ == nullptr) { - return; - } + ASSERT_TRUE(dhfwkPtr_ != nullptr); int32_t engineId = 0; int32_t ret = dhfwkPtr_->ReleaseAVCenter(engineId); EXPECT_EQ(ERR_DH_FWK_POINTER_IS_NULL, ret); @@ -337,9 +309,7 @@ HWTEST_F(DistributedHardwareFwkKitTest, ReleaseAVCenter_001, testing::ext::TestS */ HWTEST_F(DistributedHardwareFwkKitTest, CreateControlChannel_001, testing::ext::TestSize.Level0) { - if (dhfwkPtr_ == nullptr) { - return; - } + ASSERT_TRUE(dhfwkPtr_ != nullptr); int32_t engineId = 0; std::string peerDevId = "peerDevId_test"; int32_t ret = dhfwkPtr_->CreateControlChannel(engineId, peerDevId); @@ -354,9 +324,7 @@ HWTEST_F(DistributedHardwareFwkKitTest, CreateControlChannel_001, testing::ext:: */ HWTEST_F(DistributedHardwareFwkKitTest, NotifyAVCenter_001, testing::ext::TestSize.Level0) { - if (dhfwkPtr_ == nullptr) { - return; - } + ASSERT_TRUE(dhfwkPtr_ != nullptr); int32_t engineId = 0; AVTransEvent event; int32_t ret = dhfwkPtr_->NotifyAVCenter(engineId, event); diff --git a/interfaces/inner_kits/test/unittest/common/ipc/dhfwk_sa_manager/src/dhfwk_sa_manager_test.cpp b/interfaces/inner_kits/test/unittest/common/ipc/dhfwk_sa_manager/src/dhfwk_sa_manager_test.cpp index 8b3a7a7711733adab4b01945e7d6bf415e36600d..b312d665cbe7648bee5f2338e511df8ac3309921 100644 --- a/interfaces/inner_kits/test/unittest/common/ipc/dhfwk_sa_manager/src/dhfwk_sa_manager_test.cpp +++ b/interfaces/inner_kits/test/unittest/common/ipc/dhfwk_sa_manager/src/dhfwk_sa_manager_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -121,9 +121,7 @@ HWTEST_F(DHFWKSAManagerTest, OnAddSystemAbility_001, TestSize.Level0) { DHFWKSAManager::GetInstance().saListener_ = sptr(new DHFWKSAManager::SystemAbilityListener()); - if (DHFWKSAManager::GetInstance().saListener_ == nullptr) { - return; - } + ASSERT_TRUE(DHFWKSAManager::GetInstance().saListener_ != nullptr); int32_t systemAbilityId = 1; std::string deviceId = "deviceId"; DHFWKSAManager::GetInstance().saListener_->OnAddSystemAbility(systemAbilityId, deviceId); @@ -140,9 +138,7 @@ HWTEST_F(DHFWKSAManagerTest, OnAddSystemAbility_002, TestSize.Level0) { DHFWKSAManager::GetInstance().saListener_ = sptr(new DHFWKSAManager::SystemAbilityListener()); - if (DHFWKSAManager::GetInstance().saListener_ == nullptr) { - return; - } + ASSERT_TRUE(DHFWKSAManager::GetInstance().saListener_ != nullptr); int32_t systemAbilityId = DISTRIBUTED_HARDWARE_SA_ID; std::string deviceId = "deviceId"; DHFWKSAManager::GetInstance().saListener_->OnAddSystemAbility(systemAbilityId, deviceId); @@ -159,9 +155,7 @@ HWTEST_F(DHFWKSAManagerTest, OnAddSystemAbility_003, TestSize.Level0) { DHFWKSAManager::GetInstance().saListener_ = sptr(new DHFWKSAManager::SystemAbilityListener()); - if (DHFWKSAManager::GetInstance().saListener_ == nullptr) { - return; - } + ASSERT_TRUE(DHFWKSAManager::GetInstance().saListener_ != nullptr); int32_t systemAbilityId = DISTRIBUTED_HARDWARE_SA_ID; std::string deviceId = "deviceId"; DHFWKSAManager::GetInstance().saStateCallback_ = DHFWKSaStateCallback; @@ -179,9 +173,7 @@ HWTEST_F(DHFWKSAManagerTest, OnRemoveSystemAbility_001, TestSize.Level0) { DHFWKSAManager::GetInstance().saListener_ = sptr(new DHFWKSAManager::SystemAbilityListener()); - if (DHFWKSAManager::GetInstance().saListener_ == nullptr) { - return; - } + ASSERT_TRUE(DHFWKSAManager::GetInstance().saListener_ != nullptr); int32_t systemAbilityId = 1; std::string deviceId = "deviceId"; DHFWKSAManager::GetInstance().saListener_->OnRemoveSystemAbility(systemAbilityId, deviceId); @@ -198,9 +190,7 @@ HWTEST_F(DHFWKSAManagerTest, OnRemoveSystemAbility_002, TestSize.Level0) { DHFWKSAManager::GetInstance().saListener_ = sptr(new DHFWKSAManager::SystemAbilityListener()); - if (DHFWKSAManager::GetInstance().saListener_ == nullptr) { - return; - } + ASSERT_TRUE(DHFWKSAManager::GetInstance().saListener_ != nullptr); int32_t systemAbilityId = DISTRIBUTED_HARDWARE_SA_ID; std::string deviceId = "deviceId"; DHFWKSAManager::GetInstance().saListener_->OnRemoveSystemAbility(systemAbilityId, deviceId); @@ -217,9 +207,7 @@ HWTEST_F(DHFWKSAManagerTest, OnRemoveSystemAbility_003, TestSize.Level0) { DHFWKSAManager::GetInstance().saListener_ = sptr(new DHFWKSAManager::SystemAbilityListener()); - if (DHFWKSAManager::GetInstance().saListener_ == nullptr) { - return; - } + ASSERT_TRUE(DHFWKSAManager::GetInstance().saListener_ != nullptr); int32_t systemAbilityId = DISTRIBUTED_HARDWARE_SA_ID; std::string deviceId = "deviceId"; DHFWKSAManager::GetInstance().saStateCallback_ = DHFWKSaStateCallback; diff --git a/interfaces/inner_kits/test/unittest/common/ipc/distributed_hardware_proxy/src/distributed_hardware_proxy_test.cpp b/interfaces/inner_kits/test/unittest/common/ipc/distributed_hardware_proxy/src/distributed_hardware_proxy_test.cpp index bf6c7a6119066f403bd71f8186c516182ec84f19..46f97dc6fa83530d49e4d559aeaa98bd143cf9a1 100644 --- a/interfaces/inner_kits/test/unittest/common/ipc/distributed_hardware_proxy/src/distributed_hardware_proxy_test.cpp +++ b/interfaces/inner_kits/test/unittest/common/ipc/distributed_hardware_proxy/src/distributed_hardware_proxy_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -46,9 +46,7 @@ void DistributedHardwareProxyTest::TearDown() */ HWTEST_F(DistributedHardwareProxyTest, RegisterPublisherListener_001, TestSize.Level0) { - if (hardwareProxy_ == nullptr) { - return; - } + ASSERT_TRUE(hardwareProxy_ != nullptr); DHTopic topic = DHTopic::TOPIC_STOP_DSCREEN; sptr listener = nullptr; int32_t ret = hardwareProxy_->RegisterPublisherListener(topic, listener); @@ -63,9 +61,7 @@ HWTEST_F(DistributedHardwareProxyTest, RegisterPublisherListener_001, TestSize.L */ HWTEST_F(DistributedHardwareProxyTest, RegisterAbilityListener_002, TestSize.Level0) { - if (hardwareProxy_ == nullptr) { - return; - } + ASSERT_TRUE(hardwareProxy_ != nullptr); int32_t invalid = 7; DHTopic topic = static_cast(invalid); sptr listener(new MockIPublisherListener()); @@ -81,9 +77,7 @@ HWTEST_F(DistributedHardwareProxyTest, RegisterAbilityListener_002, TestSize.Lev */ HWTEST_F(DistributedHardwareProxyTest, RegisterAbilityListener_003, TestSize.Level0) { - if (hardwareProxy_ == nullptr) { - return; - } + ASSERT_TRUE(hardwareProxy_ != nullptr); DHTopic topic = DHTopic::TOPIC_STOP_DSCREEN; sptr listener(new MockIPublisherListener()); int32_t ret = hardwareProxy_->RegisterPublisherListener(topic, listener); @@ -98,9 +92,7 @@ HWTEST_F(DistributedHardwareProxyTest, RegisterAbilityListener_003, TestSize.Lev */ HWTEST_F(DistributedHardwareProxyTest, UnregisterPublisherListener_001, TestSize.Level0) { - if (hardwareProxy_ == nullptr) { - return; - } + ASSERT_TRUE(hardwareProxy_ != nullptr); DHTopic topic = DHTopic::TOPIC_STOP_DSCREEN; sptr listener = nullptr; int32_t ret = hardwareProxy_->UnregisterPublisherListener(topic, listener); @@ -115,9 +107,7 @@ HWTEST_F(DistributedHardwareProxyTest, UnregisterPublisherListener_001, TestSize */ HWTEST_F(DistributedHardwareProxyTest, UnregisterPublisherListener_002, TestSize.Level0) { - if (hardwareProxy_ == nullptr) { - return; - } + ASSERT_TRUE(hardwareProxy_ != nullptr); int32_t invalid = 7; DHTopic topic = static_cast(invalid); sptr listener(new MockIPublisherListener()); @@ -133,9 +123,7 @@ HWTEST_F(DistributedHardwareProxyTest, UnregisterPublisherListener_002, TestSize */ HWTEST_F(DistributedHardwareProxyTest, UnregisterPublisherListener_003, TestSize.Level0) { - if (hardwareProxy_ == nullptr) { - return; - } + ASSERT_TRUE(hardwareProxy_ != nullptr); DHTopic topic = DHTopic::TOPIC_STOP_DSCREEN; sptr listener(new MockIPublisherListener()); int32_t ret = hardwareProxy_->UnregisterPublisherListener(topic, listener); @@ -150,9 +138,7 @@ HWTEST_F(DistributedHardwareProxyTest, UnregisterPublisherListener_003, TestSize */ HWTEST_F(DistributedHardwareProxyTest, PublishMessage_001, TestSize.Level0) { - if (hardwareProxy_ == nullptr) { - return; - } + ASSERT_TRUE(hardwareProxy_ != nullptr); int32_t invalid = 7; std::string msg; DHTopic topic = static_cast(invalid); @@ -168,9 +154,7 @@ HWTEST_F(DistributedHardwareProxyTest, PublishMessage_001, TestSize.Level0) */ HWTEST_F(DistributedHardwareProxyTest, PublishMessage_002, TestSize.Level0) { - if (hardwareProxy_ == nullptr) { - return; - } + ASSERT_TRUE(hardwareProxy_ != nullptr); DHTopic topic = DHTopic::TOPIC_STOP_DSCREEN; std::string msg; int32_t ret = hardwareProxy_->PublishMessage(topic, msg); @@ -185,9 +169,7 @@ HWTEST_F(DistributedHardwareProxyTest, PublishMessage_002, TestSize.Level0) */ HWTEST_F(DistributedHardwareProxyTest, PublishMessage_003, TestSize.Level0) { - if (hardwareProxy_ == nullptr) { - return; - } + ASSERT_TRUE(hardwareProxy_ != nullptr); DHTopic topic = DHTopic::TOPIC_STOP_DSCREEN; std::string msg = "msg"; int32_t ret = hardwareProxy_->PublishMessage(topic, msg); @@ -202,9 +184,7 @@ HWTEST_F(DistributedHardwareProxyTest, PublishMessage_003, TestSize.Level0) */ HWTEST_F(DistributedHardwareProxyTest, QueryLocalSysSpec_001, TestSize.Level0) { - if (hardwareProxy_ == nullptr) { - return; - } + ASSERT_TRUE(hardwareProxy_ != nullptr); QueryLocalSysSpecType spec = QueryLocalSysSpecType::MIN; std::string ret = hardwareProxy_->QueryLocalSysSpec(spec); EXPECT_EQ(true, ret.empty()); @@ -218,9 +198,7 @@ HWTEST_F(DistributedHardwareProxyTest, QueryLocalSysSpec_001, TestSize.Level0) */ HWTEST_F(DistributedHardwareProxyTest, InitializeAVCenter_001, TestSize.Level0) { - if (hardwareProxy_ == nullptr) { - return; - } + ASSERT_TRUE(hardwareProxy_ != nullptr); TransRole transRole = TransRole::UNKNOWN;; int32_t engineId = 0; int32_t ret = hardwareProxy_->InitializeAVCenter(transRole, engineId); @@ -235,9 +213,7 @@ HWTEST_F(DistributedHardwareProxyTest, InitializeAVCenter_001, TestSize.Level0) */ HWTEST_F(DistributedHardwareProxyTest, ReleaseAVCenter_001, TestSize.Level0) { - if (hardwareProxy_ == nullptr) { - return; - } + ASSERT_TRUE(hardwareProxy_ != nullptr); int32_t engineId = 0; int32_t ret = hardwareProxy_->ReleaseAVCenter(engineId); EXPECT_EQ(ERR_DH_AVT_SERVICE_REMOTE_IS_NULL, ret); @@ -251,9 +227,7 @@ HWTEST_F(DistributedHardwareProxyTest, ReleaseAVCenter_001, TestSize.Level0) */ HWTEST_F(DistributedHardwareProxyTest, CreateControlChannel_001, TestSize.Level0) { - if (hardwareProxy_ == nullptr) { - return; - } + ASSERT_TRUE(hardwareProxy_ != nullptr); int32_t engineId = 0; std::string peerDevId = "peerDevId_test"; int32_t ret = hardwareProxy_->CreateControlChannel(engineId, peerDevId); @@ -268,9 +242,7 @@ HWTEST_F(DistributedHardwareProxyTest, CreateControlChannel_001, TestSize.Level0 */ HWTEST_F(DistributedHardwareProxyTest, NotifyAVCenter_001, TestSize.Level0) { - if (hardwareProxy_ == nullptr) { - return; - } + ASSERT_TRUE(hardwareProxy_ != nullptr); int32_t engineId = 0; AVTransEvent event; int32_t ret = hardwareProxy_->NotifyAVCenter(engineId, event); @@ -285,9 +257,7 @@ HWTEST_F(DistributedHardwareProxyTest, NotifyAVCenter_001, TestSize.Level0) */ HWTEST_F(DistributedHardwareProxyTest, NotifySourceRemoteSinkStarted_001, TestSize.Level0) { - if (hardwareProxy_ == nullptr) { - return; - } + ASSERT_TRUE(hardwareProxy_ != nullptr); std::string deviceId = "devid_test"; int32_t ret = hardwareProxy_->NotifySourceRemoteSinkStarted(deviceId); EXPECT_EQ(ERR_DH_AVT_SERVICE_REMOTE_IS_NULL, ret); @@ -301,9 +271,7 @@ HWTEST_F(DistributedHardwareProxyTest, NotifySourceRemoteSinkStarted_001, TestSi */ HWTEST_F(DistributedHardwareProxyTest, PauseDistributedHardware_001, TestSize.Level0) { - if (hardwareProxy_ == nullptr) { - return; - } + ASSERT_TRUE(hardwareProxy_ != nullptr); DHType dhType = DHType::CAMERA; std::string networkId = "networkId_test"; int32_t ret = hardwareProxy_->PauseDistributedHardware(dhType, networkId); @@ -318,9 +286,7 @@ HWTEST_F(DistributedHardwareProxyTest, PauseDistributedHardware_001, TestSize.Le */ HWTEST_F(DistributedHardwareProxyTest, ResumeDistributedHardware_001, TestSize.Level0) { - if (hardwareProxy_ == nullptr) { - return; - } + ASSERT_TRUE(hardwareProxy_ != nullptr); DHType dhType = DHType::CAMERA; std::string networkId = "networkId_test"; int32_t ret = hardwareProxy_->ResumeDistributedHardware(dhType, networkId); @@ -335,9 +301,7 @@ HWTEST_F(DistributedHardwareProxyTest, ResumeDistributedHardware_001, TestSize.L */ HWTEST_F(DistributedHardwareProxyTest, StopDistributedHardware_001, TestSize.Level0) { - if (hardwareProxy_ == nullptr) { - return; - } + ASSERT_TRUE(hardwareProxy_ != nullptr); DHType dhType = DHType::CAMERA; std::string networkId = "networkId_test"; int32_t ret = hardwareProxy_->StopDistributedHardware(dhType, networkId); diff --git a/services/distributedhardwarefwkservice/test/unittest/common/componentloader/src/component_loader_test.cpp b/services/distributedhardwarefwkservice/test/unittest/common/componentloader/src/component_loader_test.cpp index 0863daf8b87bee7c93fad9b39cb7ca394d0f4b2e..ef6c796bb0fb82d71b4f0ade4b1132fcccbec706 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/componentloader/src/component_loader_test.cpp +++ b/services/distributedhardwarefwkservice/test/unittest/common/componentloader/src/component_loader_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -299,9 +299,7 @@ HWTEST_F(ComponentLoaderTest, component_loader_test_018, TestSize.Level0) const char *TYPE = "TYPE"; const char *PATH = "PATH"; cJSON* json0bject = cJSON_CreateObject(); - if (json0bject == nullptr) { - return; - } + ASSERT_TRUE(json0bject != nullptr); cJSON* compVers = cJSON_CreateObject(); if (compVers == nullptr) { cJSON_Delete(json0bject); @@ -457,9 +455,7 @@ HWTEST_F(ComponentLoaderTest, component_loader_test_029, TestSize.Level0) { CompConfig cfg; cJSON *json = cJSON_CreateObject(); - if (json == nullptr) { - return; - } + ASSERT_TRUE(json != nullptr); cJSON_AddNumberToObject(json, COMP_NAME.c_str(), 4801); from_json(json, cfg); @@ -477,9 +473,7 @@ HWTEST_F(ComponentLoaderTest, component_loader_test_030, TestSize.Level0) { CompConfig cfg; cJSON *json = cJSON_CreateObject(); - if (json == nullptr) { - return; - } + ASSERT_TRUE(json != nullptr); cJSON_AddStringToObject(json, COMP_NAME.c_str(), "name"); cJSON_AddNumberToObject(json, COMP_TYPE.c_str(), 0x02); @@ -498,9 +492,7 @@ HWTEST_F(ComponentLoaderTest, component_loader_test_031, TestSize.Level0) { CompConfig cfg; cJSON *json = cJSON_CreateObject(); - if (json == nullptr) { - return; - } + ASSERT_TRUE(json != nullptr); cJSON_AddStringToObject(json, COMP_NAME.c_str(), "name"); cJSON_AddStringToObject(json, COMP_TYPE.c_str(), "DHType::AUDIO"); cJSON_AddNumberToObject(json, COMP_HANDLER_LOC.c_str(), 4801); @@ -520,9 +512,7 @@ HWTEST_F(ComponentLoaderTest, component_loader_test_032, TestSize.Level0) { CompConfig cfg; cJSON *json = cJSON_CreateObject(); - if (json == nullptr) { - return; - } + ASSERT_TRUE(json != nullptr); cJSON_AddStringToObject(json, COMP_NAME.c_str(), "name"); cJSON_AddStringToObject(json, COMP_TYPE.c_str(), "DHType::AUDIO"); cJSON_AddStringToObject(json, COMP_HANDLER_LOC.c_str(), "comp_handler_loc"); @@ -543,9 +533,7 @@ HWTEST_F(ComponentLoaderTest, component_loader_test_033, TestSize.Level0) { CompConfig cfg; cJSON *json = cJSON_CreateObject(); - if (json == nullptr) { - return; - } + ASSERT_TRUE(json != nullptr); cJSON_AddStringToObject(json, COMP_NAME.c_str(), "name"); cJSON_AddStringToObject(json, COMP_TYPE.c_str(), "DHType::AUDIO"); cJSON_AddStringToObject(json, COMP_HANDLER_LOC.c_str(), "comp_handler_loc"); @@ -567,9 +555,7 @@ HWTEST_F(ComponentLoaderTest, component_loader_test_034, TestSize.Level0) { CompConfig cfg; cJSON *json = cJSON_CreateObject(); - if (json == nullptr) { - return; - } + ASSERT_TRUE(json != nullptr); cJSON_AddStringToObject(json, COMP_NAME.c_str(), "name"); cJSON_AddStringToObject(json, COMP_TYPE.c_str(), "DHType::AUDIO"); cJSON_AddStringToObject(json, COMP_HANDLER_LOC.c_str(), "comp_handler_loc"); @@ -592,9 +578,7 @@ HWTEST_F(ComponentLoaderTest, component_loader_test_035, TestSize.Level0) { CompConfig cfg; cJSON *json = cJSON_CreateObject(); - if (json == nullptr) { - return; - } + ASSERT_TRUE(json != nullptr); cJSON_AddStringToObject(json, COMP_NAME.c_str(), "name"); cJSON_AddStringToObject(json, COMP_TYPE.c_str(), "DHType::AUDIO"); cJSON_AddStringToObject(json, COMP_HANDLER_LOC.c_str(), "comp_handler_loc"); @@ -618,9 +602,7 @@ HWTEST_F(ComponentLoaderTest, component_loader_test_036, TestSize.Level0) { CompConfig cfg; cJSON *json = cJSON_CreateObject(); - if (json == nullptr) { - return; - } + ASSERT_TRUE(json != nullptr); cJSON_AddStringToObject(json, COMP_NAME.c_str(), "name"); cJSON_AddStringToObject(json, COMP_TYPE.c_str(), "DHType::AUDIO"); cJSON_AddStringToObject(json, COMP_HANDLER_LOC.c_str(), "comp_handler_loc"); @@ -645,9 +627,7 @@ HWTEST_F(ComponentLoaderTest, component_loader_test_037, TestSize.Level0) { CompConfig cfg; cJSON *json = cJSON_CreateObject(); - if (json == nullptr) { - return; - } + ASSERT_TRUE(json != nullptr); cJSON_AddStringToObject(json, COMP_NAME.c_str(), "name"); cJSON_AddStringToObject(json, COMP_TYPE.c_str(), "DHType::AUDIO"); cJSON_AddStringToObject(json, COMP_HANDLER_LOC.c_str(), "comp_handler_loc"); @@ -673,9 +653,7 @@ HWTEST_F(ComponentLoaderTest, component_loader_test_038, TestSize.Level0) { CompConfig cfg; cJSON *json = cJSON_CreateObject(); - if (json == nullptr) { - return; - } + ASSERT_TRUE(json != nullptr); cJSON_AddStringToObject(json, COMP_NAME.c_str(), "name"); cJSON_AddStringToObject(json, COMP_TYPE.c_str(), "DHType::AUDIO"); cJSON_AddStringToObject(json, COMP_HANDLER_LOC.c_str(), "comp_handler_loc"); @@ -702,9 +680,7 @@ HWTEST_F(ComponentLoaderTest, component_loader_test_039, TestSize.Level0) { CompConfig cfg; cJSON *json = cJSON_CreateObject(); - if (json == nullptr) { - return; - } + ASSERT_TRUE(json != nullptr); cJSON_AddStringToObject(json, COMP_NAME.c_str(), "name"); cJSON_AddStringToObject(json, COMP_TYPE.c_str(), "DHType::AUDIO"); cJSON_AddStringToObject(json, COMP_HANDLER_LOC.c_str(), "comp_handler_loc"); @@ -725,9 +701,7 @@ HWTEST_F(ComponentLoaderTest, ParseSink_001, TestSize.Level0) { CompConfig cfg; cJSON *json = cJSON_CreateObject(); - if (json == nullptr) { - return; - } + ASSERT_TRUE(json != nullptr); cJSON_AddNumberToObject(json, COMP_SINK_LOC.c_str(), 100); auto ret = ParseSink(json, cfg); cJSON_Delete(json); @@ -738,9 +712,7 @@ HWTEST_F(ComponentLoaderTest, ParseSink_002, TestSize.Level0) { CompConfig cfg; cJSON *json = cJSON_CreateObject(); - if (json == nullptr) { - return; - } + ASSERT_TRUE(json != nullptr); cJSON_AddStringToObject(json, COMP_SINK_LOC.c_str(), "comp_sink_loc_test"); cJSON_AddNumberToObject(json, COMP_SINK_VERSION.c_str(), 100); auto ret = ParseSink(json, cfg); @@ -752,9 +724,7 @@ HWTEST_F(ComponentLoaderTest, ParseSink_003, TestSize.Level0) { CompConfig cfg; cJSON *json = cJSON_CreateObject(); - if (json == nullptr) { - return; - } + ASSERT_TRUE(json != nullptr); cJSON_AddStringToObject(json, COMP_SINK_LOC.c_str(), "comp_sink_loc_test"); cJSON_AddStringToObject(json, COMP_SINK_VERSION.c_str(), "1.0"); cJSON_AddStringToObject(json, COMP_SINK_SA_ID.c_str(), "comp_sink_sa_id_test"); @@ -767,9 +737,7 @@ HWTEST_F(ComponentLoaderTest, ParseSink_004, TestSize.Level0) { CompConfig cfg; cJSON *json = cJSON_CreateObject(); - if (json == nullptr) { - return; - } + ASSERT_TRUE(json != nullptr); cJSON_AddStringToObject(json, COMP_SINK_LOC.c_str(), "comp_sink_loc_test"); cJSON_AddStringToObject(json, COMP_SINK_VERSION.c_str(), "1.0"); cJSON_AddNumberToObject(json, COMP_SINK_SA_ID.c_str(), 4801); @@ -782,9 +750,7 @@ HWTEST_F(ComponentLoaderTest, ParseResourceDesc_001, TestSize.Level0) { CompConfig cfg; cJSON *array = cJSON_CreateArray(); - if (array == nullptr) { - return; - } + ASSERT_TRUE(array != nullptr); cJSON *obj = cJSON_CreateObject(); if (obj == nullptr) { cJSON_Delete(array); @@ -804,9 +770,7 @@ HWTEST_F(ComponentLoaderTest, ParseResourceDesc_001, TestSize.Level0) CompConfig config; cJSON *component = cJSON_CreateObject(); - if (component == nullptr) { - return; - } + ASSERT_TRUE(component != nullptr); cJSON_AddNumberToObject(component, COMP_NAME.c_str(), 1); cJSON_AddNumberToObject(component, COMP_TYPE.c_str(), 1); cJSON_AddNumberToObject(component, COMP_HANDLER_LOC.c_str(), 1); @@ -827,9 +791,7 @@ HWTEST_F(ComponentLoaderTest, ParseResourceDesc_002, TestSize.Level0) { CompConfig cfg; cJSON *json = cJSON_CreateObject(); - if (json == nullptr) { - return; - } + ASSERT_TRUE(json != nullptr); cJSON_AddNumberToObject(json, COMP_NAME.c_str(), 100); auto ret = ParseComponent(json, cfg); cJSON_Delete(json); @@ -837,9 +799,7 @@ HWTEST_F(ComponentLoaderTest, ParseResourceDesc_002, TestSize.Level0) CompConfig config1; cJSON *component1 = cJSON_CreateObject(); - if (component1 == nullptr) { - return; - } + ASSERT_TRUE(component1 != nullptr); cJSON_AddStringToObject(component1, COMP_NAME.c_str(), "comp_name_test"); cJSON_AddStringToObject(component1, COMP_TYPE.c_str(), "comp_type_test"); cJSON_AddStringToObject(component1, COMP_HANDLER_LOC.c_str(), "comp_handler_loc_test"); @@ -900,17 +860,13 @@ HWTEST_F(ComponentLoaderTest, from_json_001, TestSize.Level0) { CompConfig cfg; cJSON *json = cJSON_CreateObject(); - if (json == nullptr) { - return; - } + ASSERT_TRUE(json != nullptr); cJSON_AddNumberToObject(json, COMP_NAME.c_str(), 100); from_json(json, cfg); cJSON_Delete(json); cJSON *Json1 = cJSON_CreateObject(); - if (Json1 == nullptr) { - return; - } + ASSERT_TRUE(Json1 != nullptr); cJSON_AddStringToObject(Json1, COMP_NAME.c_str(), "comp_name_test"); cJSON_AddStringToObject(Json1, COMP_TYPE.c_str(), "comp_type_test"); cJSON_AddStringToObject(Json1, COMP_HANDLER_LOC.c_str(), "comp_handler_loc_test"); @@ -920,9 +876,7 @@ HWTEST_F(ComponentLoaderTest, from_json_001, TestSize.Level0) cJSON_Delete(Json1); cJSON *Json2 = cJSON_CreateObject(); - if (Json2 == nullptr) { - return; - } + ASSERT_TRUE(Json2 != nullptr); cJSON_AddStringToObject(Json2, COMP_NAME.c_str(), "comp_name_test"); cJSON_AddStringToObject(Json2, COMP_TYPE.c_str(), "comp_type_test"); cJSON_AddStringToObject(Json2, COMP_HANDLER_LOC.c_str(), "comp_handler_loc_test"); @@ -939,9 +893,7 @@ HWTEST_F(ComponentLoaderTest, ParseComponent_001, TestSize.Level0) { CompConfig cfg; cJSON *json = cJSON_CreateObject(); - if (json == nullptr) { - return; - } + ASSERT_TRUE(json != nullptr); cJSON_AddNumberToObject(json, COMP_NAME.c_str(), 100); auto ret = ParseComponent(json, cfg); cJSON_Delete(json); @@ -952,9 +904,7 @@ HWTEST_F(ComponentLoaderTest, ParseComponent_002, TestSize.Level0) { CompConfig cfg; cJSON *json = cJSON_CreateObject(); - if (json == nullptr) { - return; - } + ASSERT_TRUE(json != nullptr); cJSON_AddStringToObject(json, COMP_NAME.c_str(), "comp_name_test"); cJSON_AddNumberToObject(json, COMP_TYPE.c_str(), 100); auto ret = ParseComponent(json, cfg); @@ -966,9 +916,7 @@ HWTEST_F(ComponentLoaderTest, ParseComponent_003, TestSize.Level0) { CompConfig cfg; cJSON *json = cJSON_CreateObject(); - if (json == nullptr) { - return; - } + ASSERT_TRUE(json != nullptr); cJSON_AddStringToObject(json, COMP_NAME.c_str(), "comp_name_test"); cJSON_AddStringToObject(json, COMP_TYPE.c_str(), "comp_type_test"); cJSON_AddNumberToObject(json, COMP_HANDLER_LOC.c_str(), 100); @@ -981,9 +929,7 @@ HWTEST_F(ComponentLoaderTest, ParseComponent_004, TestSize.Level0) { CompConfig cfg; cJSON *json = cJSON_CreateObject(); - if (json == nullptr) { - return; - } + ASSERT_TRUE(json != nullptr); cJSON_AddStringToObject(json, COMP_NAME.c_str(), "comp_name_test"); cJSON_AddStringToObject(json, COMP_TYPE.c_str(), "comp_type_test"); cJSON_AddStringToObject(json, COMP_HANDLER_LOC.c_str(), "comp_handler_loc_test"); @@ -997,9 +943,7 @@ HWTEST_F(ComponentLoaderTest, ParseComponent_005, TestSize.Level0) { CompConfig cfg; cJSON *json = cJSON_CreateObject(); - if (json == nullptr) { - return; - } + ASSERT_TRUE(json != nullptr); cJSON_AddStringToObject(json, COMP_NAME.c_str(), "comp_name_test"); cJSON_AddStringToObject(json, COMP_TYPE.c_str(), "comp_type_test"); cJSON_AddStringToObject(json, COMP_HANDLER_LOC.c_str(), "comp_handler_loc_test"); @@ -1013,9 +957,7 @@ HWTEST_F(ComponentLoaderTest, ParseSource_001, TestSize.Level0) { CompConfig cfg; cJSON *json = cJSON_CreateObject(); - if (json == nullptr) { - return; - } + ASSERT_TRUE(json != nullptr); cJSON_AddNumberToObject(json, COMP_SOURCE_LOC.c_str(), 100); auto ret = ParseSource(json, cfg); cJSON_Delete(json); @@ -1026,9 +968,7 @@ HWTEST_F(ComponentLoaderTest, ParseSource_002, TestSize.Level0) { CompConfig cfg; cJSON *json = cJSON_CreateObject(); - if (json == nullptr) { - return; - } + ASSERT_TRUE(json != nullptr); cJSON_AddStringToObject(json, COMP_SOURCE_LOC.c_str(), "comp_source_loc_test"); cJSON_AddNumberToObject(json, COMP_SOURCE_VERSION.c_str(), 100); auto ret = ParseSource(json, cfg); @@ -1040,9 +980,7 @@ HWTEST_F(ComponentLoaderTest, ParseSource_003, TestSize.Level0) { CompConfig cfg; cJSON *json = cJSON_CreateObject(); - if (json == nullptr) { - return; - } + ASSERT_TRUE(json != nullptr); cJSON_AddStringToObject(json, COMP_SOURCE_LOC.c_str(), "comp_source_loc_test"); cJSON_AddStringToObject(json, COMP_SOURCE_VERSION.c_str(), "1.0"); cJSON_AddStringToObject(json, COMP_SOURCE_SA_ID.c_str(), "4801"); @@ -1055,9 +993,7 @@ HWTEST_F(ComponentLoaderTest, ParseSource_004, TestSize.Level0) { CompConfig cfg; cJSON *json = cJSON_CreateObject(); - if (json == nullptr) { - return; - } + ASSERT_TRUE(json != nullptr); cJSON_AddStringToObject(json, COMP_SOURCE_LOC.c_str(), "comp_source_loc_test"); cJSON_AddStringToObject(json, COMP_SOURCE_VERSION.c_str(), "1.0"); cJSON_AddNumberToObject(json, COMP_SOURCE_SA_ID.c_str(), 4801); diff --git a/services/distributedhardwarefwkservice/test/unittest/common/componentmanager/component_monitior/src/component_monitor_test.cpp b/services/distributedhardwarefwkservice/test/unittest/common/componentmanager/component_monitior/src/component_monitor_test.cpp index 2be9f75256724cfa4b4cf68ebb73d505ba953569..d8c0df599716091ec3e805c3bae5f9c825cce1f1 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/componentmanager/component_monitior/src/component_monitor_test.cpp +++ b/services/distributedhardwarefwkservice/test/unittest/common/componentmanager/component_monitior/src/component_monitor_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -55,9 +55,7 @@ void ComponentMonitorTest::TearDown() */ HWTEST_F(ComponentMonitorTest, AddSAMonitor_001, TestSize.Level0) { - if (compMonitorPtr_ == nullptr) { - return; - } + ASSERT_TRUE(compMonitorPtr_ != nullptr); int32_t saId = static_cast(DHType::AUDIO); compMonitorPtr_->AddSAMonitor(saId); EXPECT_EQ(false, compMonitorPtr_->saListeners_.empty()); @@ -71,9 +69,7 @@ HWTEST_F(ComponentMonitorTest, AddSAMonitor_001, TestSize.Level0) */ HWTEST_F(ComponentMonitorTest, AddSAMonitor_002, TestSize.Level0) { - if (compMonitorPtr_ == nullptr) { - return; - } + ASSERT_TRUE(compMonitorPtr_ != nullptr); int32_t saId = static_cast(DHType::CAMERA); sptr listener(new ComponentMonitor::CompSystemAbilityListener()); compMonitorPtr_->saListeners_.insert(std::make_pair(saId, listener)); @@ -89,9 +85,7 @@ HWTEST_F(ComponentMonitorTest, AddSAMonitor_002, TestSize.Level0) */ HWTEST_F(ComponentMonitorTest, RemoveSAMonitor_001, TestSize.Level0) { - if (compMonitorPtr_ == nullptr) { - return; - } + ASSERT_TRUE(compMonitorPtr_ != nullptr); int32_t saId = static_cast(DHType::GPS); compMonitorPtr_->RemoveSAMonitor(saId); EXPECT_EQ(true, compMonitorPtr_->saListeners_.empty()); @@ -105,9 +99,7 @@ HWTEST_F(ComponentMonitorTest, RemoveSAMonitor_001, TestSize.Level0) */ HWTEST_F(ComponentMonitorTest, RemoveSAMonitor_002, TestSize.Level0) { - if (compMonitorPtr_ == nullptr) { - return; - } + ASSERT_TRUE(compMonitorPtr_ != nullptr); int32_t saId = static_cast(DHType::CAMERA); sptr listener(new ComponentMonitor::CompSystemAbilityListener()); compMonitorPtr_->saListeners_.insert(std::make_pair(saId, listener)); @@ -123,9 +115,7 @@ HWTEST_F(ComponentMonitorTest, RemoveSAMonitor_002, TestSize.Level0) */ HWTEST_F(ComponentMonitorTest, OnRemoveSystemAbility_001, TestSize.Level0) { - if (compMonitorPtr_ == nullptr) { - return; - } + ASSERT_TRUE(compMonitorPtr_ != nullptr); sptr listener(new ComponentMonitor::CompSystemAbilityListener()); int32_t saId = static_cast(DHType::UNKNOWN); std::string deviceId; @@ -142,9 +132,7 @@ HWTEST_F(ComponentMonitorTest, OnRemoveSystemAbility_001, TestSize.Level0) */ HWTEST_F(ComponentMonitorTest, OnRemoveSystemAbility_002, TestSize.Level0) { - if (compMonitorPtr_ == nullptr) { - return; - } + ASSERT_TRUE(compMonitorPtr_ != nullptr); sptr listener(new ComponentMonitor::CompSystemAbilityListener()); int32_t saId = static_cast(DHType::CAMERA); std::string deviceId; diff --git a/services/distributedhardwarefwkservice/test/unittest/common/componentmanager/component_privacy/component_privacy_test.cpp b/services/distributedhardwarefwkservice/test/unittest/common/componentmanager/component_privacy/component_privacy_test.cpp index bd5a057e5e68d0f69e9c0340dbf398b8a74517fa..aed955e68b34db15a9a9f1e3360ced8fbf8ce8f3 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/componentmanager/component_privacy/component_privacy_test.cpp +++ b/services/distributedhardwarefwkservice/test/unittest/common/componentmanager/component_privacy/component_privacy_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -156,9 +156,7 @@ HWTEST_F(ComponentPrivacyTest, ProcessEvent_001, TestSize.Level0) { ASSERT_TRUE(compPrivacy_ != nullptr); cJSON *jsonArrayMsg = cJSON_CreateArray(); - if (jsonArrayMsg == NULL) { - return; - } + ASSERT_TRUE(jsonArrayMsg != nullptr); cJSON *tmpJson = cJSON_CreateObject(); if (tmpJson == NULL) { @@ -177,9 +175,7 @@ HWTEST_F(ComponentPrivacyTest, ProcessEvent_002, TestSize.Level0) { ASSERT_TRUE(compPrivacy_ != nullptr); cJSON *jsonArrayMsg = cJSON_CreateArray(); - if (jsonArrayMsg == NULL) { - return; - } + ASSERT_TRUE(jsonArrayMsg != nullptr); cJSON *tmpJson = cJSON_CreateObject(); if (tmpJson == NULL) { @@ -198,9 +194,7 @@ HWTEST_F(ComponentPrivacyTest, ProcessEvent_003, TestSize.Level0) { ASSERT_TRUE(compPrivacy_ != nullptr); cJSON *jsonArrayMsg = cJSON_CreateArray(); - if (jsonArrayMsg == NULL) { - return; - } + ASSERT_TRUE(jsonArrayMsg != nullptr); cJSON *tmpJson = cJSON_CreateObject(); if (tmpJson == NULL) { @@ -219,9 +213,7 @@ HWTEST_F(ComponentPrivacyTest, ProcessEvent_004, TestSize.Level0) { ASSERT_TRUE(compPrivacy_ != nullptr); cJSON *jsonArrayMsg = cJSON_CreateArray(); - if (jsonArrayMsg == NULL) { - return; - } + ASSERT_TRUE(jsonArrayMsg != nullptr); cJSON *tmpJson = cJSON_CreateObject(); if (tmpJson == NULL) { @@ -240,9 +232,7 @@ HWTEST_F(ComponentPrivacyTest, ProcessEvent_005, TestSize.Level0) { ASSERT_TRUE(compPrivacy_ != nullptr); cJSON *jsonArrayMsg = cJSON_CreateArray(); - if (jsonArrayMsg == NULL) { - return; - } + ASSERT_TRUE(jsonArrayMsg != nullptr); cJSON *tmpJson = cJSON_CreateObject(); if (tmpJson == NULL) { @@ -260,9 +250,7 @@ HWTEST_F(ComponentPrivacyTest, ProcessEvent_006, TestSize.Level0) { ASSERT_TRUE(compPrivacy_ != nullptr); cJSON *jsonArrayMsg = cJSON_CreateArray(); - if (jsonArrayMsg == NULL) { - return; - } + ASSERT_TRUE(jsonArrayMsg != nullptr); cJSON *tmpJson = cJSON_CreateObject(); if (tmpJson == NULL) { @@ -280,9 +268,7 @@ HWTEST_F(ComponentPrivacyTest, ProcessEvent_007, TestSize.Level0) { ASSERT_TRUE(compPrivacy_ != nullptr); cJSON *jsonArrayMsg = cJSON_CreateArray(); - if (jsonArrayMsg == NULL) { - return; - } + ASSERT_TRUE(jsonArrayMsg != nullptr); cJSON *tmpJson = cJSON_CreateObject(); if (tmpJson == NULL) { diff --git a/services/distributedhardwarefwkservice/test/unittest/common/dbadapter/src/db_adapter_test.cpp b/services/distributedhardwarefwkservice/test/unittest/common/dbadapter/src/db_adapter_test.cpp index 848515255b1802f55f8edbd06a04f077f348e5dd..8ee8f72bbcc8f9d789cfcfd9148f4c7f7d3a4444 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/dbadapter/src/db_adapter_test.cpp +++ b/services/distributedhardwarefwkservice/test/unittest/common/dbadapter/src/db_adapter_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -137,9 +137,7 @@ void DbAdapterTest::TearDown() */ HWTEST_F(DbAdapterTest, db_adapter_test_000, TestSize.Level0) { - if (g_dbAdapterPtr == nullptr) { - return; - } + ASSERT_TRUE(g_dbAdapterPtr != nullptr); EXPECT_EQ(DH_FWK_SUCCESS, g_dbAdapterPtr->Init(true, DistributedKv::DataType::TYPE_DYNAMICAL)); } @@ -151,9 +149,7 @@ HWTEST_F(DbAdapterTest, db_adapter_test_000, TestSize.Level0) */ HWTEST_F(DbAdapterTest, db_adapter_test_001, TestSize.Level0) { - if (g_dbAdapterPtr == nullptr) { - return; - } + ASSERT_TRUE(g_dbAdapterPtr != nullptr); vector> resInfos { CAP_INFO_0, CAP_INFO_1, CAP_INFO_2, CAP_INFO_3, CAP_INFO_4, CAP_INFO_5, CAP_INFO_6, CAP_INFO_7, CAP_INFO_8, CAP_INFO_9 }; @@ -179,9 +175,7 @@ HWTEST_F(DbAdapterTest, db_adapter_test_001, TestSize.Level0) */ HWTEST_F(DbAdapterTest, db_adapter_test_002, TestSize.Level0) { - if (g_dbAdapterPtr == nullptr) { - return; - } + ASSERT_TRUE(g_dbAdapterPtr != nullptr); std::vector keys { std::string(TEST_DEV_ID_2 + TEST_DH_ID_0) }; std::vector values { TEST_DH_ATTR_0 }; @@ -197,9 +191,7 @@ HWTEST_F(DbAdapterTest, db_adapter_test_002, TestSize.Level0) */ HWTEST_F(DbAdapterTest, db_adapter_test_003, TestSize.Level0) { - if (g_dbAdapterPtr == nullptr) { - return; - } + ASSERT_TRUE(g_dbAdapterPtr != nullptr); std::vector keys { std::string(TEST_DEV_ID_2 + TEST_DH_ID_0) }; std::vector valuesEmpty; @@ -214,9 +206,7 @@ HWTEST_F(DbAdapterTest, db_adapter_test_003, TestSize.Level0) */ HWTEST_F(DbAdapterTest, db_adapter_test_004, TestSize.Level0) { - if (g_dbAdapterPtr == nullptr) { - return; - } + ASSERT_TRUE(g_dbAdapterPtr != nullptr); std::vector keysEmpty; std::vector values { TEST_DH_ATTR_0 }; @@ -231,9 +221,7 @@ HWTEST_F(DbAdapterTest, db_adapter_test_004, TestSize.Level0) */ HWTEST_F(DbAdapterTest, db_adapter_test_005, TestSize.Level0) { - if (g_dbAdapterPtr == nullptr) { - return; - } + ASSERT_TRUE(g_dbAdapterPtr != nullptr); std::vector keysEmpty; std::vector valuesEmpty; @@ -248,9 +236,7 @@ HWTEST_F(DbAdapterTest, db_adapter_test_005, TestSize.Level0) */ HWTEST_F(DbAdapterTest, db_adapter_test_006, TestSize.Level0) { - if (g_dbAdapterPtr == nullptr) { - return; - } + ASSERT_TRUE(g_dbAdapterPtr != nullptr); std::vector keys { std::string(TEST_DEV_ID_2 + TEST_DH_ID_0) }; std::vector values { TEST_DH_ATTR_0, TEST_DH_ATTR_1 }; @@ -265,9 +251,7 @@ HWTEST_F(DbAdapterTest, db_adapter_test_006, TestSize.Level0) */ HWTEST_F(DbAdapterTest, db_adapter_test_007, TestSize.Level0) { - if (g_dbAdapterPtr == nullptr) { - return; - } + ASSERT_TRUE(g_dbAdapterPtr != nullptr); g_dbAdapterPtr->kvStoragePtr_ = nullptr; std::vector keys { std::string(TEST_DEV_ID_2 + TEST_DH_ID_0) }; std::vector values { TEST_DH_ATTR_0 }; @@ -283,9 +267,7 @@ HWTEST_F(DbAdapterTest, db_adapter_test_007, TestSize.Level0) */ HWTEST_F(DbAdapterTest, db_adapter_test_008, TestSize.Level0) { - if (g_dbAdapterPtr == nullptr) { - return; - } + ASSERT_TRUE(g_dbAdapterPtr != nullptr); g_dbAdapterPtr->kvStoragePtr_ = nullptr; EXPECT_EQ(ERR_DH_FWK_RESOURCE_KV_STORAGE_POINTER_NULL, g_dbAdapterPtr->ReInit(true)); } @@ -298,9 +280,7 @@ HWTEST_F(DbAdapterTest, db_adapter_test_008, TestSize.Level0) */ HWTEST_F(DbAdapterTest, db_adapter_test_009, TestSize.Level0) { - if (g_dbAdapterPtr == nullptr) { - return; - } + ASSERT_TRUE(g_dbAdapterPtr != nullptr); g_dbAdapterPtr->kvStoragePtr_ = nullptr; EXPECT_EQ(ERR_DH_FWK_RESOURCE_KV_STORAGE_POINTER_NULL, g_dbAdapterPtr->RemoveDeviceData(TEST_DEV_ID_0)); } @@ -313,9 +293,7 @@ HWTEST_F(DbAdapterTest, db_adapter_test_009, TestSize.Level0) */ HWTEST_F(DbAdapterTest, db_adapter_test_010, TestSize.Level0) { - if (g_dbAdapterPtr == nullptr) { - return; - } + ASSERT_TRUE(g_dbAdapterPtr != nullptr); g_dbAdapterPtr->kvStoragePtr_ = nullptr; EXPECT_EQ(ERR_DH_FWK_RESOURCE_KV_STORAGE_POINTER_NULL, g_dbAdapterPtr->RemoveDataByKey("key")); } @@ -328,9 +306,7 @@ HWTEST_F(DbAdapterTest, db_adapter_test_010, TestSize.Level0) */ HWTEST_F(DbAdapterTest, db_adapter_test_012, TestSize.Level0) { - if (g_dbAdapterPtr == nullptr) { - return; - } + ASSERT_TRUE(g_dbAdapterPtr != nullptr); g_dbAdapterPtr->kvStoragePtr_ = nullptr; EXPECT_EQ(ERR_DH_FWK_RESOURCE_KV_STORAGE_POINTER_NULL, g_dbAdapterPtr->UnRegisterChangeListener()); } @@ -343,9 +319,7 @@ HWTEST_F(DbAdapterTest, db_adapter_test_012, TestSize.Level0) */ HWTEST_F(DbAdapterTest, db_adapter_test_013, TestSize.Level0) { - if (g_dbAdapterPtr == nullptr) { - return; - } + ASSERT_TRUE(g_dbAdapterPtr != nullptr); std::string key = std::string(TEST_DEV_ID_1 + TEST_DH_ID_1); std::string value = TEST_DH_ATTR_0; g_dbAdapterPtr->kvStoragePtr_ = nullptr; @@ -360,9 +334,7 @@ HWTEST_F(DbAdapterTest, db_adapter_test_013, TestSize.Level0) */ HWTEST_F(DbAdapterTest, db_adapter_test_014, TestSize.Level0) { - if (g_dbAdapterPtr == nullptr) { - return; - } + ASSERT_TRUE(g_dbAdapterPtr != nullptr); std::string networkId = DEV_NETWORK_ID_1; g_dbAdapterPtr->kvStoragePtr_ = nullptr; EXPECT_EQ(ERR_DH_FWK_RESOURCE_KV_STORAGE_POINTER_NULL, g_dbAdapterPtr->RegisterChangeListener()); @@ -376,9 +348,7 @@ HWTEST_F(DbAdapterTest, db_adapter_test_014, TestSize.Level0) */ HWTEST_F(DbAdapterTest, db_adapter_test_015, TestSize.Level0) { - if (g_dbAdapterPtr == nullptr) { - return; - } + ASSERT_TRUE(g_dbAdapterPtr != nullptr); g_dbAdapterPtr->kvStoragePtr_ = nullptr; EXPECT_EQ(ERR_DH_FWK_RESOURCE_KV_STORAGE_POINTER_NULL, g_dbAdapterPtr->UnRegisterChangeListener()); } @@ -391,9 +361,7 @@ HWTEST_F(DbAdapterTest, db_adapter_test_015, TestSize.Level0) */ HWTEST_F(DbAdapterTest, ReInit_001, TestSize.Level0) { - if (g_dbAdapterPtr == nullptr) { - return; - } + ASSERT_TRUE(g_dbAdapterPtr != nullptr); g_dbAdapterPtr->GetKvStorePtr(true, DistributedKv::DataType::TYPE_DYNAMICAL); EXPECT_EQ(DH_FWK_SUCCESS, g_dbAdapterPtr->ReInit(true)); } @@ -406,9 +374,7 @@ HWTEST_F(DbAdapterTest, ReInit_001, TestSize.Level0) */ HWTEST_F(DbAdapterTest, RemoveDeviceData_001, TestSize.Level0) { - if (g_dbAdapterPtr == nullptr) { - return; - } + ASSERT_TRUE(g_dbAdapterPtr != nullptr); g_dbAdapterPtr->GetKvStorePtr(true, DistributedKv::DataType::TYPE_DYNAMICAL); EXPECT_EQ(DH_FWK_SUCCESS, g_dbAdapterPtr->RemoveDeviceData(TEST_DEV_ID_0)); } @@ -421,9 +387,7 @@ HWTEST_F(DbAdapterTest, RemoveDeviceData_001, TestSize.Level0) */ HWTEST_F(DbAdapterTest, PutData_01, TestSize.Level0) { - if (g_dbAdapterPtr == nullptr) { - return; - } + ASSERT_TRUE(g_dbAdapterPtr != nullptr); std::string key; std::string value; EXPECT_EQ(ERR_DH_FWK_PARA_INVALID, g_dbAdapterPtr->PutData(key, value)); @@ -437,9 +401,7 @@ HWTEST_F(DbAdapterTest, PutData_01, TestSize.Level0) */ HWTEST_F(DbAdapterTest, PutData_02, TestSize.Level0) { - if (g_dbAdapterPtr == nullptr) { - return; - } + ASSERT_TRUE(g_dbAdapterPtr != nullptr); uint32_t MAX_MESSAGE_LEN = 40 * 1024 * 1024 +1 ; std::string key = "key"; key.resize(MAX_MESSAGE_LEN); @@ -455,9 +417,7 @@ HWTEST_F(DbAdapterTest, PutData_02, TestSize.Level0) */ HWTEST_F(DbAdapterTest, PutData_03, TestSize.Level0) { - if (g_dbAdapterPtr == nullptr) { - return; - } + ASSERT_TRUE(g_dbAdapterPtr != nullptr); std::string key = "key"; std::string value; EXPECT_EQ(ERR_DH_FWK_PARA_INVALID, g_dbAdapterPtr->PutData(key, value)); @@ -471,9 +431,7 @@ HWTEST_F(DbAdapterTest, PutData_03, TestSize.Level0) */ HWTEST_F(DbAdapterTest, PutData_04, TestSize.Level0) { - if (g_dbAdapterPtr == nullptr) { - return; - } + ASSERT_TRUE(g_dbAdapterPtr != nullptr); uint32_t MAX_MESSAGE_LEN = 40 * 1024 * 1024 + 1; std::string key = "key"; std::string value; @@ -489,9 +447,7 @@ HWTEST_F(DbAdapterTest, PutData_04, TestSize.Level0) */ HWTEST_F(DbAdapterTest, PutData_05, TestSize.Level0) { - if (g_dbAdapterPtr == nullptr) { - return; - } + ASSERT_TRUE(g_dbAdapterPtr != nullptr); std::string key = "key"; std::string value = "value"; g_dbAdapterPtr->kvStoragePtr_ = nullptr; diff --git a/services/distributedhardwarefwkservice/test/unittest/common/distributedhardwareservice/src/distributed_hardware_service_test.cpp b/services/distributedhardwarefwkservice/test/unittest/common/distributedhardwareservice/src/distributed_hardware_service_test.cpp index ae344a384d1f8ea21d46019038647a92b12d9772..9667310ea03448fcd17b9bef3fce7983e2c53072 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/distributedhardwareservice/src/distributed_hardware_service_test.cpp +++ b/services/distributedhardwarefwkservice/test/unittest/common/distributedhardwareservice/src/distributed_hardware_service_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -281,9 +281,7 @@ HWTEST_F(DistributedHardwareServiceTest, QueryDhSysSpec_002, TestSize.Level0) std::string targetKey = "histmAudEnc"; int32_t target = 100; cJSON *attrJson = cJSON_CreateObject(); - if (attrJson == nullptr) { - return; - } + ASSERT_TRUE(attrJson != nullptr); cJSON_AddNumberToObject(attrJson, targetKey.c_str(), target); char* cjson = cJSON_PrintUnformatted(attrJson); if (cjson == nullptr) { @@ -298,9 +296,7 @@ HWTEST_F(DistributedHardwareServiceTest, QueryDhSysSpec_002, TestSize.Level0) cJSON_Delete(attrJson); cJSON *attrJson1 = cJSON_CreateObject(); - if (attrJson1 == nullptr) { - return; - } + ASSERT_TRUE(attrJson1 != nullptr); std::string targetKeyValue = "targetKeyValue"; cJSON_AddStringToObject(attrJson1, targetKey.c_str(), targetKeyValue.c_str()); char* cjson1 = cJSON_PrintUnformatted(attrJson1); diff --git a/services/distributedhardwarefwkservice/test/unittest/common/distributedhardwarestub/src/distributed_hardware_stub_test.cpp b/services/distributedhardwarefwkservice/test/unittest/common/distributedhardwarestub/src/distributed_hardware_stub_test.cpp index 9e84c34f416f6b6cc6c699e050c55b4c08d790ea..9b9eafafdb88b015fcb123af71a07c9fe347392a 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/distributedhardwarestub/src/distributed_hardware_stub_test.cpp +++ b/services/distributedhardwarefwkservice/test/unittest/common/distributedhardwarestub/src/distributed_hardware_stub_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -45,9 +45,7 @@ void DistributedHardwareStubTest::TearDown() */ HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_001, TestSize.Level0) { - if (stubTest_ == nullptr) { - return; - } + ASSERT_TRUE(stubTest_ != nullptr); uint32_t code = 0; MessageParcel data; MessageParcel reply; @@ -63,9 +61,7 @@ HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_001, TestSize.Level0) */ HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_002, TestSize.Level0) { - if (stubTest_ == nullptr) { - return; - } + ASSERT_TRUE(stubTest_ != nullptr); uint32_t code = 0; MessageParcel data; MessageParcel reply; @@ -75,9 +71,7 @@ HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_002, TestSize.Level0) HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_003, TestSize.Level0) { - if (stubTest_ == nullptr) { - return; - } + ASSERT_TRUE(stubTest_ != nullptr); uint32_t code = static_cast(DHMsgInterfaceCode::REG_PUBLISHER_LISTNER); MessageParcel data; MessageParcel reply; @@ -91,9 +85,7 @@ HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_003, TestSize.Level0) HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_004, TestSize.Level0) { - if (stubTest_ == nullptr) { - return; - } + ASSERT_TRUE(stubTest_ != nullptr); uint32_t code = static_cast(DHMsgInterfaceCode::PUBLISH_MESSAGE); MessageParcel data; MessageParcel reply; @@ -107,9 +99,7 @@ HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_004, TestSize.Level0) HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_005, TestSize.Level0) { - if (stubTest_ == nullptr) { - return; - } + ASSERT_TRUE(stubTest_ != nullptr); uint32_t code = static_cast(DHMsgInterfaceCode::INIT_CTL_CEN); MessageParcel data; MessageParcel reply; @@ -123,9 +113,7 @@ HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_005, TestSize.Level0) HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_006, TestSize.Level0) { - if (stubTest_ == nullptr) { - return; - } + ASSERT_TRUE(stubTest_ != nullptr); uint32_t code = static_cast(DHMsgInterfaceCode::RELEASE_CTL_CEN); MessageParcel data; MessageParcel reply; @@ -139,9 +127,7 @@ HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_006, TestSize.Level0) HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_007, TestSize.Level0) { - if (stubTest_ == nullptr) { - return; - } + ASSERT_TRUE(stubTest_ != nullptr); uint32_t code = static_cast(DHMsgInterfaceCode::CREATE_CTL_CEN_CHANNEL); MessageParcel data; MessageParcel reply; @@ -157,9 +143,7 @@ HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_007, TestSize.Level0) HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_008, TestSize.Level0) { - if (stubTest_ == nullptr) { - return; - } + ASSERT_TRUE(stubTest_ != nullptr); uint32_t code = static_cast(DHMsgInterfaceCode::NOTIFY_AV_EVENT); MessageParcel data; MessageParcel reply; @@ -179,9 +163,7 @@ HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_008, TestSize.Level0) HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_009, TestSize.Level0) { - if (stubTest_ == nullptr) { - return; - } + ASSERT_TRUE(stubTest_ != nullptr); uint32_t code = static_cast(DHMsgInterfaceCode::QUERY_LOCAL_SYS_SPEC); MessageParcel data; MessageParcel reply; @@ -195,9 +177,7 @@ HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_009, TestSize.Level0) HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_010, TestSize.Level0) { - if (stubTest_ == nullptr) { - return; - } + ASSERT_TRUE(stubTest_ != nullptr); uint32_t code = static_cast(DHMsgInterfaceCode::NOTIFY_SOURCE_DEVICE_REMOTE_DMSDP_STARTED); MessageParcel data; MessageParcel reply; @@ -211,9 +191,7 @@ HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_010, TestSize.Level0) HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_011, TestSize.Level0) { - if (stubTest_ == nullptr) { - return; - } + ASSERT_TRUE(stubTest_ != nullptr); uint32_t code = static_cast(DHMsgInterfaceCode::PAUSE_DISTRIBUTED_HARDWARE); MessageParcel data; MessageParcel reply; @@ -225,9 +203,7 @@ HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_011, TestSize.Level0) HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_012, TestSize.Level0) { - if (stubTest_ == nullptr) { - return; - } + ASSERT_TRUE(stubTest_ != nullptr); uint32_t code = static_cast(DHMsgInterfaceCode::RESUME_DISTRIBUTED_HARDWARE); MessageParcel data; MessageParcel reply; @@ -239,9 +215,7 @@ HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_012, TestSize.Level0) HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_013, TestSize.Level0) { - if (stubTest_ == nullptr) { - return; - } + ASSERT_TRUE(stubTest_ != nullptr); uint32_t code = static_cast(DHMsgInterfaceCode::STOP_DISTRIBUTED_HARDWARE); MessageParcel data; MessageParcel reply; @@ -253,9 +227,7 @@ HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_013, TestSize.Level0) HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_014, TestSize.Level0) { - if (stubTest_ == nullptr) { - return; - } + ASSERT_TRUE(stubTest_ != nullptr); uint32_t code = static_cast(DHMsgInterfaceCode::UNREG_PUBLISHER_LISTENER); MessageParcel data; MessageParcel reply; @@ -275,9 +247,7 @@ HWTEST_F(DistributedHardwareStubTest, OnRemoteRequest_014, TestSize.Level0) */ HWTEST_F(DistributedHardwareStubTest, RegisterPublisherListenerInner_001, TestSize.Level0) { - if (stubTest_ == nullptr) { - return; - } + ASSERT_TRUE(stubTest_ != nullptr); MessageParcel data; MessageParcel reply; EXPECT_NE(DH_FWK_SUCCESS, stubTest_->RegisterPublisherListenerInner(data, reply)); @@ -291,9 +261,7 @@ HWTEST_F(DistributedHardwareStubTest, RegisterPublisherListenerInner_001, TestSi */ HWTEST_F(DistributedHardwareStubTest, UnregisterPublisherListenerInner_001, TestSize.Level0) { - if (stubTest_ == nullptr) { - return; - } + ASSERT_TRUE(stubTest_ != nullptr); MessageParcel data; MessageParcel reply; EXPECT_NE(DH_FWK_SUCCESS, stubTest_->UnregisterPublisherListenerInner(data, reply)); @@ -307,9 +275,7 @@ HWTEST_F(DistributedHardwareStubTest, UnregisterPublisherListenerInner_001, Test */ HWTEST_F(DistributedHardwareStubTest, PublishMessageInner_001, TestSize.Level0) { - if (stubTest_ == nullptr) { - return; - } + ASSERT_TRUE(stubTest_ != nullptr); MessageParcel data; MessageParcel reply; EXPECT_NE(DH_FWK_SUCCESS, stubTest_->PublishMessageInner(data, reply)); @@ -323,9 +289,7 @@ HWTEST_F(DistributedHardwareStubTest, PublishMessageInner_001, TestSize.Level0) */ HWTEST_F(DistributedHardwareStubTest, ValidTopic_001, TestSize.Level0) { - if (stubTest_ == nullptr) { - return; - } + ASSERT_TRUE(stubTest_ != nullptr); uint32_t topic = static_cast(DHTopic::TOPIC_MIN); EXPECT_EQ(false, stubTest_->ValidTopic(topic)); @@ -344,9 +308,7 @@ HWTEST_F(DistributedHardwareStubTest, ValidTopic_001, TestSize.Level0) */ HWTEST_F(DistributedHardwareStubTest, ValidQueryLocalSpec_001, TestSize.Level0) { - if (stubTest_ == nullptr) { - return; - } + ASSERT_TRUE(stubTest_ != nullptr); uint32_t spec = 1; EXPECT_EQ(true, stubTest_->ValidQueryLocalSpec(spec)); } @@ -359,9 +321,7 @@ HWTEST_F(DistributedHardwareStubTest, ValidQueryLocalSpec_001, TestSize.Level0) */ HWTEST_F(DistributedHardwareStubTest, ValidQueryLocalSpec_002, TestSize.Level0) { - if (stubTest_ == nullptr) { - return; - } + ASSERT_TRUE(stubTest_ != nullptr); uint32_t spec = 0; EXPECT_EQ(false, stubTest_->ValidQueryLocalSpec(spec)); spec = 5; diff --git a/services/distributedhardwarefwkservice/test/unittest/common/localhardwaremanager/pluginlistenerimpl/src/plugin_listener_impl_test.cpp b/services/distributedhardwarefwkservice/test/unittest/common/localhardwaremanager/pluginlistenerimpl/src/plugin_listener_impl_test.cpp index 5ec66ee43f533d381f518c71ac723b03640b103d..f523ed26121206ae8eafea1b9423c38535891a99 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/localhardwaremanager/pluginlistenerimpl/src/plugin_listener_impl_test.cpp +++ b/services/distributedhardwarefwkservice/test/unittest/common/localhardwaremanager/pluginlistenerimpl/src/plugin_listener_impl_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -51,9 +51,7 @@ void PluginListenerImplTest::TearDown() {} */ HWTEST_F(PluginListenerImplTest, plugin_listener_impl_test_001, TestSize.Level0) { - if (g_mockHardwareHandler == nullptr) { - return; - } + ASSERT_TRUE(g_mockHardwareHandler != nullptr); g_mockHardwareHandler->RegisterPluginListener(g_listener); EXPECT_EQ(g_mockHardwareHandler->PluginHardware(dhId, attrs, subtype), DH_FWK_SUCCESS); } @@ -66,9 +64,7 @@ HWTEST_F(PluginListenerImplTest, plugin_listener_impl_test_001, TestSize.Level0) */ HWTEST_F(PluginListenerImplTest, plugin_listener_impl_test_002, TestSize.Level0) { - if (g_mockHardwareHandler == nullptr) { - return; - } + ASSERT_TRUE(g_mockHardwareHandler != nullptr); EXPECT_EQ(g_mockHardwareHandler->UnPluginHardware(dhId), DH_FWK_SUCCESS); g_mockHardwareHandler->UnRegisterPluginListener(); } diff --git a/services/distributedhardwarefwkservice/test/unittest/common/lowlatency/lowlatencylistener/src/low_latency_listener_test.cpp b/services/distributedhardwarefwkservice/test/unittest/common/lowlatency/lowlatencylistener/src/low_latency_listener_test.cpp index 634159e6e98e23919e15a440651d40c950d71934..6bcf64cb3deb472981a7499d950ff9b4ec896999 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/lowlatency/lowlatencylistener/src/low_latency_listener_test.cpp +++ b/services/distributedhardwarefwkservice/test/unittest/common/lowlatency/lowlatencylistener/src/low_latency_listener_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -46,9 +46,7 @@ void LowLatencyListenerTest::TearDown() */ HWTEST_F(LowLatencyListenerTest, OnMessage_001, TestSize.Level0) { - if (listener_ == nullptr) { - return; - } + ASSERT_TRUE(listener_ != nullptr); DHTopic topic = DHTopic::TOPIC_MIN; std::string message; listener_->OnMessage(topic, message); @@ -63,9 +61,7 @@ HWTEST_F(LowLatencyListenerTest, OnMessage_001, TestSize.Level0) */ HWTEST_F(LowLatencyListenerTest, OnMessage_002, TestSize.Level0) { - if (listener_ == nullptr) { - return; - } + ASSERT_TRUE(listener_ != nullptr); DHTopic topic = DHTopic::TOPIC_START_DSCREEN; std::string message; listener_->OnMessage(topic, message); @@ -80,9 +76,7 @@ HWTEST_F(LowLatencyListenerTest, OnMessage_002, TestSize.Level0) */ HWTEST_F(LowLatencyListenerTest, OnMessage_003, TestSize.Level0) { - if (listener_ == nullptr) { - return; - } + ASSERT_TRUE(listener_ != nullptr); DHTopic topic = DHTopic::TOPIC_START_DSCREEN; std::string message = "message"; listener_->OnMessage(topic, message); @@ -97,14 +91,10 @@ HWTEST_F(LowLatencyListenerTest, OnMessage_003, TestSize.Level0) */ HWTEST_F(LowLatencyListenerTest, OnMessage_004, TestSize.Level0) { - if (listener_ == nullptr) { - return; - } + ASSERT_TRUE(listener_ != nullptr); DHTopic topic = DHTopic::TOPIC_START_DSCREEN; cJSON* json = cJSON_CreateObject(); - if (json == nullptr) { - return; - } + ASSERT_TRUE(json != nullptr); const char* DH_TYPE = "dh_type"; const char* LOW_LATENCY_ENABLE = "low_latency_enable"; @@ -130,9 +120,7 @@ HWTEST_F(LowLatencyListenerTest, OnMessage_004, TestSize.Level0) */ HWTEST_F(LowLatencyListenerTest, OnMessage_005, TestSize.Level0) { - if (listener_ == nullptr) { - return; - } + ASSERT_TRUE(listener_ != nullptr); DHTopic topic = DHTopic::TOPIC_START_DSCREEN; std::string message; uint32_t MAX_MESSAGE_LEN = 40 * 1024 * 1024; @@ -149,14 +137,10 @@ HWTEST_F(LowLatencyListenerTest, OnMessage_005, TestSize.Level0) */ HWTEST_F(LowLatencyListenerTest, OnMessage_006, TestSize.Level0) { - if (listener_ == nullptr) { - return; - } + ASSERT_TRUE(listener_ != nullptr); DHTopic topic = DHTopic::TOPIC_START_DSCREEN; cJSON* json = cJSON_CreateObject(); - if (json == nullptr) { - return; - } + ASSERT_TRUE(json != nullptr); const char* DH_TYPE = "dh_type"; const char* LOW_LATENCY_ENABLE = "low_latency_enable"; cJSON_AddNumberToObject(json, DH_TYPE, 0x01); @@ -181,14 +165,10 @@ HWTEST_F(LowLatencyListenerTest, OnMessage_006, TestSize.Level0) */ HWTEST_F(LowLatencyListenerTest, OnMessage_007, TestSize.Level0) { - if (listener_ == nullptr) { - return; - } + ASSERT_TRUE(listener_ != nullptr); DHTopic topic = DHTopic::TOPIC_START_DSCREEN; cJSON* json = cJSON_CreateObject(); - if (json == nullptr) { - return; - } + ASSERT_TRUE(json != nullptr); const char* DH_TYPE = "dh_type"; const char* LOW_LATENCY_ENABLE = "low_latency_enable"; cJSON_AddNumberToObject(json, DH_TYPE, 0x01); @@ -213,9 +193,7 @@ HWTEST_F(LowLatencyListenerTest, OnMessage_007, TestSize.Level0) */ HWTEST_F(LowLatencyListenerTest, ExecuteInner_008, TestSize.Level0) { - if (listener_ == nullptr) { - return; - } + ASSERT_TRUE(listener_ != nullptr); std::string timerId; int32_t delayTimeMs = 1; LowLatencyTimer timer(timerId, delayTimeMs); @@ -231,9 +209,7 @@ HWTEST_F(LowLatencyListenerTest, ExecuteInner_008, TestSize.Level0) */ HWTEST_F(LowLatencyListenerTest, HandleStopTimer_008, TestSize.Level0) { - if (listener_ == nullptr) { - return; - } + ASSERT_TRUE(listener_ != nullptr); std::string timerId; int32_t delayTimeMs = 1; LowLatencyTimer timer(timerId, delayTimeMs); diff --git a/services/distributedhardwarefwkservice/test/unittest/common/transport/dh_comm_tool_test.cpp b/services/distributedhardwarefwkservice/test/unittest/common/transport/dh_comm_tool_test.cpp index 1b13e0dc03271a26dff85ee2e732e752beed8b88..ea4b37424e1853c1cf4ff2a077e5e328e6e163a8 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/transport/dh_comm_tool_test.cpp +++ b/services/distributedhardwarefwkservice/test/unittest/common/transport/dh_comm_tool_test.cpp @@ -59,9 +59,7 @@ void DhCommToolTest::TearDown() HWTEST_F(DhCommToolTest, TriggerReqFullDHCaps_001, TestSize.Level0) { - if (dhCommToolTest_ == nullptr) { - return; - } + ASSERT_TRUE(dhCommToolTest_ != nullptr); std::string remoteNetworkId = ""; dhCommToolTest_->TriggerReqFullDHCaps(remoteNetworkId); @@ -79,9 +77,7 @@ HWTEST_F(DhCommToolTest, TriggerReqFullDHCaps_001, TestSize.Level0) HWTEST_F(DhCommToolTest, GetAndSendLocalFullCaps_001, TestSize.Level0) { - if (dhCommToolTest_ == nullptr) { - return; - } + ASSERT_TRUE(dhCommToolTest_ != nullptr); std::string reqNetworkId = ""; dhCommToolTest_->dhTransportPtr_ = nullptr; dhCommToolTest_->GetAndSendLocalFullCaps(reqNetworkId); @@ -93,9 +89,7 @@ HWTEST_F(DhCommToolTest, GetAndSendLocalFullCaps_001, TestSize.Level0) HWTEST_F(DhCommToolTest, ParseAndSaveRemoteDHCaps_001, TestSize.Level0) { - if (dhCommToolTest_ == nullptr) { - return; - } + ASSERT_TRUE(dhCommToolTest_ != nullptr); std::string remoteCaps = ""; FullCapsRsp ret = dhCommToolTest_->ParseAndSaveRemoteDHCaps(remoteCaps); EXPECT_EQ("", ret.networkId); @@ -103,9 +97,7 @@ HWTEST_F(DhCommToolTest, ParseAndSaveRemoteDHCaps_001, TestSize.Level0) HWTEST_F(DhCommToolTest, ParseAndSaveRemoteDHCaps_002, TestSize.Level0) { - if (dhCommToolTest_ == nullptr) { - return; - } + ASSERT_TRUE(dhCommToolTest_ != nullptr); cJSON *jsonObject = cJSON_CreateObject(); ASSERT_TRUE(jsonObject != nullptr); std::string networkId = "123456";