diff --git a/fastdds_python/src/swig/fastdds/dds/domain/DomainParticipant.i b/fastdds_python/src/swig/fastdds/dds/domain/DomainParticipant.i index 3246cdb2..4e62f13c 100644 --- a/fastdds_python/src/swig/fastdds/dds/domain/DomainParticipant.i +++ b/fastdds_python/src/swig/fastdds/dds/domain/DomainParticipant.i @@ -18,6 +18,12 @@ %extend eprosima::fastdds::dds::DomainParticipant { + /** + * Modifies the DomainParticipantListener, sets the mask to StatusMask::all() + * + * @param listener new value for the DomainParticipantListener + * @return RETCODE_OK + */ ReturnCode_t set_listener( DomainParticipantListener* listener) { @@ -55,6 +61,13 @@ return ret; } + /** + * Modifies the DomainParticipantListener. + * + * @param listener new value for the DomainParticipantListener + * @param mask StatusMask that holds statuses the listener responds to + * @return RETCODE_OK + */ ReturnCode_t set_listener( DomainParticipantListener* listener, const StatusMask& mask) @@ -93,6 +106,14 @@ return ret; } + /** + * Create a Publisher in this Participant. + * + * @param qos QoS of the Publisher. + * @param listener Pointer to the listener (default: nullptr) + * @param mask StatusMask that holds statuses the listener responds to (default: all) + * @return Pointer to the created Publisher. + */ Publisher* create_publisher( const PublisherQos& qos, PublisherListener* listener = nullptr, @@ -113,6 +134,41 @@ return self->create_publisher(qos, listener, mask); } + /** + * Create a Publisher in this Participant. + * + * @param profile_name Publisher profile name. + * @param listener Pointer to the listener (default: nullptr) + * @param mask StatusMask that holds statuses the listener responds to (default: all) + * @return Pointer to the created Publisher. + */ + Publisher* create_publisher_with_profile( + const std::string& profile_name, + PublisherListener* listener = nullptr, + const StatusMask& mask = eprosima::fastdds::dds::StatusMask::all()) + { + if (nullptr != listener) + { + Swig::Director* director = SWIG_DIRECTOR_CAST(listener); + + if (nullptr != director) + { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + Py_INCREF(director->swig_get_self()); + SWIG_PYTHON_THREAD_END_BLOCK; + } + } + + return self->create_publisher_with_profile(profile_name, listener, mask); + } + + /** + * Deletes an existing Publisher. + * + * @param publisher to be deleted. + * @return RETCODE_PRECONDITION_NOT_MET if the publisher does not belong to this participant or if it has active DataWriters, + * RETCODE_OK if it is correctly deleted and RETCODE_ERROR otherwise. + */ ReturnCode_t delete_publisher( const Publisher* publisher) { @@ -135,6 +191,14 @@ return ret; } + /** + * Create a Subscriber in this Participant. + * + * @param qos QoS of the Subscriber. + * @param listener Pointer to the listener (default: nullptr) + * @param mask StatusMask that holds statuses the listener responds to (default: all) + * @return Pointer to the created Subscriber. + */ Subscriber* create_subscriber( const SubscriberQos& qos, SubscriberListener* listener = nullptr, @@ -155,6 +219,41 @@ return self->create_subscriber(qos, listener, mask); } + /** + * Create a Subscriber in this Participant. + * + * @param profile_name Subscriber profile name. + * @param listener Pointer to the listener (default: nullptr) + * @param mask StatusMask that holds statuses the listener responds to (default: all) + * @return Pointer to the created Subscriber. + */ + RTPS_DllAPI Subscriber* create_subscriber_with_profile( + const std::string& profile_name, + SubscriberListener* listener = nullptr, + const StatusMask& mask = eprosima::fastdds::dds::StatusMask::all()) + { + if (nullptr != listener) + { + Swig::Director* director = SWIG_DIRECTOR_CAST(listener); + + if (nullptr != director) + { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + Py_INCREF(director->swig_get_self()); + SWIG_PYTHON_THREAD_END_BLOCK; + } + } + + return self->create_subscriber_with_profile(profile_name, listener, mask); + } + + /** + * Deletes an existing Subscriber. + * + * @param subscriber to be deleted. + * @return RETCODE_PRECONDITION_NOT_MET if the subscriber does not belong to this participant or if it has active DataReaders, + * RETCODE_OK if it is correctly deleted and RETCODE_ERROR otherwise. + */ ReturnCode_t delete_subscriber( const Subscriber* subscriber) { @@ -183,8 +282,10 @@ %ignore eprosima::fastdds::dds::DomainParticipant::~DomainParticipant; %ignore eprosima::fastdds::dds::DomainParticipant::set_listener; %ignore eprosima::fastdds::dds::DomainParticipant::create_publisher; +%ignore eprosima::fastdds::dds::DomainParticipant::create_publisher_with_profile; %ignore eprosima::fastdds::dds::DomainParticipant::create_subscriber; %ignore eprosima::fastdds::dds::DomainParticipant::delete_publisher; %ignore eprosima::fastdds::dds::DomainParticipant::delete_subscriber; +%ignore eprosima::fastdds::dds::DomainParticipant::create_subscriber_with_profile; %include "fastdds/dds/domain/DomainParticipant.hpp" diff --git a/fastdds_python/src/swig/fastdds/dds/domain/DomainParticipantFactory.i b/fastdds_python/src/swig/fastdds/dds/domain/DomainParticipantFactory.i index a2d2a580..51287681 100644 --- a/fastdds_python/src/swig/fastdds/dds/domain/DomainParticipantFactory.i +++ b/fastdds_python/src/swig/fastdds/dds/domain/DomainParticipantFactory.i @@ -23,6 +23,15 @@ */ %extend eprosima::fastdds::dds::DomainParticipantFactory { + /** + * Create a Participant. + * + * @param domain_id Domain Id. + * @param qos DomainParticipantQos Reference. + * @param listener DomainParticipantListener Pointer (default: nullptr) + * @param mask StatusMask Reference (default: all) + * @return DomainParticipant pointer. (nullptr if not created.) + */ DomainParticipant* create_participant( DomainId_t domain_id, const DomainParticipantQos& qos, @@ -44,6 +53,71 @@ return self->create_participant(domain_id, qos, listener, mask); } + /** + * Create a Participant. + * + * @param domain_id Domain Id. + * @param profile_name Participant profile name. + * @param listener DomainParticipantListener Pointer (default: nullptr) + * @param mask StatusMask Reference (default: all) + * @return DomainParticipant pointer. (nullptr if not created.) + */ + DomainParticipant* create_participant_with_profile( + DomainId_t domain_id, + const std::string& profile_name, + DomainParticipantListener* listener = nullptr, + const StatusMask& mask = eprosima::fastdds::dds::StatusMask::all()) + { + if (nullptr != listener) + { + Swig::Director* director = SWIG_DIRECTOR_CAST(listener); + + if (nullptr != director) + { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + Py_INCREF(director->swig_get_self()); + SWIG_PYTHON_THREAD_END_BLOCK; + } + } + + return self->create_participant_with_profile(domain_id, profile_name, listener, mask); + } + + /** + * Create a Participant. + * + * @param profile_name Participant profile name. + * @param listener DomainParticipantListener Pointer (default: nullptr) + * @param mask StatusMask Reference (default: all) + * @return DomainParticipant pointer. (nullptr if not created.) + */ + DomainParticipant* create_participant_with_profile( + const std::string& profile_name, + DomainParticipantListener* listener = nullptr, + const StatusMask& mask = eprosima::fastdds::dds::StatusMask::all()) + { + if (nullptr != listener) + { + Swig::Director* director = SWIG_DIRECTOR_CAST(listener); + + if (nullptr != director) + { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + Py_INCREF(director->swig_get_self()); + SWIG_PYTHON_THREAD_END_BLOCK; + } + } + + return self->create_participant_with_profile(profile_name, listener, mask); + } + + /** + * Remove a Participant and all associated publishers and subscribers. + * + * @param part Pointer to the participant. + * @return RETCODE_PRECONDITION_NOT_MET if the participant has active entities, RETCODE_OK if the participant is correctly + * deleted and RETCODE_ERROR otherwise. + */ ReturnCode_t delete_participant( DomainParticipant* part) { @@ -68,6 +142,7 @@ } %ignore eprosima::fastdds::dds::DomainParticipantFactory::create_participant; +%ignore eprosima::fastdds::dds::DomainParticipantFactory::create_participant_with_profile; %ignore eprosima::fastdds::dds::DomainParticipantFactory::delete_participant; %include "fastdds/dds/domain/DomainParticipantFactory.hpp" diff --git a/fastdds_python/src/swig/fastdds/dds/publisher/Publisher.i b/fastdds_python/src/swig/fastdds/dds/publisher/Publisher.i index edea3286..0fa98d6b 100644 --- a/fastdds_python/src/swig/fastdds/dds/publisher/Publisher.i +++ b/fastdds_python/src/swig/fastdds/dds/publisher/Publisher.i @@ -18,6 +18,12 @@ %extend eprosima::fastdds::dds::Publisher { + /** + * Modifies the PublisherListener, sets the mask to StatusMask::all() + * + * @param listener new value for the PublisherListener + * @return RETCODE_OK + */ ReturnCode_t set_listener( PublisherListener* listener) { @@ -55,6 +61,14 @@ return ret; } + + /** + * Modifies the PublisherListener. + * + * @param listener new value for the PublisherListener + * @param mask StatusMask that holds statuses the listener responds to + * @return RETCODE_OK + */ ReturnCode_t set_listener( PublisherListener* listener, const StatusMask& mask) @@ -93,6 +107,15 @@ return ret; } + /** + * This operation creates a DataWriter. The returned DataWriter will be attached and belongs to the Publisher. + * + * @param topic Topic the DataWriter will be listening + * @param qos QoS of the DataWriter. + * @param listener Pointer to the listener (default: nullptr). + * @param mask StatusMask that holds statuses the listener responds to (default: all). + * @return Pointer to the created DataWriter. nullptr if failed. + */ DataWriter* create_datawriter( Topic* topic, const DataWriterQos& writer_qos, @@ -114,6 +137,51 @@ return self->create_datawriter(topic, writer_qos, listener, mask); } + /** + * This operation creates a DataWriter. The returned DataWriter will be attached and belongs to the Publisher. + * + * @param topic Topic the DataWriter will be listening + * @param profile_name DataWriter profile name. + * @param listener Pointer to the listener (default: nullptr). + * @param mask StatusMask that holds statuses the listener responds to (default: all). + * @return Pointer to the created DataWriter. nullptr if failed. + */ + DataWriter* create_datawriter_with_profile( + Topic* topic, + const std::string& profile_name, + DataWriterListener* listener = nullptr, + const StatusMask& mask = eprosima::fastdds::dds::StatusMask::all()) + { + if (nullptr != listener) + { + Swig::Director* director = SWIG_DIRECTOR_CAST(listener); + + if (nullptr != director) + { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + Py_INCREF(director->swig_get_self()); + SWIG_PYTHON_THREAD_END_BLOCK; + } + } + + return self->create_datawriter_with_profile(topic, profile_name, listener, mask); + } + + /** + * This operation deletes a DataWriter that belongs to the Publisher. + * + * The delete_datawriter operation must be called on the same Publisher object used to create the DataWriter. + * If delete_datawriter is called on a different Publisher, the operation will have no effect and it will + * return false. + * + * The deletion of the DataWriter will automatically unregister all instances. + * Depending on the settings of the WRITER_DATA_LIFECYCLE QosPolicy, the deletion of the DataWriter + * may also dispose all instances. + * + * @param writer DataWriter to delete + * @return RETCODE_PRECONDITION_NOT_MET if it does not belong to this Publisher, RETCODE_OK if it is correctly deleted and + * RETCODE_ERROR otherwise. + */ ReturnCode_t delete_datawriter( const DataWriter* writer) { @@ -141,6 +209,7 @@ %ignore eprosima::fastdds::dds::Publisher::~Publisher; %ignore eprosima::fastdds::dds::Publisher::set_listener; %ignore eprosima::fastdds::dds::Publisher::create_datawriter; +%ignore eprosima::fastdds::dds::Publisher::create_datawriter_with_profile; %ignore eprosima::fastdds::dds::Publisher::delete_datawriter; %include "fastdds/dds/publisher/Publisher.hpp" diff --git a/fastdds_python/src/swig/fastdds/dds/subscriber/Subscriber.i b/fastdds_python/src/swig/fastdds/dds/subscriber/Subscriber.i index c814101e..65d82039 100644 --- a/fastdds_python/src/swig/fastdds/dds/subscriber/Subscriber.i +++ b/fastdds_python/src/swig/fastdds/dds/subscriber/Subscriber.i @@ -18,6 +18,12 @@ %extend eprosima::fastdds::dds::Subscriber { + /** + * Modifies the SubscriberListener, sets the mask to StatusMask::all() + * + * @param listener new value for SubscriberListener + * @return RETCODE_OK + */ ReturnCode_t set_listener( SubscriberListener* listener) { @@ -55,6 +61,13 @@ return ret; } + /** + * Modifies the SubscriberListener. + * + * @param listener new value for the SubscriberListener + * @param mask StatusMask that holds statuses the listener responds to. + * @return RETCODE_OK + */ ReturnCode_t set_listener( SubscriberListener* listener, const StatusMask& mask) @@ -93,6 +106,15 @@ return ret; } + /** + * This operation creates a DataReader. The returned DataReader will be attached and belong to the Subscriber. + * + * @param topic Topic the DataReader will be listening. + * @param reader_qos QoS of the DataReader. + * @param listener Pointer to the listener (default: nullptr) + * @param mask StatusMask that holds statuses the listener responds to (default: all). + * @return Pointer to the created DataReader. nullptr if failed. + */ DataReader* create_datareader( TopicDescription* topic, const DataReaderQos& reader_qos, @@ -114,6 +136,47 @@ return self->create_datareader(topic, reader_qos, listener, mask); } + /** + * This operation creates a DataReader. The returned DataReader will be attached and belongs to the Subscriber. + * + * @param topic Topic the DataReader will be listening. + * @param profile_name DataReader profile name. + * @param listener Pointer to the listener (default: nullptr) + * @param mask StatusMask that holds statuses the listener responds to (default: all). + * @return Pointer to the created DataReader. nullptr if failed. + */ + RTPS_DllAPI DataReader* create_datareader_with_profile( + TopicDescription* topic, + const std::string& profile_name, + DataReaderListener* listener = nullptr, + const StatusMask& mask = eprosima::fastdds::dds::StatusMask::all()) + { + if (nullptr != listener) + { + Swig::Director* director = SWIG_DIRECTOR_CAST(listener); + + if (nullptr != director) + { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + Py_INCREF(director->swig_get_self()); + SWIG_PYTHON_THREAD_END_BLOCK; + } + } + + return self->create_datareader_with_profile(topic, profile_name, listener, mask); + } + + /** + * This operation deletes a DataReader that belongs to the Subscriber. + * + * The delete_datareader operation must be called on the same Subscriber object used to create the DataReader. + * If delete_datareader is called on a different Subscriber, the operation will have no effect and it will + * return an error. + * + * @param reader DataReader to delete + * @return RETCODE_PRECONDITION_NOT_MET if the datareader does not belong to this subscriber, RETCODE_OK if it is correctly + * deleted and RETCODE_ERROR otherwise. + */ ReturnCode_t delete_datareader( const DataReader* reader) { @@ -141,6 +204,7 @@ %ignore eprosima::fastdds::dds::Subscriber::~Subscriber; %ignore eprosima::fastdds::dds::Subscriber::set_listener; %ignore eprosima::fastdds::dds::Subscriber::create_datareader; +%ignore eprosima::fastdds::dds::Subscriber::create_datareader_with_profile; %ignore eprosima::fastdds::dds::Subscriber::delete_datareader; %include "fastdds/dds/subscriber/Subscriber.hpp" diff --git a/fastdds_python/test/api/DEFAULT_FASTRTPS_PROFILES.xml b/fastdds_python/test/api/DEFAULT_FASTRTPS_PROFILES.xml new file mode 100644 index 00000000..10253650 --- /dev/null +++ b/fastdds_python/test/api/DEFAULT_FASTRTPS_PROFILES.xml @@ -0,0 +1,47 @@ + + + + + 3 + + test_name + + + + + + + + partition_name_c + + + + + + + + + + partition_name_b + + + + + + + + + VOLATILE + + + + + + + + RELIABLE + + + + + diff --git a/fastdds_python/test/api/test_domainparticipant.py b/fastdds_python/test/api/test_domainparticipant.py index 9bce1311..30079990 100644 --- a/fastdds_python/test/api/test_domainparticipant.py +++ b/fastdds_python/test/api/test_domainparticipant.py @@ -72,7 +72,7 @@ def test_contains_entity(participant): participant.delete_publisher(publisher)) -def test_create_and_delete_publisher(participant): +def test_create_publisher(participant): """ This test checks: - DomainParticipant::create_publisher @@ -182,7 +182,131 @@ def test(status_mask_1, status_mask_2, listnr=None): listener) -def test_create_and_delete_subscriber(participant): +def test_create_publisher_with_profile(participant): + """ + This test checks: + - DomainParticipant::create_publisher_with_profile + - DomainParticipant::delete_publisher + - Publisher::get_status_mask + - StatusMask::operator == + - StatusMask::operator << + """ + listener = PublisherListener() + assert(listener is not None) + + # Failure + publisher = participant.create_publisher_with_profile( + 'no_exits_profile') + assert(publisher is None) + + # Overload 1 + publisher = participant.create_publisher_with_profile( + 'test_publisher_profile') + assert(publisher is not None) + assert(publisher.is_enabled()) + qos = publisher.get_qos() + assert('partition_name_c' == qos.partition()[0]) + assert(fastdds.StatusMask.all() == publisher.get_status_mask()) + assert(fastdds.ReturnCode_t.RETCODE_OK == + participant.delete_publisher(publisher)) + + # Overload 2 + publisher = participant.create_publisher_with_profile( + 'test_publisher_profile', listener) + assert(publisher is not None) + assert(publisher.is_enabled()) + qos = publisher.get_qos() + assert('partition_name_c' == qos.partition()[0]) + assert(fastdds.StatusMask.all() == publisher.get_status_mask()) + assert(fastdds.ReturnCode_t.RETCODE_OK == + participant.delete_publisher(publisher)) + + def test(status_mask_1, status_mask_2, listnr=None): + """ + Test the entity creation using the two types of StatusMasks. + """ + publisher = participant.create_publisher_with_profile( + 'test_publisher_profile', listnr, status_mask_1) + assert(publisher is not None) + assert(publisher.is_enabled()) + qos = publisher.get_qos() + assert('partition_name_c' == qos.partition()[0]) + assert(status_mask_1 == publisher.get_status_mask()) + assert(fastdds.ReturnCode_t.RETCODE_OK == + participant.delete_publisher(publisher)) + publisher = participant.create_publisher_with_profile( + 'test_publisher_profile', listnr, status_mask_2) + assert(publisher is not None) + assert(publisher.is_enabled()) + qos = publisher.get_qos() + assert('partition_name_c' == qos.partition()[0]) + assert(status_mask_2 == publisher.get_status_mask()) + assert(fastdds.ReturnCode_t.RETCODE_OK == + participant.delete_publisher(publisher)) + + # Overload 3: Different status masks + test(fastdds.StatusMask.all(), fastdds.StatusMask_all(), None) + test(fastdds.StatusMask.all(), fastdds.StatusMask_all(), listener) + test(fastdds.StatusMask.none(), fastdds.StatusMask_none(), listener) + test(fastdds.StatusMask.data_available(), + fastdds.StatusMask_data_available(), listener) + test(fastdds.StatusMask.data_on_readers(), + fastdds.StatusMask_data_on_readers(), listener) + test(fastdds.StatusMask.inconsistent_topic(), + fastdds.StatusMask_inconsistent_topic(), listener) + test(fastdds.StatusMask.liveliness_changed(), + fastdds.StatusMask_liveliness_changed(), listener) + test(fastdds.StatusMask.liveliness_lost(), + fastdds.StatusMask_liveliness_lost(), listener) + test(fastdds.StatusMask.offered_deadline_missed(), + fastdds.StatusMask_offered_deadline_missed(), listener) + test(fastdds.StatusMask.offered_incompatible_qos(), + fastdds.StatusMask_offered_incompatible_qos(), listener) + test(fastdds.StatusMask.publication_matched(), + fastdds.StatusMask_publication_matched(), listener) + test(fastdds.StatusMask.requested_deadline_missed(), + fastdds.StatusMask_requested_deadline_missed(), listener) + test(fastdds.StatusMask.requested_incompatible_qos(), + fastdds.StatusMask_requested_incompatible_qos(), listener) + test(fastdds.StatusMask.sample_lost(), + fastdds.StatusMask_sample_lost(), listener) + test(fastdds.StatusMask.sample_rejected(), + fastdds.StatusMask_sample_rejected(), listener) + test(fastdds.StatusMask.subscription_matched(), + fastdds.StatusMask_subscription_matched(), listener) + + m = fastdds.StatusMask_data_available() << \ + fastdds.StatusMask_data_on_readers() << \ + fastdds.StatusMask_inconsistent_topic() << \ + fastdds.StatusMask_liveliness_changed() << \ + fastdds.StatusMask_liveliness_lost() << \ + fastdds.StatusMask_offered_deadline_missed() << \ + fastdds.StatusMask_offered_incompatible_qos() << \ + fastdds.StatusMask_publication_matched() << \ + fastdds.StatusMask_requested_deadline_missed() << \ + fastdds.StatusMask_requested_incompatible_qos() << \ + fastdds.StatusMask_sample_lost() << \ + fastdds.StatusMask_sample_rejected() << \ + fastdds.StatusMask_subscription_matched() + + test(fastdds.StatusMask.data_available() << + fastdds.StatusMask.data_on_readers() << + fastdds.StatusMask.inconsistent_topic() << + fastdds.StatusMask.liveliness_changed() << + fastdds.StatusMask.liveliness_lost() << + fastdds.StatusMask.offered_deadline_missed() << + fastdds.StatusMask.offered_incompatible_qos() << + fastdds.StatusMask.publication_matched() << + fastdds.StatusMask.requested_deadline_missed() << + fastdds.StatusMask.requested_incompatible_qos() << + fastdds.StatusMask.sample_lost() << + fastdds.StatusMask.sample_rejected() << + fastdds.StatusMask.subscription_matched(), + m, + listener) + + +def test_create_subscriber(participant): """ This test checks: - DomainParticipant::create_subscriber @@ -292,6 +416,130 @@ def test(status_mask_1, status_mask_2, listnr=None): listener) +def test_create_subscriber_with_profile(participant): + """ + This test checks: + - DomainParticipant::create_subscriber_with_profile + - DomainParticipant::delete_subscriber + - Subscriber::get_status_mask + - StatusMask::operator == + - StatusMask::operator << + """ + listener = SubscriberListener() + assert(listener is not None) + + # Failure + subscriber = participant.create_subscriber_with_profile( + 'no_exits_profile') + assert(subscriber is None) + + # Overload 1 + subscriber = participant.create_subscriber_with_profile( + 'test_subscriber_profile') + assert(subscriber is not None) + assert(subscriber.is_enabled()) + qos = subscriber.get_qos() + assert('partition_name_b' == qos.partition()[0]) + assert(fastdds.StatusMask.all() == subscriber.get_status_mask()) + assert(fastdds.ReturnCode_t.RETCODE_OK == + participant.delete_subscriber(subscriber)) + + # Overload 2 + subscriber = participant.create_subscriber_with_profile( + 'test_subscriber_profile', listener) + assert(subscriber is not None) + assert(subscriber.is_enabled()) + qos = subscriber.get_qos() + assert('partition_name_b' == qos.partition()[0]) + assert(fastdds.StatusMask.all() == subscriber.get_status_mask()) + assert(fastdds.ReturnCode_t.RETCODE_OK == + participant.delete_subscriber(subscriber)) + + def test(status_mask_1, status_mask_2, listnr=None): + """ + Test the entity creation using the two types of StatusMasks. + """ + subscriber = participant.create_subscriber_with_profile( + 'test_subscriber_profile', listnr, status_mask_1) + assert(subscriber is not None) + assert(subscriber.is_enabled()) + qos = subscriber.get_qos() + assert('partition_name_b' == qos.partition()[0]) + assert(status_mask_1 == subscriber.get_status_mask()) + assert(fastdds.ReturnCode_t.RETCODE_OK == + participant.delete_subscriber(subscriber)) + subscriber = participant.create_subscriber_with_profile( + 'test_subscriber_profile', listnr, status_mask_2) + assert(subscriber is not None) + assert(subscriber.is_enabled()) + qos = subscriber.get_qos() + assert('partition_name_b' == qos.partition()[0]) + assert(status_mask_2 == subscriber.get_status_mask()) + assert(fastdds.ReturnCode_t.RETCODE_OK == + participant.delete_subscriber(subscriber)) + + # Overload 3: Different status masks + test(fastdds.StatusMask.all(), fastdds.StatusMask_all(), None) + test(fastdds.StatusMask.all(), fastdds.StatusMask_all(), listener) + test(fastdds.StatusMask.none(), fastdds.StatusMask_none(), listener) + test(fastdds.StatusMask.data_available(), + fastdds.StatusMask_data_available(), listener) + test(fastdds.StatusMask.data_on_readers(), + fastdds.StatusMask_data_on_readers(), listener) + test(fastdds.StatusMask.inconsistent_topic(), + fastdds.StatusMask_inconsistent_topic(), listener) + test(fastdds.StatusMask.liveliness_changed(), + fastdds.StatusMask_liveliness_changed(), listener) + test(fastdds.StatusMask.liveliness_lost(), + fastdds.StatusMask_liveliness_lost(), listener) + test(fastdds.StatusMask.offered_deadline_missed(), + fastdds.StatusMask_offered_deadline_missed(), listener) + test(fastdds.StatusMask.offered_incompatible_qos(), + fastdds.StatusMask_offered_incompatible_qos(), listener) + test(fastdds.StatusMask.publication_matched(), + fastdds.StatusMask_publication_matched(), listener) + test(fastdds.StatusMask.requested_deadline_missed(), + fastdds.StatusMask_requested_deadline_missed(), listener) + test(fastdds.StatusMask.requested_incompatible_qos(), + fastdds.StatusMask_requested_incompatible_qos(), listener) + test(fastdds.StatusMask.sample_lost(), + fastdds.StatusMask_sample_lost(), listener) + test(fastdds.StatusMask.sample_rejected(), + fastdds.StatusMask_sample_rejected(), listener) + test(fastdds.StatusMask.subscription_matched(), + fastdds.StatusMask_subscription_matched(), listener) + + m = fastdds.StatusMask_data_available() << \ + fastdds.StatusMask_data_on_readers() << \ + fastdds.StatusMask_inconsistent_topic() << \ + fastdds.StatusMask_liveliness_changed() << \ + fastdds.StatusMask_liveliness_lost() << \ + fastdds.StatusMask_offered_deadline_missed() << \ + fastdds.StatusMask_offered_incompatible_qos() << \ + fastdds.StatusMask_publication_matched() << \ + fastdds.StatusMask_requested_deadline_missed() << \ + fastdds.StatusMask_requested_incompatible_qos() << \ + fastdds.StatusMask_sample_lost() << \ + fastdds.StatusMask_sample_rejected() << \ + fastdds.StatusMask_subscription_matched() + + test(fastdds.StatusMask.data_available() << + fastdds.StatusMask.data_on_readers() << + fastdds.StatusMask.inconsistent_topic() << + fastdds.StatusMask.liveliness_changed() << + fastdds.StatusMask.liveliness_lost() << + fastdds.StatusMask.offered_deadline_missed() << + fastdds.StatusMask.offered_incompatible_qos() << + fastdds.StatusMask.publication_matched() << + fastdds.StatusMask.requested_deadline_missed() << + fastdds.StatusMask.requested_incompatible_qos() << + fastdds.StatusMask.sample_lost() << + fastdds.StatusMask.sample_rejected() << + fastdds.StatusMask.subscription_matched(), + m, + listener) + + def test_create_and_delete_topic(participant): """ This test checks: @@ -741,7 +989,7 @@ def test_lookup_topicdescription(participant): participant.delete_topic(topic)) -def test_listener_ownership(participant): +def test_listener_ownership(): factory = fastdds.DomainParticipantFactory.get_instance() def second_participant(): @@ -750,6 +998,10 @@ def second_participant(): listener, fastdds.StatusMask.all()) participant2 = second_participant() + participant = factory.create_participant( + 0, fastdds.PARTICIPANT_QOS_DEFAULT) time.sleep(1) + assert(fastdds.ReturnCode_t.RETCODE_OK == + factory.delete_participant(participant)) assert(fastdds.ReturnCode_t.RETCODE_OK == factory.delete_participant(participant2)) diff --git a/fastdds_python/test/api/test_domainparticipantfactory.py b/fastdds_python/test/api/test_domainparticipantfactory.py new file mode 100644 index 00000000..2ae066eb --- /dev/null +++ b/fastdds_python/test/api/test_domainparticipantfactory.py @@ -0,0 +1,283 @@ +import fastdds + + +def test_create_participant(): + """ + This test checks: + - DomainParticipantFactory::create_participant + - DomainParticipantFactory::delete_participant + - Publisher::get_status_mask + - StatusMask::operator == + - StatusMask::operator << + """ + factory = fastdds.DomainParticipantFactory.get_instance() + + # Overload 1 + participant = factory.create_participant( + 0, fastdds.PARTICIPANT_QOS_DEFAULT) + assert(participant.is_enabled()) + assert(fastdds.StatusMask.all() == participant.get_status_mask()) + assert(participant is not None) + assert(fastdds.ReturnCode_t.RETCODE_OK == + factory.delete_participant(participant)) + + # Overload 2 + listener = fastdds.DomainParticipantListener() + participant = factory.create_participant( + 0, fastdds.PARTICIPANT_QOS_DEFAULT, listener) + assert(participant is not None) + assert(participant.is_enabled()) + assert(fastdds.StatusMask.all() == participant.get_status_mask()) + assert(fastdds.ReturnCode_t.RETCODE_OK == + factory.delete_participant(participant)) + + def test(status_mask_1, status_mask_2, listnr=None): + """ + Test the entity creation using the two types of StatusMasks. + """ + participant = factory.create_participant( + 0, fastdds.PARTICIPANT_QOS_DEFAULT, listnr, status_mask_1) + assert(participant is not None) + assert(participant.is_enabled()) + assert(status_mask_1 == participant.get_status_mask()) + assert(fastdds.ReturnCode_t.RETCODE_OK == + factory.delete_participant(participant)) + participant = factory.create_participant( + 0, fastdds.PARTICIPANT_QOS_DEFAULT, listnr, status_mask_2) + assert(participant is not None) + assert(participant.is_enabled()) + assert(status_mask_1 == participant.get_status_mask()) + assert(fastdds.ReturnCode_t.RETCODE_OK == + factory.delete_participant(participant)) + + # Overload 3: Different status masks + test(fastdds.StatusMask.all(), fastdds.StatusMask_all(), None) + test(fastdds.StatusMask.all(), fastdds.StatusMask_all(), listener) + test(fastdds.StatusMask.none(), fastdds.StatusMask_none(), listener) + test(fastdds.StatusMask.data_available(), + fastdds.StatusMask_data_available(), listener) + test(fastdds.StatusMask.data_on_readers(), + fastdds.StatusMask_data_on_readers(), listener) + test(fastdds.StatusMask.inconsistent_topic(), + fastdds.StatusMask_inconsistent_topic(), listener) + test(fastdds.StatusMask.liveliness_changed(), + fastdds.StatusMask_liveliness_changed(), listener) + test(fastdds.StatusMask.liveliness_lost(), + fastdds.StatusMask_liveliness_lost(), listener) + test(fastdds.StatusMask.offered_deadline_missed(), + fastdds.StatusMask_offered_deadline_missed(), listener) + test(fastdds.StatusMask.offered_incompatible_qos(), + fastdds.StatusMask_offered_incompatible_qos(), listener) + test(fastdds.StatusMask.publication_matched(), + fastdds.StatusMask_publication_matched(), listener) + test(fastdds.StatusMask.requested_deadline_missed(), + fastdds.StatusMask_requested_deadline_missed(), listener) + test(fastdds.StatusMask.requested_incompatible_qos(), + fastdds.StatusMask_requested_incompatible_qos(), listener) + test(fastdds.StatusMask.sample_lost(), + fastdds.StatusMask_sample_lost(), listener) + test(fastdds.StatusMask.sample_rejected(), + fastdds.StatusMask_sample_rejected(), listener) + test(fastdds.StatusMask.subscription_matched(), + fastdds.StatusMask_subscription_matched(), listener) + + m = fastdds.StatusMask_data_available() << \ + fastdds.StatusMask_data_on_readers() << \ + fastdds.StatusMask_inconsistent_topic() << \ + fastdds.StatusMask_liveliness_changed() << \ + fastdds.StatusMask_liveliness_lost() << \ + fastdds.StatusMask_offered_deadline_missed() << \ + fastdds.StatusMask_offered_incompatible_qos() << \ + fastdds.StatusMask_publication_matched() << \ + fastdds.StatusMask_requested_deadline_missed() << \ + fastdds.StatusMask_requested_incompatible_qos() << \ + fastdds.StatusMask_sample_lost() << \ + fastdds.StatusMask_sample_rejected() << \ + fastdds.StatusMask_subscription_matched() + + test(fastdds.StatusMask.data_available() << + fastdds.StatusMask.data_on_readers() << + fastdds.StatusMask.inconsistent_topic() << + fastdds.StatusMask.liveliness_changed() << + fastdds.StatusMask.liveliness_lost() << + fastdds.StatusMask.offered_deadline_missed() << + fastdds.StatusMask.offered_incompatible_qos() << + fastdds.StatusMask.publication_matched() << + fastdds.StatusMask.requested_deadline_missed() << + fastdds.StatusMask.requested_incompatible_qos() << + fastdds.StatusMask.sample_lost() << + fastdds.StatusMask.sample_rejected() << + fastdds.StatusMask.subscription_matched(), + m, + listener) + + +def test_create_participant_with_profile(): + """ + This test checks: + - DomainParticipantFactory::create_participant_with_profile + - DomainParticipantFactory::delete_participant + - Publisher::get_status_mask + - StatusMask::operator == + - StatusMask::operator << + """ + factory = fastdds.DomainParticipantFactory.get_instance() + + # Failure + participant = factory.create_participant_with_profile( + 'no_exits_profile') + assert(participant is None) + participant = factory.create_participant_with_profile( + 0, 'no_exits_profile') + assert(participant is None) + + # Overload 1 + participant = factory.create_participant_with_profile( + 'test_participant_profile') + assert(participant is not None) + assert(participant.is_enabled()) + assert(3 == participant.get_domain_id()) + qos = participant.get_qos() + assert('test_name' == qos.name()) + assert(fastdds.StatusMask.all() == participant.get_status_mask()) + assert(fastdds.ReturnCode_t.RETCODE_OK == + factory.delete_participant(participant)) + participant = factory.create_participant_with_profile( + 0, 'test_participant_profile') + assert(participant is not None) + assert(participant.is_enabled()) + assert(0 == participant.get_domain_id()) + qos = participant.get_qos() + assert('test_name' == qos.name()) + assert(fastdds.StatusMask.all() == participant.get_status_mask()) + assert(fastdds.ReturnCode_t.RETCODE_OK == + factory.delete_participant(participant)) + + # Overload 2 + listener = fastdds.DomainParticipantListener() + participant = factory.create_participant_with_profile( + 'test_participant_profile', listener) + assert(participant is not None) + assert(participant.is_enabled()) + assert(3 == participant.get_domain_id()) + qos = participant.get_qos() + assert('test_name' == qos.name()) + assert(fastdds.StatusMask.all() == participant.get_status_mask()) + assert(fastdds.ReturnCode_t.RETCODE_OK == + factory.delete_participant(participant)) + participant = factory.create_participant_with_profile( + 0, 'test_participant_profile', listener) + assert(participant is not None) + assert(participant.is_enabled()) + assert(0 == participant.get_domain_id()) + qos = participant.get_qos() + assert('test_name' == qos.name()) + assert(fastdds.StatusMask.all() == participant.get_status_mask()) + assert(fastdds.ReturnCode_t.RETCODE_OK == + factory.delete_participant(participant)) + + def test(status_mask_1, status_mask_2, listnr=None): + """ + Test the entity creation using the two types of StatusMasks. + """ + participant = factory.create_participant_with_profile( + 'test_participant_profile', listnr, status_mask_1) + assert(participant is not None) + assert(participant.is_enabled()) + assert(3 == participant.get_domain_id()) + qos = participant.get_qos() + assert('test_name' == qos.name()) + assert(status_mask_1 == participant.get_status_mask()) + assert(fastdds.ReturnCode_t.RETCODE_OK == + factory.delete_participant(participant)) + participant = factory.create_participant_with_profile( + 0, 'test_participant_profile', listnr, status_mask_1) + assert(participant is not None) + assert(participant.is_enabled()) + assert(0 == participant.get_domain_id()) + qos = participant.get_qos() + assert('test_name' == qos.name()) + assert(status_mask_1 == participant.get_status_mask()) + assert(fastdds.ReturnCode_t.RETCODE_OK == + factory.delete_participant(participant)) + participant = factory.create_participant_with_profile( + 'test_participant_profile', listnr, status_mask_2) + assert(participant is not None) + assert(participant.is_enabled()) + assert(3 == participant.get_domain_id()) + qos = participant.get_qos() + assert('test_name' == qos.name()) + assert(status_mask_1 == participant.get_status_mask()) + assert(fastdds.ReturnCode_t.RETCODE_OK == + factory.delete_participant(participant)) + participant = factory.create_participant_with_profile( + 0, 'test_participant_profile', listnr, status_mask_2) + assert(participant is not None) + assert(participant.is_enabled()) + assert(0 == participant.get_domain_id()) + qos = participant.get_qos() + assert('test_name' == qos.name()) + assert(status_mask_1 == participant.get_status_mask()) + assert(fastdds.ReturnCode_t.RETCODE_OK == + factory.delete_participant(participant)) + + # Overload 3: Different status masks + test(fastdds.StatusMask.all(), fastdds.StatusMask_all(), None) + test(fastdds.StatusMask.all(), fastdds.StatusMask_all(), listener) + test(fastdds.StatusMask.none(), fastdds.StatusMask_none(), listener) + test(fastdds.StatusMask.data_available(), + fastdds.StatusMask_data_available(), listener) + test(fastdds.StatusMask.data_on_readers(), + fastdds.StatusMask_data_on_readers(), listener) + test(fastdds.StatusMask.inconsistent_topic(), + fastdds.StatusMask_inconsistent_topic(), listener) + test(fastdds.StatusMask.liveliness_changed(), + fastdds.StatusMask_liveliness_changed(), listener) + test(fastdds.StatusMask.liveliness_lost(), + fastdds.StatusMask_liveliness_lost(), listener) + test(fastdds.StatusMask.offered_deadline_missed(), + fastdds.StatusMask_offered_deadline_missed(), listener) + test(fastdds.StatusMask.offered_incompatible_qos(), + fastdds.StatusMask_offered_incompatible_qos(), listener) + test(fastdds.StatusMask.publication_matched(), + fastdds.StatusMask_publication_matched(), listener) + test(fastdds.StatusMask.requested_deadline_missed(), + fastdds.StatusMask_requested_deadline_missed(), listener) + test(fastdds.StatusMask.requested_incompatible_qos(), + fastdds.StatusMask_requested_incompatible_qos(), listener) + test(fastdds.StatusMask.sample_lost(), + fastdds.StatusMask_sample_lost(), listener) + test(fastdds.StatusMask.sample_rejected(), + fastdds.StatusMask_sample_rejected(), listener) + test(fastdds.StatusMask.subscription_matched(), + fastdds.StatusMask_subscription_matched(), listener) + + m = fastdds.StatusMask_data_available() << \ + fastdds.StatusMask_data_on_readers() << \ + fastdds.StatusMask_inconsistent_topic() << \ + fastdds.StatusMask_liveliness_changed() << \ + fastdds.StatusMask_liveliness_lost() << \ + fastdds.StatusMask_offered_deadline_missed() << \ + fastdds.StatusMask_offered_incompatible_qos() << \ + fastdds.StatusMask_publication_matched() << \ + fastdds.StatusMask_requested_deadline_missed() << \ + fastdds.StatusMask_requested_incompatible_qos() << \ + fastdds.StatusMask_sample_lost() << \ + fastdds.StatusMask_sample_rejected() << \ + fastdds.StatusMask_subscription_matched() + + test(fastdds.StatusMask.data_available() << + fastdds.StatusMask.data_on_readers() << + fastdds.StatusMask.inconsistent_topic() << + fastdds.StatusMask.liveliness_changed() << + fastdds.StatusMask.liveliness_lost() << + fastdds.StatusMask.offered_deadline_missed() << + fastdds.StatusMask.offered_incompatible_qos() << + fastdds.StatusMask.publication_matched() << + fastdds.StatusMask.requested_deadline_missed() << + fastdds.StatusMask.requested_incompatible_qos() << + fastdds.StatusMask.sample_lost() << + fastdds.StatusMask.sample_rejected() << + fastdds.StatusMask.subscription_matched(), + m, + listener) diff --git a/fastdds_python/test/api/test_publisher.py b/fastdds_python/test/api/test_publisher.py index 65b42945..be86b60b 100644 --- a/fastdds_python/test/api/test_publisher.py +++ b/fastdds_python/test/api/test_publisher.py @@ -88,7 +88,7 @@ def test_coherent_changes(publisher): publisher.end_coherent_changes()) -def test_create_and_delete_datawriter(topic, publisher): +def test_create_datawriter(topic, publisher): """ This test checks: - Publisher::create_datawriter @@ -199,6 +199,134 @@ def test(status_mask_1, status_mask_2, listnr=None): listener) +def test_create_datawriter_with_profile(topic, publisher): + """ + This test checks: + - Publisher::create_datawriter_with_profile + - Publisher::delete_datawriter + - DataWriter::get_status_mask + - StatusMask::operator == + - StatusMask::operator << + """ + listener = DataWriterListener() + assert(listener is not None) + + # Failure + datawriter = publisher.create_datawriter_with_profile( + topic, 'no_exits_profile') + assert(datawriter is None) + + # Overload 1 + datawriter = publisher.create_datawriter_with_profile( + topic, 'test_datawriter_profile') + assert(datawriter is not None) + assert(datawriter.is_enabled()) + qos = datawriter.get_qos() + assert(fastdds.VOLATILE_DURABILITY_QOS == + qos.durability().kind) + assert(fastdds.StatusMask.all() == datawriter.get_status_mask()) + assert(fastdds.ReturnCode_t.RETCODE_OK == + publisher.delete_datawriter(datawriter)) + + # Overload 2 + datawriter = publisher.create_datawriter_with_profile( + topic, 'test_datawriter_profile', listener) + assert(datawriter is not None) + assert(datawriter.is_enabled()) + qos = datawriter.get_qos() + assert(fastdds.VOLATILE_DURABILITY_QOS == + qos.durability().kind) + assert(fastdds.StatusMask.all() == datawriter.get_status_mask()) + assert(fastdds.ReturnCode_t.RETCODE_OK == + publisher.delete_datawriter(datawriter)) + + def test(status_mask_1, status_mask_2, listnr=None): + """ + Test the entity creation using the two types of StatusMasks. + """ + datawriter = publisher.create_datawriter_with_profile( + topic, 'test_datawriter_profile', listnr, status_mask_1) + assert(datawriter is not None) + assert(datawriter.is_enabled()) + qos = datawriter.get_qos() + assert(fastdds.VOLATILE_DURABILITY_QOS == + qos.durability().kind) + assert(status_mask_1 == datawriter.get_status_mask()) + assert(fastdds.ReturnCode_t.RETCODE_OK == + publisher.delete_datawriter(datawriter)) + datawriter = publisher.create_datawriter_with_profile( + topic, 'test_datawriter_profile', listnr, status_mask_2) + assert(datawriter is not None) + assert(datawriter.is_enabled()) + qos = datawriter.get_qos() + assert(fastdds.VOLATILE_DURABILITY_QOS == + qos.durability().kind) + assert(status_mask_2 == datawriter.get_status_mask()) + assert(fastdds.ReturnCode_t.RETCODE_OK == + publisher.delete_datawriter(datawriter)) + + # Overload 3: Different status masks + test(fastdds.StatusMask.all(), fastdds.StatusMask_all(), None) + test(fastdds.StatusMask.all(), fastdds.StatusMask_all(), listener) + test(fastdds.StatusMask.none(), fastdds.StatusMask_none(), listener) + test(fastdds.StatusMask.data_available(), + fastdds.StatusMask_data_available(), listener) + test(fastdds.StatusMask.data_on_readers(), + fastdds.StatusMask_data_on_readers(), listener) + test(fastdds.StatusMask.inconsistent_topic(), + fastdds.StatusMask_inconsistent_topic(), listener) + test(fastdds.StatusMask.liveliness_changed(), + fastdds.StatusMask_liveliness_changed(), listener) + test(fastdds.StatusMask.liveliness_lost(), + fastdds.StatusMask_liveliness_lost(), listener) + test(fastdds.StatusMask.offered_deadline_missed(), + fastdds.StatusMask_offered_deadline_missed(), listener) + test(fastdds.StatusMask.offered_incompatible_qos(), + fastdds.StatusMask_offered_incompatible_qos(), listener) + test(fastdds.StatusMask.publication_matched(), + fastdds.StatusMask_publication_matched(), listener) + test(fastdds.StatusMask.requested_deadline_missed(), + fastdds.StatusMask_requested_deadline_missed(), listener) + test(fastdds.StatusMask.requested_incompatible_qos(), + fastdds.StatusMask_requested_incompatible_qos(), listener) + test(fastdds.StatusMask.sample_lost(), + fastdds.StatusMask_sample_lost(), listener) + test(fastdds.StatusMask.sample_rejected(), + fastdds.StatusMask_sample_rejected(), listener) + test(fastdds.StatusMask.subscription_matched(), + fastdds.StatusMask_subscription_matched(), listener) + + m = fastdds.StatusMask_data_available() << \ + fastdds.StatusMask_data_on_readers() << \ + fastdds.StatusMask_inconsistent_topic() << \ + fastdds.StatusMask_liveliness_changed() << \ + fastdds.StatusMask_liveliness_lost() << \ + fastdds.StatusMask_offered_deadline_missed() << \ + fastdds.StatusMask_offered_incompatible_qos() << \ + fastdds.StatusMask_publication_matched() << \ + fastdds.StatusMask_requested_deadline_missed() << \ + fastdds.StatusMask_requested_incompatible_qos() << \ + fastdds.StatusMask_sample_lost() << \ + fastdds.StatusMask_sample_rejected() << \ + fastdds.StatusMask_subscription_matched() + + test(fastdds.StatusMask.data_available() << + fastdds.StatusMask.data_on_readers() << + fastdds.StatusMask.inconsistent_topic() << + fastdds.StatusMask.liveliness_changed() << + fastdds.StatusMask.liveliness_lost() << + fastdds.StatusMask.offered_deadline_missed() << + fastdds.StatusMask.offered_incompatible_qos() << + fastdds.StatusMask.publication_matched() << + fastdds.StatusMask.requested_deadline_missed() << + fastdds.StatusMask.requested_incompatible_qos() << + fastdds.StatusMask.sample_lost() << + fastdds.StatusMask.sample_rejected() << + fastdds.StatusMask.subscription_matched(), + m, + listener) + + def test_deleted_contained_entities(participant, topic, publisher): """ This test checks: diff --git a/fastdds_python/test/api/test_subscriber.py b/fastdds_python/test/api/test_subscriber.py index f4a7490a..a2099c19 100644 --- a/fastdds_python/test/api/test_subscriber.py +++ b/fastdds_python/test/api/test_subscriber.py @@ -89,7 +89,7 @@ def test_access(subscriber): subscriber.end_access()) -def test_create_and_delete_datareader(topic, subscriber): +def test_create_datareader(topic, subscriber): """ This test checks: - Subscriber::create_datareader @@ -200,6 +200,133 @@ def test(status_mask_1, status_mask_2, listnr=None): listener) +def test_create_datareader_with_profile(topic, subscriber): + """ + This test checks: + - Subscriber::create_datareader + - Subscriber::delete_datareader + - DataReader::get_status_mask + - StatusMask::operator == + - StatusMask::operator << + """ + listener = DataReaderListener() + assert(listener is not None) + + # Failure + datareader = subscriber.create_datareader_with_profile( + topic, 'no_exits_profile') + assert(datareader is None) + + # Overload 1 + datareader = subscriber.create_datareader_with_profile( + topic, 'test_datareader_profile') + assert(datareader is not None) + assert(datareader.is_enabled()) + qos = datareader.get_qos() + assert(fastdds.RELIABLE_RELIABILITY_QOS == + qos.reliability().kind) + assert(fastdds.StatusMask.all() == datareader.get_status_mask()) + assert(fastdds.ReturnCode_t.RETCODE_OK == + subscriber.delete_datareader(datareader)) + + # Overload 2 + datareader = subscriber.create_datareader_with_profile( + topic, 'test_datareader_profile', listener) + assert(datareader is not None) + assert(datareader.is_enabled()) + qos = datareader.get_qos() + assert(fastdds.RELIABLE_RELIABILITY_QOS == + qos.reliability().kind) + assert(fastdds.StatusMask.all() == datareader.get_status_mask()) + assert(fastdds.ReturnCode_t.RETCODE_OK == + subscriber.delete_datareader(datareader)) + + def test(status_mask_1, status_mask_2, listnr=None): + """ + Test the entity creation using the two types of StatusMasks. + """ + datareader = subscriber.create_datareader_with_profile( + topic, 'test_datareader_profile', listnr, status_mask_1) + assert(datareader is not None) + assert(datareader.is_enabled()) + qos = datareader.get_qos() + assert(fastdds.RELIABLE_RELIABILITY_QOS == + qos.reliability().kind) + assert(status_mask_1 == datareader.get_status_mask()) + assert(fastdds.ReturnCode_t.RETCODE_OK == + subscriber.delete_datareader(datareader)) + datareader = subscriber.create_datareader_with_profile( + topic, 'test_datareader_profile', listnr, status_mask_2) + assert(datareader is not None) + assert(datareader.is_enabled()) + assert(fastdds.RELIABLE_RELIABILITY_QOS == + qos.reliability().kind) + assert(status_mask_2 == datareader.get_status_mask()) + assert(fastdds.ReturnCode_t.RETCODE_OK == + subscriber.delete_datareader(datareader)) + + # Overload 3: Different status masks + test(fastdds.StatusMask.all(), fastdds.StatusMask_all(), None) + test(fastdds.StatusMask.all(), fastdds.StatusMask_all(), listener) + test(fastdds.StatusMask.none(), fastdds.StatusMask_none(), listener) + test(fastdds.StatusMask.data_available(), + fastdds.StatusMask_data_available(), listener) + test(fastdds.StatusMask.data_on_readers(), + fastdds.StatusMask_data_on_readers(), listener) + test(fastdds.StatusMask.inconsistent_topic(), + fastdds.StatusMask_inconsistent_topic(), listener) + test(fastdds.StatusMask.liveliness_changed(), + fastdds.StatusMask_liveliness_changed(), listener) + test(fastdds.StatusMask.liveliness_lost(), + fastdds.StatusMask_liveliness_lost(), listener) + test(fastdds.StatusMask.offered_deadline_missed(), + fastdds.StatusMask_offered_deadline_missed(), listener) + test(fastdds.StatusMask.offered_incompatible_qos(), + fastdds.StatusMask_offered_incompatible_qos(), listener) + test(fastdds.StatusMask.publication_matched(), + fastdds.StatusMask_publication_matched(), listener) + test(fastdds.StatusMask.requested_deadline_missed(), + fastdds.StatusMask_requested_deadline_missed(), listener) + test(fastdds.StatusMask.requested_incompatible_qos(), + fastdds.StatusMask_requested_incompatible_qos(), listener) + test(fastdds.StatusMask.sample_lost(), + fastdds.StatusMask_sample_lost(), listener) + test(fastdds.StatusMask.sample_rejected(), + fastdds.StatusMask_sample_rejected(), listener) + test(fastdds.StatusMask.subscription_matched(), + fastdds.StatusMask_subscription_matched(), listener) + + m = fastdds.StatusMask_data_available() << \ + fastdds.StatusMask_data_on_readers() << \ + fastdds.StatusMask_inconsistent_topic() << \ + fastdds.StatusMask_liveliness_changed() << \ + fastdds.StatusMask_liveliness_lost() << \ + fastdds.StatusMask_offered_deadline_missed() << \ + fastdds.StatusMask_offered_incompatible_qos() << \ + fastdds.StatusMask_publication_matched() << \ + fastdds.StatusMask_requested_deadline_missed() << \ + fastdds.StatusMask_requested_incompatible_qos() << \ + fastdds.StatusMask_sample_lost() << \ + fastdds.StatusMask_sample_rejected() << \ + fastdds.StatusMask_subscription_matched() + + test(fastdds.StatusMask.data_available() << + fastdds.StatusMask.data_on_readers() << + fastdds.StatusMask.inconsistent_topic() << + fastdds.StatusMask.liveliness_changed() << + fastdds.StatusMask.liveliness_lost() << + fastdds.StatusMask.offered_deadline_missed() << + fastdds.StatusMask.offered_incompatible_qos() << + fastdds.StatusMask.publication_matched() << + fastdds.StatusMask.requested_deadline_missed() << + fastdds.StatusMask.requested_incompatible_qos() << + fastdds.StatusMask.sample_lost() << + fastdds.StatusMask.sample_rejected() << + fastdds.StatusMask.subscription_matched(), + m, + listener) + + def test_delete_contained_entities(participant, topic, subscriber): """ This test checks: