@@ -311,6 +311,35 @@ TEST(ParticipantTests, CreateDomainParticipant)
311
311
312
312
}
313
313
314
+ /* *
315
+ * @brief Check whether two @ref DomainParticipantQos are equivalent properties wise and equal elsewhere.
316
+ *
317
+ * @c qos_1 and @c qos_2 have equivalent properties if:
318
+ *
319
+ * 1. They have equal binary properties
320
+ * 2. All the non-binary properties of @c qos_2 are present (by name) in @c qos_1
321
+ *
322
+ * @param[in] qos_1 LHS @ref DomainParticipantQos
323
+ * @param[in] qos_2 RHS @ref DomainParticipantQos
324
+ */
325
+ void check_equivalent_qos (
326
+ const DomainParticipantQos& qos_1,
327
+ const DomainParticipantQos& qos_2)
328
+ {
329
+ ASSERT_EQ (qos_1.user_data (), qos_2.user_data ());
330
+ ASSERT_EQ (qos_1.entity_factory (), qos_2.entity_factory ());
331
+ ASSERT_EQ (qos_1.allocation (), qos_2.allocation ());
332
+ for (auto property : qos_2.properties ().properties ())
333
+ {
334
+ ASSERT_NE (nullptr , fastrtps::rtps::PropertyPolicyHelper::find_property (qos_1.properties (), property.name ()));
335
+ }
336
+ ASSERT_EQ (qos_1.properties ().binary_properties (), qos_2.properties ().binary_properties ());
337
+ ASSERT_EQ (qos_1.wire_protocol (), qos_2.wire_protocol ());
338
+ ASSERT_EQ (qos_1.transport (), qos_2.transport ());
339
+ ASSERT_EQ (qos_1.name (), qos_2.name ());
340
+ ASSERT_EQ (qos_1.flow_controllers (), qos_2.flow_controllers ());
341
+ }
342
+
314
343
void check_participant_with_profile (
315
344
DomainParticipant* participant,
316
345
const std::string& profile_name)
@@ -321,9 +350,14 @@ void check_participant_with_profile (
321
350
ParticipantAttributes participant_atts;
322
351
XMLProfileManager::fillParticipantAttributes (profile_name, participant_atts);
323
352
324
- // Values taken from profile
353
+ /* Values taken from profile */
325
354
ASSERT_TRUE (qos.allocation () == participant_atts.rtps .allocation );
326
- ASSERT_TRUE (qos.properties () == participant_atts.rtps .properties );
355
+ // Check that all the non-binary properties in participant_atts are present (by name) in qos
356
+ for (auto property : participant_atts.rtps .properties .properties ())
357
+ {
358
+ ASSERT_NE (nullptr , fastrtps::rtps::PropertyPolicyHelper::find_property (qos.properties (), property.name ()));
359
+ }
360
+ ASSERT_TRUE (qos.properties ().binary_properties () == participant_atts.rtps .properties .binary_properties ());
327
361
ASSERT_TRUE (qos.name ().to_string () == participant_atts.rtps .getName ());
328
362
ASSERT_TRUE (qos.wire_protocol ().prefix == participant_atts.rtps .prefix );
329
363
ASSERT_TRUE (qos.wire_protocol ().participant_id == participant_atts.rtps .participantID );
@@ -344,6 +378,41 @@ void check_participant_with_profile (
344
378
ASSERT_TRUE (qos.entity_factory () == PARTICIPANT_QOS_DEFAULT.entity_factory ());
345
379
}
346
380
381
+ /* *
382
+ * This test checks that:
383
+ *
384
+ * 1. In the case of disabled Statistics, none of the physical data related properties are present in a default
385
+ * constructed DomainParticipantQos.
386
+ * 2. In the case of enabled Statistics, all of the physical data related properties are present in a default
387
+ * constructed DomainParticipantQos, and that their default value is empty.
388
+ */
389
+ TEST (ParticipantTests, DomainParticipantQosPhysicalProperties)
390
+ {
391
+ std::vector<std::string> property_names = {
392
+ parameter_policy_physical_data_host,
393
+ parameter_policy_physical_data_user,
394
+ parameter_policy_physical_data_process
395
+ };
396
+ #ifndef FASTDDS_STATISTICS
397
+ /* Check the behaviour when FASTDDS_STATISTICS is NOT defined */
398
+ DomainParticipantQos qos_1;
399
+ for (std::string property_name : property_names)
400
+ {
401
+ std::string* property = fastrtps::rtps::PropertyPolicyHelper::find_property (qos_1.properties (), property_name);
402
+ ASSERT_EQ (nullptr , property);
403
+ }
404
+ #else
405
+ /* Check the behaviour when FASTDDS_STATISTICS is defined */
406
+ DomainParticipantQos qos_2;
407
+ for (std::string property_name : property_names)
408
+ {
409
+ std::string* property = fastrtps::rtps::PropertyPolicyHelper::find_property (qos_2.properties (), property_name);
410
+ ASSERT_NE (nullptr , property);
411
+ ASSERT_TRUE (property->empty ());
412
+ }
413
+ #endif // ifndef FASTDDS_STATISTICS
414
+ }
415
+
347
416
TEST (ParticipantTests, CreateDomainParticipantWithProfile)
348
417
{
349
418
DomainParticipantFactory::get_instance ()->load_XML_profiles_file (" test_xml_profiles.xml" );
@@ -494,7 +563,7 @@ TEST(ParticipantTests, ChangeDomainParticipantQos)
494
563
DomainParticipantQos qos;
495
564
participant->get_qos (qos);
496
565
497
- ASSERT_EQ (qos, PARTICIPANT_QOS_DEFAULT);
566
+ check_equivalent_qos (qos, PARTICIPANT_QOS_DEFAULT);
498
567
499
568
qos.entity_factory ().autoenable_created_entities = false ;
500
569
ASSERT_TRUE (participant->set_qos (qos) == ReturnCode_t::RETCODE_OK);
@@ -515,7 +584,7 @@ TEST(ParticipantTests, ChangePSMDomainParticipantQos)
515
584
participant = ::dds::domain::DomainParticipant (0 , PARTICIPANT_QOS_DEFAULT);
516
585
::dds::domain::qos::DomainParticipantQos qos = participant.qos ();
517
586
518
- ASSERT_EQ (qos, PARTICIPANT_QOS_DEFAULT);
587
+ check_equivalent_qos (qos, PARTICIPANT_QOS_DEFAULT);
519
588
520
589
qos.entity_factory ().autoenable_created_entities = false ;
521
590
ASSERT_NO_THROW (participant.qos (qos));
@@ -1012,7 +1081,7 @@ TEST(ParticipantTests, ChangeWireProtocolQos)
1012
1081
DomainParticipantQos qos;
1013
1082
participant->get_qos (qos);
1014
1083
1015
- ASSERT_EQ (qos, PARTICIPANT_QOS_DEFAULT);
1084
+ check_equivalent_qos (qos, PARTICIPANT_QOS_DEFAULT);
1016
1085
1017
1086
// Check that just adding two servers is OK
1018
1087
rtps::RemoteServerAttributes server;
@@ -1985,7 +2054,7 @@ TEST(ParticipantTests, ChangeAllocationDomainParticipantQos)
1985
2054
DomainParticipantQos qos;
1986
2055
participant->get_qos (qos);
1987
2056
1988
- ASSERT_EQ (qos, PARTICIPANT_QOS_DEFAULT);
2057
+ check_equivalent_qos (qos, PARTICIPANT_QOS_DEFAULT);
1989
2058
1990
2059
qos.allocation ().data_limits .max_properties = 10 ;
1991
2060
ASSERT_EQ (participant->set_qos (qos), ReturnCode_t::RETCODE_OK);
@@ -2023,7 +2092,7 @@ TEST(ParticipantTests, ChangeDomainParcipantName)
2023
2092
DomainParticipantQos qos;
2024
2093
participant->get_qos (qos);
2025
2094
2026
- ASSERT_EQ (qos, PARTICIPANT_QOS_DEFAULT);
2095
+ check_equivalent_qos (qos, PARTICIPANT_QOS_DEFAULT);
2027
2096
2028
2097
qos.name () = " part1" ;
2029
2098
ASSERT_EQ (participant->set_qos (qos), ReturnCode_t::RETCODE_OK);
0 commit comments