22 #ifndef OutPortPullConnector_cpp 23 #define OutPortPullConnector_cpp 25 #include <cppunit/ui/text/TestRunner.h> 26 #include <cppunit/TextOutputter.h> 27 #include <cppunit/extensions/TestFactoryRegistry.h> 28 #include <cppunit/extensions/HelperMacros.h> 29 #include <cppunit/TestAssert.h> 31 #include <coil/Properties.h> 33 #include <rtm/idl/BasicDataTypeSkel.h> 34 #include <rtm/idl/DataPortSkel.h> 67 const RTC::TimedLong&
data)
90 std::cout <<
"------------------------------" << std::endl;
91 std::cout <<
"Connector Listener: " <<
m_name << std::endl;
92 std::cout <<
"Profile::name: " << info.
name << std::endl;
93 std::cout <<
"------------------------------" << std::endl;
106 void log(
const std::string& msg)
108 m_log.push_back(msg);
114 for (
int i = 0; i < (int) m_log.size(); ++i)
116 if (m_log[i] == msg) ++count;
130 template <
class DataType>
139 logger.
log(
"RingBufferMock::Constructor");
140 m_read_return_value = BUFFER_OK;
153 m_read_return_value = value;
176 return ::RTC::BufferStatus::BUFFER_OK;
184 return ::RTC::BufferStatus::BUFFER_OK;
190 virtual DataType*
wptr(
long int n = 0)
200 return ::RTC::BufferStatus::BUFFER_OK;
208 return ::RTC::BufferStatus::BUFFER_OK;
215 long int sec = -1,
long int nsec = -1)
217 return ::RTC::BufferStatus::BUFFER_OK;
239 virtual DataType*
rptr(
long int n = 0)
249 return ::RTC::BufferStatus::BUFFER_OK;
257 return ::RTC::BufferStatus::BUFFER_OK;
263 virtual DataType&
get()
272 long int sec = -1,
long int nsec = -1)
274 if (m_logger != NULL)
276 m_logger->log(
"RingBufferMock::read");
279 return m_read_return_value;
314 template <
class DataType>
325 public virtual ::POA_OpenRTM::OutPortCdr,
326 public virtual PortableServer::RefCountServantBase
343 if (m_logger != NULL)
345 m_logger->log(
"OutPortCorbaCdrProviderMock::init");
352 virtual ::OpenRTM::PortStatus
get(::OpenRTM::CdrData_out
data)
354 return ::OpenRTM::PORT_OK;
418 :
public CppUnit::TestFixture
422 CPPUNIT_TEST(test_OutPortPullConnector);
423 CPPUNIT_TEST(test_write);
424 CPPUNIT_TEST(test_disconnect_getBuffer);
427 CPPUNIT_TEST_SUITE_END();
445 m_pORB = CORBA::ORB_init(argc, argv);
446 m_pPOA = PortableServer::POA::_narrow(
447 m_pORB->resolve_initial_references(
"RootPOA"));
448 m_pPOA->the_POAManager()->activate();
518 RTC::ConnectorProfile prof;
532 prop << conn_prop.
getNode(
"dataport");
554 prop << conn_prop.
getNode(
"dataport");
574 RTC::ConnectorProfile prof;
588 prop << conn_prop.
getNode(
"dataport");
605 ret = connector->
write(cdr);
621 RTC::ConnectorProfile prof;
635 prop << conn_prop.
getNode(
"dataport");
646 CPPUNIT_ASSERT(pbuffer == connector->
getBuffer());
664 RTC::ConnectorProfile prof;
678 prop << conn_prop.
getNode(
"dataport");
707 int main(
int argc,
char* argv[])
720 std::string arg(argv[i]);
721 std::string next_arg;
722 if (i + 1 < argc) next_arg = argv[i + 1];
725 if (arg ==
"--text") { format =
TEXT_OUT;
break; }
738 ofs.open(fname.c_str());
740 if ( arg ==
"--compiler" ) { format =
COMPILER_OUT;
break; }
741 if ( arg ==
"--cerr" ) { target = 1;
break; }
742 if ( arg ==
"--xsl" )
744 if (next_arg ==
"") xsl =
"default.xsl";
747 if ( arg ==
"--namespace" )
751 std::cerr <<
"no namespace specified" << std::endl;
761 CppUnit::TextUi::TestRunner runner;
763 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
765 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest());
766 CppUnit::Outputter* outputter = 0;
767 std::ostream* stream = target ? &std::cerr : &std::cout;
771 outputter =
new CppUnit::TextOutputter(&runner.result(),*stream);
774 std::cout <<
"XML_OUT" << std::endl;
775 outputter =
new CppUnit::XmlOutputter(&runner.result(),
777 static_cast<CppUnit::XmlOutputter*
>(outputter)->setStyleSheet(xsl);
780 outputter =
new CppUnit::CompilerOutputter(&runner.result(),*stream);
783 runner.setOutputter(outputter);
SDOPackage::NameValue newNV(const char *name, Value value)
Create NameValue.
virtual void init(const coil::Properties &prop)
Set the buffer.
ConnectorListeners class.
virtual ~RingBufferMock(void)
virtual DataType * wptr(long int n=0)
Get the writing pointer.
int main(int argc, char **argv)
virtual void activate()=0
Connector activation.
OutPortConnector base class.
ConnListener(const char *name)
CPPUNIT_TEST_SUITE_REGISTRATION(OutPortPullConnector::OutPortPullConnectorTests)
virtual size_t writable() const
Get a writable number.
virtual ReturnCode length(size_t n)
Set the buffer length.
std::vector< DataType > m_buffer
virtual void tearDown()
Test finalization.
void addListener(ConnectorDataListener *listener, bool autoclean)
Add the listener.
std::vector< std::pair< std::string, std::string > > NVList
void test_OutPortPullConnector()
Constructor メソッドテスト
void log(const std::string &msg)
ConnectorListenerHolder connector_[CONNECTOR_LISTENER_NUM]
ConnectorListenerType listener array The ConnectorListenerType listener is stored.
virtual CdrBufferBase * getBuffer()=0
Getting Buffer.
virtual DataType * rptr(long int n=0)
Get the reading pointer.
void setLogger(Logger *logger)
virtual void operator()(const RTC::ConnectorInfo &info)
Virtual Callback method.
std::vector< std::string > m_log
RTC::ReturnCode_t ret(RTC::Local::ReturnCode_t r)
RTC::ConnectorListeners m_listeners
void publishInterfaceProfile(SDOPackage::NVList &properties)
Publish InterfaceProfile information.
void init(coil::Properties &prop)
Initializing configuration.
void set_read_return_value(::RTC::BufferStatus::Enum value)
OutPortCorbaCdrProviderMock(void)
void addListener(ConnectorListener *listener, bool autoclean)
Add the listener.
virtual size_t length(void) const
Get the buffer length.
Enum
DataPortStatus return codes.
PortableServer::POA_ptr m_pPOA
virtual bool empty(void) const
Check on whether the buffer is empty.
virtual ~OutPortCorbaCdrProviderMock(void)
virtual ReturnCode put(const DataType &value)
Write data into the buffer.
void setConnector(RTC::OutPortConnector *connector)
set Connector
#define BUFFERSTATUS_ENUM
Importing RTC::BufferStatus macro.
ConnectorDataListenerHolder connectorData_[CONNECTOR_DATA_LISTENER_NUM]
ConnectorDataListenerType listener array The ConnectorDataListenerType listener is stored...
virtual ReturnCode write(const cdrMemoryStream &data)=0
Destructor.
void test_disconnect_getBuffer()
disconnect メソッドテスト
virtual ReturnCode read(DataType &value, long int sec=-1, long int nsec=-1)
Read data from the buffer.
void copyToProperties(coil::Properties &prop, const SDOPackage::NVList &nv)
Copy NVList to the Proeprties.
virtual ReturnCode write(const DataType &value, long int sec=-1, long int nsec=-1)
Write data into the buffer.
DataListener(const char *name)
ConnectorDataListenerT class.
void test_activate_deactivate()
activate メソッドテスト
OutPortPullConnectorTests()
Constructor.
NameValue and NVList utility functions.
CORBA sequence utility template functions.
virtual ReturnCode disconnect()=0
Disconnect connection.
std::string name
Connection name.
int countLog(const std::string &msg)
void log(const std::string &msg)
void test_write()
write メソッドテスト
void setLogger(Logger *logger)
::RTC::BufferStatus::Enum ReturnCode
prop
Organization::get_organization_property ();.
RTC::Port implementation for InPort.
Class represents a set of properties.
~OutPortPullConnectorTests()
Destructor.
virtual void setUp()
Test initialization.
virtual ReturnCode advanceWptr(long int n=1)
Forward n writing pointers.
void setListener(RTC::ConnectorInfo &info, RTC::ConnectorListeners *listeners)
Set the listener.
bool subscribeInterface(const SDOPackage::NVList &properties)
OutPortPull type connector class.
RingBufferMock< cdrMemoryStream > CdrRingBufferMock
::RTC::BufferStatus::Enum m_read_return_value
::OutPortBase::Logger logger
void push_back(CorbaSequence &seq, SequenceElement elem)
Push the new element back to the CORBA sequence.
BUFFERSTATUS_ENUM RingBufferMock(long int length=8)
OutPortPullConnector class.
void setBuffer(RTC::CdrBufferBase *buffer)
Setting outside buffer's pointer.
Properties & getNode(const std::string &key)
Get node of properties.
def test_activate_deactivate(message, arg0, arg1, arg2)
Only activation and deactivation are repeated.
virtual bool full(void) const
Check on whether the buffer is full.
void unsubscribeInterface(const SDOPackage::NVList &properties)
coil::vstring refToVstring(const CorbaRefSequence &objlist)
virtual void operator()(const RTC::ConnectorInfo &info, const RTC::TimedLong &data)
Virtual Callback method.
BufferBase abstract class.
virtual size_t readable() const
Write data into the buffer.
virtual ReturnCode advanceRptr(long int n=1)
Forward n reading pointers.
RTC's Port administration class.
RTC::InPortConsumer::ReturnCode put(const cdrMemoryStream &data)
virtual ReturnCode reset()
Reset the buffer status.