From 3045d3b1b533b817a0727afd884b5b33a96d70ea Mon Sep 17 00:00:00 2001 From: "weidong.liu@thundersoft.com" Date: Tue, 15 Mar 2022 10:48:38 +0800 Subject: [PATCH 1/4] compile test for UT --- test/unittest/BUILD.gn | 24 ++ test/unittest/UTTest_dm_adapter_manager.cpp | 85 ++++++ test/unittest/UTTest_dm_adapter_manager.h | 31 +++ test/unittest/UTTest_dm_timer.cpp | 280 ++++++++++++++++++++ test/unittest/UTTest_dm_timer.h | 31 +++ 5 files changed, 451 insertions(+) create mode 100644 test/unittest/UTTest_dm_adapter_manager.cpp create mode 100644 test/unittest/UTTest_dm_adapter_manager.h create mode 100644 test/unittest/UTTest_dm_timer.cpp create mode 100644 test/unittest/UTTest_dm_timer.h diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index 9325d03ef..e6a10649a 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -36,6 +36,8 @@ group("unittest") { ":UTTest_ipc_server_stub", ":UTTest_softbus_connector", ":UTTest_softbus_session", + ":UTTest_dm_adapter_manager", + ":UTTest_dm_timer", ] } @@ -105,6 +107,28 @@ ohos_unittest("UTTest_softbus_session") { ## UnitTest UTTest_softbus_session }}} +## UnitTest UTTest_dm_adapter_manager {{{ +ohos_unittest("UTTest_dm_adapter_manager") { + module_out_path = module_out_path + + sources = [ "UTTest_dm_adapter_manager.cpp" ] + + deps = [ ":device_manager_test_common" ] +} + +## UnitTest UTTest_dm_adapter_manager }}} + +## UnitTest UTTest_dm_timer {{{ +ohos_unittest("UTTest_dm_timer") { + module_out_path = module_out_path + + sources = [ "UTTest_dm_timer.cpp" ] + + deps = [ ":device_manager_test_common" ] +} + +## UnitTest UTTest_dm_timer }}} + ## UnitTest UTTest_ipc_client_manager {{{ ohos_unittest("UTTest_ipc_client_manager") { module_out_path = module_out_path diff --git a/test/unittest/UTTest_dm_adapter_manager.cpp b/test/unittest/UTTest_dm_adapter_manager.cpp new file mode 100644 index 000000000..fb96898d1 --- /dev/null +++ b/test/unittest/UTTest_dm_adapter_manager.cpp @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2021 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include "UTTest_dm_adapter_manager.h" +#include "dm_adapter_manager.h" +#include "dm_config_manager.h" + +namespace OHOS { +namespace DistributedHardware { +void DmAdapterManagerTest::SetUp() +{ +} +void DmAdapterManagerTest::TearDown() +{ +} +void DmAdapterManagerTest::SetUpTestCase() +{ +} +void DmAdapterManagerTest::TearDownTestCase() +{ +} + +namespace { +std::shared_ptr dmAdapterManager = + std::make_shared(); + +/** + * @tc.name: DmAdapterManager::GetDecisionAdapter_001 + * @tc.desc: 1 set soName to null + * 2 call DmAdapterManager::GetDecisionAdapter_001 with soName = nullptr + * @tc.type: FUNC + * @tc.require:AR000GHSJK + */ +HWTEST_F(DmAdapterManagerTest, GetDecisionAdapter_001, testing::ext::TestSize.Level0) +{ + std::string soName = "123"; + soName.clear(); + std::shared_ptr iDecisionAdapter = dmAdapterManager->GetDecisionAdapter(soName); + EXPECT_EQ(nullptr,iDecisionAdapter); +} + +/** + * @tc.name: DmAdapterManager::GetProfileAdapter_001 + * @tc.desc: 1 set soName to null + * 2 callDmAdapterManager::GetProfileAdapter_001 with soName = nullptr + * @tc.type: FUNC + * @tc.require:AR000GHSJK + */ +HWTEST_F(DmAdapterManagerTest, GetProfileAdapter_001, testing::ext::TestSize.Level0) +{ + std::string soName = "123"; + soName.clear(); + std::shared_ptr iProfileAdapter = dmAdapterManager->GetProfileAdapter(soName); + EXPECT_EQ(nullptr,iProfileAdapter); +} + +/** + * @tc.name: DmAdapterManager::GetCryptoAdapter_001 + * @tc.desc: 1 set soName to null + * 2 callDmAdapterManager::GetCryptoAdapter_001 with soName = nullptr + * @tc.type: FUNC + * @tc.require:AR000GHSJK + */ +HWTEST_F(DmAdapterManagerTest, GetCryptoAdapter_001, testing::ext::TestSize.Level0) +{ + std::string soName = "123"; + soName.clear(); + std::shared_ptr iCryptoAdapter = dmAdapterManager->GetCryptoAdapter(soName); + EXPECT_EQ(nullptr,iCryptoAdapter); +} +} +} +} \ No newline at end of file diff --git a/test/unittest/UTTest_dm_adapter_manager.h b/test/unittest/UTTest_dm_adapter_manager.h new file mode 100644 index 000000000..b0a975e21 --- /dev/null +++ b/test/unittest/UTTest_dm_adapter_manager.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2021 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef OHOS_UTTEST_DM_ADAPTER_MANAGER_H +#define OHOS_UTTEST_DM_ADAPTER_MANAGER_H + +#include + +namespace OHOS { +namespace DistributedHardware { +class DmAdapterManagerTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + virtual void SetUp() override; + virtual void TearDown() override; +}; +} // namespace DistributedHardware +} // namespace OHOS +#endif \ No newline at end of file diff --git a/test/unittest/UTTest_dm_timer.cpp b/test/unittest/UTTest_dm_timer.cpp new file mode 100644 index 000000000..78fd2012f --- /dev/null +++ b/test/unittest/UTTest_dm_timer.cpp @@ -0,0 +1,280 @@ +/* + * Copyright (c) 2021 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include + +#include "UTTest_dm_timer.h" +#include "dm_timer.h" + +namespace OHOS { +namespace DistributedHardware { +void DmTimerTest::SetUp() +{ +} + +void DmTimerTest::TearDown() +{ +} + +void DmTimerTest::SetUpTestCase() +{ +} + +void DmTimerTest::TearDownTestCase() +{ +} + +namespace { + +/** + * @tc.name: DmTimerTest::DmTimer_001 + * @tc.desc: to check when name is empty + * @tc.type: FUNC + * @tc.require: AR000GHSJK + */ +HWTEST_F(DmTimerTest, DmTimer_001, testing::ext::TestSize.Level0) +{ + const std::string DM_TIMER_TASK = ""; + std::shared_ptr Timer_ = std::make_shared(DM_TIMER_TASK); +} + +/** + * @tc.name: DmTimerTest::DmTimer_002 + * @tc.desc: to check when name is not empty + * @tc.type: FUNC + * @tc.require: AR000GHSJK + */ +HWTEST_F(DmTimerTest, DmTimer_002, testing::ext::TestSize.Level0) +{ + const std::string DM_TIMER_TASK = "123"; + std::shared_ptr Timer_ = std::make_shared(DM_TIMER_TASK); + EXPECT_EQ(DmTimerStatus::DM_STATUS_INIT,Timer_->mStatus_); + EXPECT_EQ(0,Timer_->mTimeOutSec_); + EXPECT_EQ(nullptr,Timer_->mHandle_); + EXPECT_EQ(nullptr,Timer_->mHandleData_); + EXPECT_EQ(0,Timer_->mTimeFd_[1]); + EXPECT_EQ(0,Timer_->mEv_.events); + EXPECT_EQ(0,Timer_->mEvents_[0].events); + EXPECT_EQ(0,Timer_->mEpFd_); + EXPECT_EQ("111",Timer_->mTimerName_); +} + +/** + * @tc.name: DmTimerTest::DisStructDmTimer_001 + * @tc.desc: to check when mTimerName_ is empty + * @tc.type: FUNC + * @tc.require: AR000GHSJK + */ +HWTEST_F(DmTimerTest, DisStructDmTimer_001, testing::ext::TestSize.Level0) +{ + const std::string DM_TIMER_TASK = ""; + std::shared_ptr Timer_ = std::make_shared(DM_TIMER_TASK); + Timer_->~DmTimer(); +} + +/** + * @tc.name: DmTimerTest::DisStructDmTimer_002 + * @tc.desc: to check when mTimerName_ is not empty + * @tc.type: FUNC + * @tc.require: AR000GHSJK + */ +HWTEST_F(DmTimerTest, DisStructDmTimer_002, testing::ext::TestSize.Level0) +{ + const std::string DM_TIMER_TASK = "123"; + std::shared_ptr Timer_ = std::make_shared(DM_TIMER_TASK); + Timer_->~DmTimer(); +} + +/** + * @tc.name: DmTimerTest::Start_001 + * @tc.desc: to check when mTimerName_ is empty,handle is nullptr,data is nullptr + * @tc.type: FUNC + * @tc.require: AR000GHSJK + */ +HWTEST_F(DmTimerTest, Start_001, testing::ext::TestSize.Level0) +{ + const std::string DM_TIMER_TASK = ""; + std::shared_ptr Timer_ = std::make_shared(DM_TIMER_TASK); + uint32_t timeOut = 10; + TimeoutHandle handle = nullptr; + void *data = nullptr; + DmTimerStatus timerStatus = Timer_->Start(timeOut,handle,data); + EXPECT_EQ(DM_STATUS_FINISH,timerStatus); +} + +/** + * @tc.name: DmTimerTest::Start_002 + * @tc.desc: to check when mTimerName_ is not empty,handle is not nullptr,data is not nullptr,mStatus_ != DmTimerStatus::DM_STATUS_INIT + * @tc.type: FUNC + * @tc.require: AR000GHSJK + */ +static void TimeOutTest(void *data, DmTimer& timer) +{ + LOGE("time out test"); +} + +HWTEST_F(DmTimerTest, Start_002, testing::ext::TestSize.Level0) +{ + const std::string DM_TIMER_TASK = "1234"; + std::shared_ptr Timer_ = std::make_shared(DM_TIMER_TASK); + uint32_t timeOut = 10; + int idx = 1; + void *data = &idx; + Timer_->mStatus_ = DmTimerStatus::DM_STATUS_RUNNING; + Timer_->Start(timeOut,TimeOutTest,data); + EXPECT_EQ(DmTimerStatus::DM_STATUS_BUSY,Timer_->mStatus_); +} + +/** + * @tc.name: DmTimerTest::Stop_001 + * @tc.desc: to check when mTimerName_ is empty + * @tc.type: FUNC + * @tc.require: AR000GHSJK + */ +HWTEST_F(DmTimerTest, Stop_001, testing::ext::TestSize.Level0) +{ + const std::string DM_TIMER_TASK = ""; + std::shared_ptr Timer_ = std::make_shared(DM_TIMER_TASK); + int32_t code = 1; + Timer_->Stop(code); +} + +/** + * @tc.name: DmTimerTest::Stop_002 + * @tc.desc: to check when mTimerName_ is not empty + * @tc.type: FUNC + * @tc.require: AR000GHSJK + */ +HWTEST_F(DmTimerTest, Stop_002, testing::ext::TestSize.Level0) +{ + const std::string DM_TIMER_TASK = "111"; + std::shared_ptr Timer_ = std::make_shared(DM_TIMER_TASK); + int32_t code = 1; + Timer_->Stop(code); +} + +/** + * @tc.name: DmTimerTest::Stop_003 + * @tc.desc: to check when mTimerName_ is not empty,mTimeFd_[1] is not 0 + * @tc.type: FUNC + * @tc.require: AR000GHSJK + */ +HWTEST_F(DmTimerTest, Stop_003, testing::ext::TestSize.Level0) +{ + const std::string DM_TIMER_TASK = "111"; + std::shared_ptr Timer_ = std::make_shared(DM_TIMER_TASK); + int32_t code = 1; + Timer_->mTimeFd_[1] = 1; + Timer_->Stop(code); +} + +/** + * @tc.name: DmTimerTest::WaitForTimeout_001 + * @tc.desc: to check when mTimerName_ is empty + * @tc.type: FUNC + * @tc.require: AR000GHSJK + */ +HWTEST_F(DmTimerTest, WaitForTimeout_001, testing::ext::TestSize.Level0) +{ + const std::string DM_TIMER_TASK = ""; + std::shared_ptr Timer_ = std::make_shared(DM_TIMER_TASK); + Timer_->WaitForTimeout(); +} + +/** + * @tc.name: DmTimerTest::WaitForTimeout_002 + * @tc.desc: to check when mTimerName_ is not empty + * @tc.type: FUNC + * @tc.require: AR000GHSJK + */ +HWTEST_F(DmTimerTest, WaitForTimeout_002, testing::ext::TestSize.Level0) +{ + const std::string DM_TIMER_TASK = "111"; + std::shared_ptr Timer_ = std::make_shared(DM_TIMER_TASK); + Timer_->WaitForTimeout(); +} + +/** + * @tc.name: DmTimerTest::CreateTimeFd_001 + * @tc.desc: to check when mTimerName_ is empty + * @tc.type: FUNC + * @tc.require: AR000GHSJK + */ +HWTEST_F(DmTimerTest, CreateTimeFd_001, testing::ext::TestSize.Level0) +{ + const std::string DM_TIMER_TASK = ""; + std::shared_ptr Timer_ = std::make_shared(DM_TIMER_TASK); + int32_t result = Timer_->CreateTimeFd(); + EXPECT_EQ(DM_STATUS_FINISH,result); +} + +/** + * @tc.name: DmTimerTest::CreateTimeFd_002 + * @tc.desc: to check when mTimerName_ is not empty + * @tc.type: FUNC + * @tc.require: AR000GHSJK + */ +HWTEST_F(DmTimerTest, CreateTimeFd_002, testing::ext::TestSize.Level0) +{ + const std::string DM_TIMER_TASK = "123"; + std::shared_ptr Timer_ = std::make_shared(DM_TIMER_TASK); + Timer_->CreateTimeFd(); +} + +/** + * @tc.name: DmTimerTest::Release_001 + * @tc.desc: to check when mTimerName_ is empty + * @tc.type: FUNC + * @tc.require: AR000GHSJK + */ +HWTEST_F(DmTimerTest, Release_001, testing::ext::TestSize.Level0) +{ + const std::string DM_TIMER_TASK = ""; + std::shared_ptr Timer_ = std::make_shared(DM_TIMER_TASK); + Timer_->Release(); +} + +/** + * @tc.name: DmTimerTest::Release_002 + * @tc.desc: to check when mTimerName_ is not empty,mStatus_ is 0 + * @tc.type: FUNC + * @tc.require: AR000GHSJK + */ +HWTEST_F(DmTimerTest, Release_002, testing::ext::TestSize.Level0) +{ + const std::string DM_TIMER_TASK = "111"; + std::shared_ptr Timer_ = std::make_shared(DM_TIMER_TASK); + Timer_->mStatus_ = DmTimerStatus::DM_STATUS_INIT; + Timer_->Release(); +} + +/** + * @tc.name: DmTimerTest::GetTimerName_001 + * @tc.desc: to check whether the return value is the same as mTimerName_ + * @tc.type: FUNC + * @tc.require: AR000GHSJK + */ +HWTEST_F(DmTimerTest, GetTimerName_001, testing::ext::TestSize.Level0) +{ + const std::string DM_TIMER_TASK = "111"; + std::shared_ptr Timer_ = std::make_shared(DM_TIMER_TASK); + std::string strTimer = Timer_->GetTimerName(); + EXPECT_EQ("111",strTimer); +} +} +} +} \ No newline at end of file diff --git a/test/unittest/UTTest_dm_timer.h b/test/unittest/UTTest_dm_timer.h new file mode 100644 index 000000000..19990300f --- /dev/null +++ b/test/unittest/UTTest_dm_timer.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2021 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef OHOS_UTTEST_DM_TIMER_H +#define OHOS_UTTEST_DM_TIMER_H + +#include + +namespace OHOS { +namespace DistributedHardware { +class DmTimerTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + virtual void SetUp() override; + virtual void TearDown() override; +}; +} // namespace DistributedHardware +} // namespace OHOS +#endif \ No newline at end of file -- Gitee From a95c5998413433a3711f5f8203289683507fee32 Mon Sep 17 00:00:00 2001 From: fuchao Date: Tue, 15 Mar 2022 04:17:24 +0000 Subject: [PATCH 2/4] update test/unittest/BUILD.gn. --- test/unittest/BUILD.gn | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index e6a10649a..730394561 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -24,10 +24,12 @@ group("unittest") { ":UTTest_auth_response_state", ":UTTest_device_manager_service", ":UTTest_device_manager_service_listener", + ":UTTest_dm_adapter_manager", ":UTTest_dm_auth_manager", ":UTTest_dm_device_info_manager", ":UTTest_dm_device_state_manager", ":UTTest_dm_discovery_manager", + ":UTTest_dm_timer", ":UTTest_ipc_client_manager", ":UTTest_ipc_client_proxy", ":UTTest_ipc_client_stub", @@ -36,8 +38,6 @@ group("unittest") { ":UTTest_ipc_server_stub", ":UTTest_softbus_connector", ":UTTest_softbus_session", - ":UTTest_dm_adapter_manager", - ":UTTest_dm_timer", ] } @@ -536,4 +536,4 @@ ohos_static_library("device_manager_test") { "samgr_standard:samgr_proxy", ] } -## Build device_manager_test.a }}} +## Build device_manager_test.a }}} \ No newline at end of file -- Gitee From a958914bb85062db689cde9f9eb13d377b4bb12a Mon Sep 17 00:00:00 2001 From: fuchao Date: Tue, 15 Mar 2022 04:18:09 +0000 Subject: [PATCH 3/4] update test/unittest/UTTest_dm_adapter_manager.cpp. --- test/unittest/UTTest_dm_adapter_manager.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/unittest/UTTest_dm_adapter_manager.cpp b/test/unittest/UTTest_dm_adapter_manager.cpp index fb96898d1..4e15fcde3 100644 --- a/test/unittest/UTTest_dm_adapter_manager.cpp +++ b/test/unittest/UTTest_dm_adapter_manager.cpp @@ -13,9 +13,9 @@ * limitations under the License. */ #include -#include "UTTest_dm_adapter_manager.h" #include "dm_adapter_manager.h" #include "dm_config_manager.h" +#include "UTTest_dm_adapter_manager.h" namespace OHOS { namespace DistributedHardware { @@ -33,7 +33,7 @@ void DmAdapterManagerTest::TearDownTestCase() } namespace { -std::shared_ptr dmAdapterManager = +std::shared_ptr dmAdapterManager = std::make_shared(); /** @@ -48,7 +48,7 @@ HWTEST_F(DmAdapterManagerTest, GetDecisionAdapter_001, testing::ext::TestSize.Le std::string soName = "123"; soName.clear(); std::shared_ptr iDecisionAdapter = dmAdapterManager->GetDecisionAdapter(soName); - EXPECT_EQ(nullptr,iDecisionAdapter); + EXPECT_EQ(nullptr, iDecisionAdapter); } /** @@ -63,7 +63,7 @@ HWTEST_F(DmAdapterManagerTest, GetProfileAdapter_001, testing::ext::TestSize.Lev std::string soName = "123"; soName.clear(); std::shared_ptr iProfileAdapter = dmAdapterManager->GetProfileAdapter(soName); - EXPECT_EQ(nullptr,iProfileAdapter); + EXPECT_EQ(nullptr, iProfileAdapter); } /** @@ -78,7 +78,7 @@ HWTEST_F(DmAdapterManagerTest, GetCryptoAdapter_001, testing::ext::TestSize.Leve std::string soName = "123"; soName.clear(); std::shared_ptr iCryptoAdapter = dmAdapterManager->GetCryptoAdapter(soName); - EXPECT_EQ(nullptr,iCryptoAdapter); + EXPECT_EQ(nullptr, iCryptoAdapter); } } } -- Gitee From 5686d1e681d4c7dedeff056c77585aceb3067ccc Mon Sep 17 00:00:00 2001 From: fuchao Date: Tue, 15 Mar 2022 04:19:00 +0000 Subject: [PATCH 4/4] update test/unittest/UTTest_dm_timer.cpp. --- test/unittest/UTTest_dm_timer.cpp | 38 +++++++++++++++---------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/test/unittest/UTTest_dm_timer.cpp b/test/unittest/UTTest_dm_timer.cpp index 78fd2012f..ab2865b79 100644 --- a/test/unittest/UTTest_dm_timer.cpp +++ b/test/unittest/UTTest_dm_timer.cpp @@ -17,8 +17,8 @@ #include #include -#include "UTTest_dm_timer.h" #include "dm_timer.h" +#include "UTTest_dm_timer.h" namespace OHOS { namespace DistributedHardware { @@ -39,7 +39,6 @@ void DmTimerTest::TearDownTestCase() } namespace { - /** * @tc.name: DmTimerTest::DmTimer_001 * @tc.desc: to check when name is empty @@ -62,15 +61,15 @@ HWTEST_F(DmTimerTest, DmTimer_002, testing::ext::TestSize.Level0) { const std::string DM_TIMER_TASK = "123"; std::shared_ptr Timer_ = std::make_shared(DM_TIMER_TASK); - EXPECT_EQ(DmTimerStatus::DM_STATUS_INIT,Timer_->mStatus_); - EXPECT_EQ(0,Timer_->mTimeOutSec_); - EXPECT_EQ(nullptr,Timer_->mHandle_); - EXPECT_EQ(nullptr,Timer_->mHandleData_); - EXPECT_EQ(0,Timer_->mTimeFd_[1]); - EXPECT_EQ(0,Timer_->mEv_.events); - EXPECT_EQ(0,Timer_->mEvents_[0].events); - EXPECT_EQ(0,Timer_->mEpFd_); - EXPECT_EQ("111",Timer_->mTimerName_); + EXPECT_EQ(DmTimerStatus::DM_STATUS_INIT, Timer_->mStatus_); + EXPECT_EQ(0, Timer_->mTimeOutSec_); + EXPECT_EQ(nullptr, Timer_->mHandle_); + EXPECT_EQ(nullptr, Timer_->mHandleData_); + EXPECT_EQ(0, Timer_->mTimeFd_[1]); + EXPECT_EQ(0, Timer_->mEv_.events); + EXPECT_EQ(0, Timer_->mEvents_[0].events); + EXPECT_EQ(0, Timer_->mEpFd_); + EXPECT_EQ("111", Timer_->mTimerName_); } /** @@ -112,13 +111,14 @@ HWTEST_F(DmTimerTest, Start_001, testing::ext::TestSize.Level0) uint32_t timeOut = 10; TimeoutHandle handle = nullptr; void *data = nullptr; - DmTimerStatus timerStatus = Timer_->Start(timeOut,handle,data); - EXPECT_EQ(DM_STATUS_FINISH,timerStatus); + DmTimerStatus timerStatus = Timer_->Start(timeOut, handle, data); + EXPECT_EQ(DM_STATUS_FINISH, timerStatus); } /** * @tc.name: DmTimerTest::Start_002 - * @tc.desc: to check when mTimerName_ is not empty,handle is not nullptr,data is not nullptr,mStatus_ != DmTimerStatus::DM_STATUS_INIT + * @tc.desc: to check when mTimerName_ is not empty, handle is not nullptr, data is not nullptr, + * @mStatus_ != DmTimerStatus::DM_STATUS_INIT * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -135,8 +135,8 @@ HWTEST_F(DmTimerTest, Start_002, testing::ext::TestSize.Level0) int idx = 1; void *data = &idx; Timer_->mStatus_ = DmTimerStatus::DM_STATUS_RUNNING; - Timer_->Start(timeOut,TimeOutTest,data); - EXPECT_EQ(DmTimerStatus::DM_STATUS_BUSY,Timer_->mStatus_); + Timer_->Start(timeOut, TimeOutTest,data); + EXPECT_EQ(DmTimerStatus::DM_STATUS_BUSY, Timer_->mStatus_); } /** @@ -219,7 +219,7 @@ HWTEST_F(DmTimerTest, CreateTimeFd_001, testing::ext::TestSize.Level0) const std::string DM_TIMER_TASK = ""; std::shared_ptr Timer_ = std::make_shared(DM_TIMER_TASK); int32_t result = Timer_->CreateTimeFd(); - EXPECT_EQ(DM_STATUS_FINISH,result); + EXPECT_EQ(DM_STATUS_FINISH, result); } /** @@ -264,7 +264,7 @@ HWTEST_F(DmTimerTest, Release_002, testing::ext::TestSize.Level0) /** * @tc.name: DmTimerTest::GetTimerName_001 - * @tc.desc: to check whether the return value is the same as mTimerName_ + * @tc.desc: to check whether the return value is the same as mTimerName_ * @tc.type: FUNC * @tc.require: AR000GHSJK */ @@ -273,7 +273,7 @@ HWTEST_F(DmTimerTest, GetTimerName_001, testing::ext::TestSize.Level0) const std::string DM_TIMER_TASK = "111"; std::shared_ptr Timer_ = std::make_shared(DM_TIMER_TASK); std::string strTimer = Timer_->GetTimerName(); - EXPECT_EQ("111",strTimer); + EXPECT_EQ("111", strTimer); } } } -- Gitee