Skip to content

Commit af84fd3

Browse files
committed
Refs #24046: Templatize test_basic_secure_communication method
Signed-off-by: Carlos Ferreira González <carlosferreira@eprosima.com>
1 parent b369915 commit af84fd3

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

test/blackbox/common/BlackboxTestsSecurity.cpp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,24 @@ class Security : public testing::TestWithParam<std::tuple<communication_type, re
282282
eprosima::fastdds::dds::ReliabilityQosPolicyKind reliability_;
283283
};
284284

285+
// Per-type default data generator dispatch for test_basic_secure_communication.
286+
inline std::list<HelloWorld> default_secure_data_generator(
287+
HelloWorldPubSubType*)
288+
{
289+
return default_helloworld_data_generator();
290+
}
291+
292+
inline std::list<Data1mb> default_secure_data_generator(
293+
Data1mbPubSubType*)
294+
{
295+
return default_data300kb_data_generator();
296+
}
297+
285298
// This method tests basic reliable communication with security plugins configured
299+
template<typename T>
286300
void test_basic_secure_communication(
287-
PubSubReader<HelloWorldPubSubType>& reader,
288-
PubSubWriter<HelloWorldPubSubType>& writer,
301+
PubSubReader<T>& reader,
302+
PubSubWriter<T>& writer,
289303
bool is_best_effort = false)
290304
{
291305
ASSERT_TRUE(reader.isInitialized());
@@ -299,7 +313,7 @@ void test_basic_secure_communication(
299313
writer.wait_discovery();
300314
reader.wait_discovery();
301315

302-
auto data = default_helloworld_data_generator();
316+
auto data = default_secure_data_generator(static_cast<T*>(nullptr));
303317

304318
reader.startReception(data);
305319

@@ -315,7 +329,7 @@ void test_basic_secure_communication(
315329
// Retry sending once if fewer than 2 samples were received within the timeout.
316330
if (reader.block_for_all(std::chrono::seconds(2)) < 2)
317331
{
318-
auto retry_data = default_helloworld_data_generator();
332+
auto retry_data = default_secure_data_generator(static_cast<T*>(nullptr));
319333
reader.startReception(retry_data);
320334
writer.send(retry_data);
321335
reader.block_for_at_least(2);

0 commit comments

Comments
 (0)