Skip to content

Commit

Permalink
Refs #20625: Fix MonitorService Unittests
Browse files Browse the repository at this point in the history
Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>
  • Loading branch information
Mario-DL committed Mar 17, 2024
1 parent bb62db5 commit 759bfaa
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 9 deletions.
20 changes: 11 additions & 9 deletions test/unittest/statistics/rtps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,24 +146,26 @@ target_compile_definitions(MonitorServiceTests PRIVATE FASTRTPS_NO_LIB
)

target_include_directories(MonitorServiceTests PRIVATE
mock/Publisher
mock/StatisticsBase
${PROJECT_SOURCE_DIR}/test/mock/rtps/BuiltinProtocols
${PROJECT_SOURCE_DIR}/test/mock/rtps/external_locators
${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/external_locators
${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
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <chrono>
#include <functional>
#include <mutex>

#include <gmock/gmock.h>

#include <fastdds/rtps/history/WriterHistory.h>
#include <fastdds/rtps/resources/ResourceManagement.h>
#include <fastrtps/utils/TimedMutex.hpp>

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<void (const fastrtps::rtps::InstanceHandle_t&)>)
: WriterHistory(to_history_attributes(topic_att, payloadMaxSize, mempolicy))
{
}

MOCK_METHOD4(add_pub_change, bool(
fastrtps::rtps::CacheChange_t*,
fastrtps::rtps::WriteParams&,
std::unique_lock<fastrtps::RecursiveTimedMutex>&,
const std::chrono::time_point<std::chrono::steady_clock>&));

};

} // namespace dds
} // namespace fastdds
} // namespace eprosima

#endif // _FASTDDS_PUBLISHER_DATAWRITERHISTORY_HPP_

0 comments on commit 759bfaa

Please sign in to comment.