diff --git a/services/softbusadapter/test/unittest/include/softbus_adapter_test.h b/services/softbusadapter/test/unittest/include/softbus_adapter_test.h index 134b103b3d71a2e141c6d018483579444b9d2cf6..fb67ed50abd6a4ef2f76c0e345cc48e9f49cd0c8 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 689d5d11447fd9048fba3404501f4d254a73bd2a..a50bf7a9850118839903dba81694e8e57521a6db 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";