From aee0eb975c859e0e3cf6f0c400f706f23fc4cabc Mon Sep 17 00:00:00 2001 From: Mario Dominguez Date: Fri, 15 Mar 2024 13:02:30 +0100 Subject: [PATCH] Refs #20625: Fix MonitorService Unittests Signed-off-by: Mario Dominguez --- .../fastdds/publisher/DataWriterHistory.hpp | 85 +++++++++++++++++++ test/unittest/statistics/rtps/CMakeLists.txt | 21 ++--- 2 files changed, 96 insertions(+), 10 deletions(-) create mode 100644 test/mock/dds/Publisher/fastdds/publisher/DataWriterHistory.hpp diff --git a/test/mock/dds/Publisher/fastdds/publisher/DataWriterHistory.hpp b/test/mock/dds/Publisher/fastdds/publisher/DataWriterHistory.hpp new file mode 100644 index 0000000000..f1859167b1 --- /dev/null +++ b/test/mock/dds/Publisher/fastdds/publisher/DataWriterHistory.hpp @@ -0,0 +1,85 @@ +// Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// 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 _FASTDDS_PUBLISHER_DATAWRITERHISTORY_HPP_ +#define _FASTDDS_PUBLISHER_DATAWRITERHISTORY_HPP_ + +#include +#include +#include + +#include + +#include +#include +#include + +namespace eprosima { +namespace fastrtps { + +class TopicAttributes; + +namespace rtps { + +class WriteParams; + +} // namespace rtps +} // namespace fastrtps + + +namespace fastdds { +namespace dds { + +class DomainParticipant; +class PublisherListener; +class DataWriter; +class DataWriterListener; +class Topic; + + +static fastrtps::rtps::HistoryAttributes to_history_attributes( + const fastrtps::TopicAttributes&, + uint32_t, + fastrtps::rtps::MemoryManagementPolicy_t) +{ + + return fastrtps::rtps::HistoryAttributes(); +} + +class DataWriterHistory : public fastrtps::rtps::WriterHistory +{ +public: + + DataWriterHistory( + const fastrtps::TopicAttributes& topic_att, + uint32_t payloadMaxSize, + fastrtps::rtps::MemoryManagementPolicy_t mempolicy, + std::function) + : WriterHistory(to_history_attributes(topic_att, payloadMaxSize, mempolicy)) + { + } + + MOCK_METHOD4(add_pub_change, bool( + fastrtps::rtps::CacheChange_t*, + fastrtps::rtps::WriteParams&, + std::unique_lock&, + const std::chrono::time_point&)); + +}; + +} // namespace dds +} // namespace fastdds +} // namespace eprosima + +#endif // _FASTDDS_PUBLISHER_DATAWRITERHISTORY_HPP_ diff --git a/test/unittest/statistics/rtps/CMakeLists.txt b/test/unittest/statistics/rtps/CMakeLists.txt index 4a997149ec..87f75f027d 100644 --- a/test/unittest/statistics/rtps/CMakeLists.txt +++ b/test/unittest/statistics/rtps/CMakeLists.txt @@ -140,23 +140,24 @@ target_compile_definitions(MonitorServiceTests PRIVATE FASTRTPS_NO_LIB target_include_directories(MonitorServiceTests PRIVATE mock/StatisticsBase + ${PROJECT_SOURCE_DIR}/test/mock/dds/Publisher ${PROJECT_SOURCE_DIR}/test/mock/rtps/BuiltinProtocols - ${PROJECT_SOURCE_DIR}/test/mock/rtps/ExternalLocatorsProcessor - ${PROJECT_SOURCE_DIR}/test/mock/rtps/RTPSParticipantImpl - ${PROJECT_SOURCE_DIR}/test/mock/rtps/Endpoint ${PROJECT_SOURCE_DIR}/test/mock/rtps/EDP - ${PROJECT_SOURCE_DIR}/test/mock/rtps/WLP + ${PROJECT_SOURCE_DIR}/test/mock/rtps/Endpoint + ${PROJECT_SOURCE_DIR}/test/mock/rtps/ExternalLocatorsProcessor + ${PROJECT_SOURCE_DIR}/test/mock/rtps/ReaderHistory ${PROJECT_SOURCE_DIR}/test/mock/rtps/ReceiverResource + ${PROJECT_SOURCE_DIR}/test/mock/rtps/RTPSParticipantImpl ${PROJECT_SOURCE_DIR}/test/mock/rtps/RTPSReader - ${PROJECT_SOURCE_DIR}/test/mock/rtps/StatefulReader - ${PROJECT_SOURCE_DIR}/test/mock/rtps/StatelessReader - ${PROJECT_SOURCE_DIR}/test/mock/rtps/ReaderHistory ${PROJECT_SOURCE_DIR}/test/mock/rtps/RTPSWriter + ${PROJECT_SOURCE_DIR}/test/mock/rtps/SecurityManager + ${PROJECT_SOURCE_DIR}/test/mock/rtps/StatefulReader ${PROJECT_SOURCE_DIR}/test/mock/rtps/StatefulWriter + ${PROJECT_SOURCE_DIR}/test/mock/rtps/StatelessReader ${PROJECT_SOURCE_DIR}/test/mock/rtps/StatelessWriter - ${PROJECT_SOURCE_DIR}/test/mock/rtps/WriterHistory - ${PROJECT_SOURCE_DIR}/test/mock/rtps/SecurityManager ${PROJECT_SOURCE_DIR}/test/mock/rtps/TypeLookupManager + ${PROJECT_SOURCE_DIR}/test/mock/rtps/WLP + ${PROJECT_SOURCE_DIR}/test/mock/rtps/WriterHistory ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include ${PROJECT_SOURCE_DIR}/src/cpp @@ -168,7 +169,7 @@ target_link_libraries(MonitorServiceTests GTest::gtest GTest::gmock $<$:OpenSSL::SSL$OpenSSL::Crypto>) - + gtest_discover_tests(MonitorServiceTests) if(QNX)