Skip to content

Commit

Permalink
Refs #11903. Add unit tests for publish modes
Browse files Browse the repository at this point in the history
Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>
  • Loading branch information
richiware committed Jul 5, 2021
1 parent 1b6ddf2 commit 02ded61
Show file tree
Hide file tree
Showing 4 changed files with 1,417 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ class RTPSMessageGroup

MOCK_METHOD0(flush_and_reset, void());

MOCK_METHOD0(reset_current_bytes_processed, void());

MOCK_METHOD0(get_current_bytes_processed, uint32_t());

void change_transmitter(
Expand All @@ -63,6 +61,10 @@ class RTPSMessageGroup
{
}

void reset_current_bytes_processed()
{
}

};

} // namespace rtps
Expand Down
32 changes: 25 additions & 7 deletions test/mock/rtps/RTPSWriter/fastdds/rtps/writer/RTPSWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,32 @@ class RTPSWriter : public Endpoint
{
public:

RTPSWriter()
{
static uint8_t entity_id = 0;
// Generate a guid.
m_guid.entityId.value[3] = ++entity_id;
}

virtual ~RTPSWriter() = default;

virtual bool matched_reader_add(
const ReaderProxyData& ratt) = 0;
const ReaderProxyData&)
{
return false;
}

virtual bool matched_reader_remove(
const GUID_t& ratt) = 0;
const GUID_t&)
{
return false;
}

virtual bool matched_reader_is_matched(
const GUID_t& rguid) = 0;
const GUID_t&)
{
return false;
}

WriterListener* getListener() const
{
Expand Down Expand Up @@ -83,8 +99,6 @@ class RTPSWriter : public Endpoint
#endif // FASTDDS_STATISTICS

// *INDENT-OFF* Uncrustify makes a mess with MOCK_METHOD macros
MOCK_CONST_METHOD0(getGuid, const GUID_t& ());

MOCK_METHOD3(new_change, CacheChange_t* (
const std::function<uint32_t()>&,
ChangeKind_t,
Expand Down Expand Up @@ -127,6 +141,11 @@ class RTPSWriter : public Endpoint

// *INDENT-ON*

const GUID_t& getGuid()
{
return m_guid;
}

virtual void updateAttributes(
const WriterAttributes&)
{
Expand Down Expand Up @@ -217,14 +236,13 @@ class RTPSWriter : public Endpoint

WriterListener* listener_;

const GUID_t m_guid;
GUID_t m_guid;

LivelinessLostStatus liveliness_lost_status_;

LocatorSelectorSender general_locator_selector_ = LocatorSelectorSender(*this, ResourceLimitedContainerConfig());

LocatorSelectorSender async_locator_selector_ = LocatorSelectorSender(*this, ResourceLimitedContainerConfig());

};

} // namespace rtps
Expand Down
35 changes: 32 additions & 3 deletions test/unittest/rtps/flowcontrol/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER))
add_definitions(-D_WIN32_WINNT=0x0601)
endif()

set(FLOWCONTROLLERFACTORYTESTS_SOURCE
FlowControllerFactoryTests.cpp
${PROJECT_SOURCE_DIR}/src/cpp/rtps/flowcontrol/FlowControllerFactory.cpp
set(FLOWCONTROLLER_COMMON_SOURCE
${PROJECT_SOURCE_DIR}/src/cpp/rtps/flowcontrol/FlowControllerConsts.cpp
${PROJECT_SOURCE_DIR}/src/cpp/rtps/writer/LocatorSelectorSender.cpp
${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp
${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/Log.cpp
${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/OStreamConsumer.cpp
Expand All @@ -34,6 +33,12 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER))
${PROJECT_SOURCE_DIR}/src/cpp/rtps/flowcontrol/ThroughputControllerDescriptor.cpp
)

set(FLOWCONTROLLERFACTORYTESTS_SOURCE
${FLOWCONTROLLER_COMMON_SOURCE}
${PROJECT_SOURCE_DIR}/src/cpp/rtps/flowcontrol/FlowControllerFactory.cpp
FlowControllerFactoryTests.cpp
)

add_executable(FlowControllerFactoryTests ${FLOWCONTROLLERFACTORYTESTS_SOURCE})
target_compile_definitions(FlowControllerFactoryTests PRIVATE FASTRTPS_NO_LIB
$<$<AND:$<NOT:$<BOOL:${WIN32}>>,$<STREQUAL:"${CMAKE_BUILD_TYPE}","Debug">>:__DEBUG>
Expand All @@ -52,5 +57,29 @@ if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER))
)
endif()
add_gtest(FlowControllerFactoryTests SOURCES ${FLOWCONTROLLERFACTORYTESTS_SOURCE})

set(FLOWCONTROLLERPUBLISHMODESTESTS_SOURCE
${FLOWCONTROLLER_COMMON_SOURCE}
FlowControllerPublishModesTests.cpp
)

add_executable(FlowControllerPublishModesTests ${FLOWCONTROLLERPUBLISHMODESTESTS_SOURCE})
target_compile_definitions(FlowControllerPublishModesTests PRIVATE FASTRTPS_NO_LIB
$<$<AND:$<NOT:$<BOOL:${WIN32}>>,$<STREQUAL:"${CMAKE_BUILD_TYPE}","Debug">>:__DEBUG>
$<$<BOOL:${INTERNAL_DEBUG}>:__INTERNALDEBUG> # Internal debug activated.
)
target_include_directories(FlowControllerPublishModesTests PRIVATE ${GTEST_INCLUDE_DIRS}
${PROJECT_SOURCE_DIR}/test/mock/rtps/RTPSWriter
${PROJECT_SOURCE_DIR}/test/mock/rtps/RTPSMessageGroup
${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include
${PROJECT_SOURCE_DIR}/src/cpp
)
target_link_libraries(FlowControllerPublishModesTests ${GTEST_LIBRARIES} ${GMOCK_LIBRARIES})
if(MSVC OR MSVC_IDE)
target_link_libraries(FlowControllerPublishModesTests ${PRIVACY}
iphlpapi Shlwapi
)
endif()
add_gtest(FlowControllerPublishModesTests SOURCES ${FLOWCONTROLLERPUBLISHMODESTESTS_SOURCE})
endif()
endif()
Loading

0 comments on commit 02ded61

Please sign in to comment.