From 08b29191cfbc1e09e14a037b0abc45cc8d7c3c69 Mon Sep 17 00:00:00 2001 From: gaoqiang_strong Date: Mon, 26 Sep 2022 13:44:52 +0800 Subject: [PATCH] fix ut Signed-off-by: gaoqiang_strong --- .../test/unittest/include/softbus_adapter_test.h | 11 +++++++++++ .../test/unittest/src/softbus_adapter_test.cpp | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/services/softbusadapter/test/unittest/include/softbus_adapter_test.h b/services/softbusadapter/test/unittest/include/softbus_adapter_test.h index 134b103b..fb67ed50 100644 --- a/services/softbusadapter/test/unittest/include/softbus_adapter_test.h +++ b/services/softbusadapter/test/unittest/include/softbus_adapter_test.h @@ -25,6 +25,7 @@ #include "dscreen_constants.h" #include "dscreen_errcode.h" #include "dscreen_util.h" +#include "isoftbus_listener.h" #define private public #include "softbus_adapter.h" #undef private @@ -40,6 +41,16 @@ public: SoftbusAdapter softbusAdapter; }; +class MockSoftbusListener : public ISoftbusListener { +public: + MockSoftbusListener() = default; + ~MockSoftbusListener() = default; + void OnSessionOpened(int32_t sessionId, int32_t result) override {} + void OnSessionClosed(int32_t sessionId) override {} + void OnBytesReceived(int32_t sessionId, const void *data, uint32_t dataLen) override {} + void OnStreamReceived(int32_t sessionId, const StreamData *data, const StreamData *ext, + const StreamFrameInfo *param) override {} +}; } // namespace DistributedHardware } // namespace OHOS #endif \ No newline at end of file diff --git a/services/softbusadapter/test/unittest/src/softbus_adapter_test.cpp b/services/softbusadapter/test/unittest/src/softbus_adapter_test.cpp index 689d5d11..9f7fc535 100644 --- a/services/softbusadapter/test/unittest/src/softbus_adapter_test.cpp +++ b/services/softbusadapter/test/unittest/src/softbus_adapter_test.cpp @@ -35,7 +35,7 @@ void SoftbusAdapterTest::TearDown(void) {} */ HWTEST_F(SoftbusAdapterTest, RegisterSoftbusListener_001, TestSize.Level1) { - std::shared_ptr listener = nullptr; + std::shared_ptr listener = std::make_shared(); std::string sessionName = DATA_SESSION_NAME; std::string peerDevId = "testDevId"; @@ -54,7 +54,7 @@ HWTEST_F(SoftbusAdapterTest, RegisterSoftbusListener_001, TestSize.Level1) */ HWTEST_F(SoftbusAdapterTest, RegisterSoftbusListener_002, TestSize.Level1) { - std::shared_ptr listener = nullptr; + std::shared_ptr listener = std::make_shared(); std::string sessionName = DATA_SESSION_NAME; std::string peerDevId = "testDevId"; -- Gitee