From f34aa4fe690adc4f964d957533277f15d5f08d10 Mon Sep 17 00:00:00 2001 From: qinlong Date: Mon, 26 Sep 2022 11:51:24 +0800 Subject: [PATCH] =?UTF-8?q?UT=E5=BC=82=E5=B8=B8=E9=97=AE=E9=A2=98=E6=95=B4?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: qinlong --- .../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..a50bf7a9 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