30 #ifndef PublisherNew_cpp 31 #define PublisherNew_cpp 33 #include <cppunit/ui/text/TestRunner.h> 34 #include <cppunit/TextOutputter.h> 35 #include <cppunit/extensions/TestFactoryRegistry.h> 36 #include <cppunit/extensions/HelperMacros.h> 37 #include <cppunit/TestAssert.h> 39 #include <coil/Properties.h> 42 #include <coil/Time.h> 48 #include <rtm/idl/BasicDataTypeSkel.h> 72 const RTC::TimedLong&
data)
74 std::cout <<
"------------------------------" << std::endl;
75 std::cout <<
"Listener: " <<
m_name << std::endl;
76 std::cout <<
" Data: " << data.data << std::endl;
77 std::cout <<
"------------------------------" << std::endl;
132 if (m_buffer->full())
163 else if(m_OnCheck == 1) {
166 else if(m_OnCheck == 2) {
169 else if(m_OnCheck == 3) {
172 else if(m_OnCheck == 4) {
175 else if(m_OnCheck == 5) {
178 else if(m_OnCheck == 6) {
182 else if(m_test_mode == 1)
184 std::string str(
"test");
209 ic = (int)m_buffer->readable();
229 :
public CppUnit::TestFixture
234 CPPUNIT_TEST(test_setConsumer);
235 CPPUNIT_TEST(test_setBuffer);
236 CPPUNIT_TEST(test_activate_deactivate_isActive);
237 CPPUNIT_TEST(test_pushAll);
238 CPPUNIT_TEST(test_pushAll_2);
239 CPPUNIT_TEST(test_pushFifo);
240 CPPUNIT_TEST(test_pushFifo_2);
241 CPPUNIT_TEST(test_pushSkip);
242 CPPUNIT_TEST(test_pushSkip_2);
243 CPPUNIT_TEST(test_pushNew);
244 CPPUNIT_TEST(test_write);
246 CPPUNIT_TEST_SUITE_END();
293 retcode = publisher.
init(prop);
299 prop.
setProperty(
"measurement.exec_time",
"default");
303 retcode = publisher.
init(prop);
311 prop.
setProperty(
"measurement.exec_time",
"enable");
313 prop.
setProperty(
"measurement.period_time",
"enable");
315 retcode = publisher.
init(prop);
322 prop.
setProperty(
"measurement.exec_time",
"disable");
324 prop.
setProperty(
"measurement.period_time",
"disable");
326 retcode = publisher.
init(prop);
337 retcode = publisher.
init(prop);
344 prop.
setProperty(
"measurement.exec_time",
"enable");
346 prop.
setProperty(
"measurement.period_time",
"enable");
347 prop.
setProperty(
"measurement.period_count",
"foo");
348 retcode = publisher.
init(prop);
355 prop.
setProperty(
"measurement.exec_time",
"enable");
357 prop.
setProperty(
"measurement.period_time",
"enable");
359 retcode = publisher.
init(prop);
427 CPPUNIT_ASSERT_EQUAL(
false,
433 CPPUNIT_ASSERT_EQUAL(
true,
442 CPPUNIT_ASSERT_EQUAL(
true,
448 CPPUNIT_ASSERT_EQUAL(
false,
457 CPPUNIT_ASSERT_EQUAL(
false,
479 prop.
setProperty(
"measurement.exec_time",
"enable");
481 prop.
setProperty(
"measurement.period_time",
"enable");
483 publisher.
init(prop);
522 for(
int icc(0);icc<8;++icc)
530 publisher.
write(cdr,0,0));
541 publisher.
write(cdr,0,0));
553 CPPUNIT_ASSERT(bret);
559 for(
int icc(0);icc<4;++icc)
561 cdrMemoryStream
data;
563 CORBA::ULong inlen = data.bufSize();
564 CPPUNIT_ASSERT_EQUAL(12,(
int)inlen);
568 CPPUNIT_ASSERT_EQUAL((
long)icc, (
long)rtd.data);
578 publisher.
write(cdr,0,0));
587 publisher.
write(cdr,0,0));
592 for(
int icc(0);icc<8;++icc)
594 cdrMemoryStream
data;
596 CORBA::ULong inlen = data.bufSize();
597 CPPUNIT_ASSERT_EQUAL(12,(
int)inlen);
601 CPPUNIT_ASSERT_EQUAL((
long)icc+4, (
long)rtd.data);
626 prop.
setProperty(
"measurement.exec_time",
"enable");
628 prop.
setProperty(
"measurement.period_time",
"enable");
630 publisher.
init(prop);
669 for(
int icc(0);icc<16;++icc)
677 ret = publisher.
write(cdr,0,0);
700 publisher.
write(cdr,0,0));
705 for(
int icc(0);icc<8;++icc)
707 cdrMemoryStream
data;
709 CORBA::ULong inlen = data.bufSize();
710 CPPUNIT_ASSERT_EQUAL(12,(
int)inlen);
714 CPPUNIT_ASSERT_EQUAL((
long)icc, (
long)rtd.data);
725 publisher.
write(cdr,0,0));
729 for(
int icc(0);icc<8;++icc)
731 cdrMemoryStream
data;
733 CORBA::ULong inlen = data.bufSize();
734 CPPUNIT_ASSERT_EQUAL(12,(
int)inlen);
738 CPPUNIT_ASSERT_EQUAL((
long)icc+8, (
long)rtd.data);
746 publisher.
write(cdr,0,0));
751 cdrMemoryStream
data;
753 CORBA::ULong inlen = data.bufSize();
754 CPPUNIT_ASSERT_EQUAL(12,(
int)inlen);
758 CPPUNIT_ASSERT_EQUAL((
long)18, (
long)rtd.data);
784 prop.
setProperty(
"measurement.exec_time",
"enable");
786 prop.
setProperty(
"measurement.period_time",
"enable");
788 publisher.
init(prop);
827 for(
int icc(0);icc<8;++icc)
835 publisher.
write(cdr,0,0));
847 publisher.
write(cdr,0,0));
857 publisher.
write(cdr,0,0);
864 for(
int icc(0);icc<4;++icc)
866 cdrMemoryStream
data;
868 CORBA::ULong inlen = data.bufSize();
869 CPPUNIT_ASSERT_EQUAL(12,(
int)inlen);
873 CPPUNIT_ASSERT_EQUAL((
long)icc, (
long)rtd.data);
883 publisher.
write(cdr,0,0));
892 publisher.
write(cdr,0,0));
901 publisher.
write(cdr,0,0));
910 publisher.
write(cdr,0,0));
915 for(
int icc(0);icc<8;++icc)
917 cdrMemoryStream
data;
919 CORBA::ULong inlen = data.bufSize();
920 CPPUNIT_ASSERT_EQUAL(12,(
int)inlen);
924 CPPUNIT_ASSERT_EQUAL((
long)icc+4, (
long)rtd.data);
952 prop.
setProperty(
"measurement.exec_time",
"enable");
954 prop.
setProperty(
"measurement.period_time",
"enable");
956 publisher.
init(prop);
996 for(
int icc(0);icc<16;++icc)
1004 ret = publisher.
write(cdr,0,0);
1022 cdrMemoryStream cdr;
1027 publisher.
write(cdr,0,0));
1032 for(
int icc(0);icc<8;++icc)
1034 cdrMemoryStream
data;
1036 CORBA::ULong inlen = data.bufSize();
1037 CPPUNIT_ASSERT_EQUAL(12,(
int)inlen);
1041 CPPUNIT_ASSERT_EQUAL((
long)icc, (
long)rtd.data);
1047 cdrMemoryStream cdr;
1052 publisher.
write(cdr,0,0));
1056 for(
int icc(0);icc<7;++icc)
1058 cdrMemoryStream cdr;
1063 publisher.
write(cdr,0,0));
1067 for(
int icc(0);icc<8;++icc)
1069 cdrMemoryStream
data;
1071 CORBA::ULong inlen = data.bufSize();
1072 CPPUNIT_ASSERT_EQUAL(12,(
int)inlen);
1076 CPPUNIT_ASSERT_EQUAL((
long)icc+8, (
long)rtd.data);
1079 cdrMemoryStream cdr;
1084 publisher.
write(cdr,0,0));
1089 cdrMemoryStream
data;
1091 CORBA::ULong inlen = data.bufSize();
1092 CPPUNIT_ASSERT_EQUAL(12,(
int)inlen);
1096 CPPUNIT_ASSERT_EQUAL((
long)18, (
long)rtd.data);
1123 prop.
setProperty(
"measurement.exec_time",
"enable");
1125 prop.
setProperty(
"measurement.period_time",
"enable");
1127 publisher.
init(prop);
1166 for(
int icc(0);icc<16;++icc)
1168 cdrMemoryStream cdr;
1175 publisher.
write(cdr,0,0);
1181 cdrMemoryStream cdr;
1186 publisher.
write(cdr,0,0));
1190 cdrMemoryStream cdr;
1195 publisher.
write(cdr,0,0));
1201 for(
int icc(0);icc<4;++icc)
1203 cdrMemoryStream
data;
1205 CORBA::ULong inlen = data.bufSize();
1206 CPPUNIT_ASSERT_EQUAL(12,(
int)inlen);
1210 CPPUNIT_ASSERT_EQUAL((
long)icc*2+1, (
long)rtd.data);
1215 cdrMemoryStream cdr;
1220 publisher.
write(cdr,0,0));
1224 cdrMemoryStream cdr;
1229 publisher.
write(cdr,0,0));
1234 for(
int icc(0);icc<2;++icc)
1236 cdrMemoryStream
data;
1238 CORBA::ULong inlen = data.bufSize();
1239 CPPUNIT_ASSERT_EQUAL(12,(
int)inlen);
1243 CPPUNIT_ASSERT_EQUAL((
long)icc*2+9, (
long)rtd.data);
1268 prop.
setProperty(
"measurement.exec_time",
"enable");
1270 prop.
setProperty(
"measurement.period_time",
"enable");
1272 publisher.
init(prop);
1312 for(
int icc(0);icc<24;++icc)
1314 cdrMemoryStream cdr;
1320 ret = publisher.
write(cdr,0,0);
1338 cdrMemoryStream cdr;
1343 publisher.
write(cdr,0,0));
1348 for(
int icc(0);icc<8;++icc)
1350 cdrMemoryStream
data;
1352 CORBA::ULong inlen = data.bufSize();
1353 CPPUNIT_ASSERT_EQUAL(12,(
int)inlen);
1357 CPPUNIT_ASSERT_EQUAL((
long)icc*2+1, (
long)rtd.data);
1363 cdrMemoryStream cdr;
1368 publisher.
write(cdr,0,0));
1373 CPPUNIT_ASSERT_EQUAL(4,len);
1374 for(
int icc(0);icc<len;++icc)
1376 cdrMemoryStream
data;
1378 CORBA::ULong inlen = data.bufSize();
1379 CPPUNIT_ASSERT_EQUAL(12,(
int)inlen);
1383 CPPUNIT_ASSERT_EQUAL((
long)icc*2+17, (
long)rtd.data);
1386 cdrMemoryStream cdr;
1391 publisher.
write(cdr,0,0));
1395 cdrMemoryStream cdr;
1400 publisher.
write(cdr,0,0));
1405 cdrMemoryStream
data;
1407 CORBA::ULong inlen = data.bufSize();
1408 CPPUNIT_ASSERT_EQUAL(12,(
int)inlen);
1412 CPPUNIT_ASSERT_EQUAL((
long)27, (
long)rtd.data);
1438 prop.
setProperty(
"measurement.exec_time",
"enable");
1440 prop.
setProperty(
"measurement.period_time",
"enable");
1442 publisher.
init(prop);
1483 for(
int icc(0);icc<7;++icc)
1485 cdrMemoryStream cdr;
1491 publisher.
write(cdr,0,0));
1497 cdrMemoryStream cdr;
1503 publisher.
write(cdr,0,0));
1511 for(
int icc(0);icc<len;++icc)
1513 cdrMemoryStream
data;
1515 CORBA::ULong inlen = data.bufSize();
1516 CPPUNIT_ASSERT_EQUAL(12,(
int)inlen);
1520 cdrMemoryStream
data;
1522 CORBA::ULong inlen = data.bufSize();
1523 CPPUNIT_ASSERT_EQUAL(12,(
int)inlen);
1527 CPPUNIT_ASSERT_EQUAL((
long)7, (
long)rtd.data);
1552 prop.
setProperty(
"measurement.exec_time",
"enable");
1554 prop.
setProperty(
"measurement.period_time",
"enable");
1556 publisher.
init(prop);
1593 cdrMemoryStream cdr;
1598 publisher.
write(cdr,0,0));
1603 cdrMemoryStream cdr;
1608 publisher.
write(cdr,0,0));
1615 cdrMemoryStream cdr;
1620 publisher.
write(cdr,0,0));
1626 cdrMemoryStream cdr;
1631 publisher.
write(cdr,0,0));
1638 cdrMemoryStream cdr;
1643 publisher.
write(cdr,0,0));
1648 cdrMemoryStream cdr;
1656 publisher.
write(cdr,0,0);
1659 publisher.
write(cdr,0,0);
1662 publisher.
write(cdr,0,0);
1665 publisher.
write(cdr,0,0);
1668 publisher.
write(cdr,0,0);
1795 int main(
int argc,
char* argv[])
1808 std::string arg(argv[i]);
1809 std::string next_arg;
1810 if (i + 1 < argc) next_arg = argv[i + 1];
1813 if (arg ==
"--text") { format =
TEXT_OUT;
break; }
1826 ofs.open(fname.c_str());
1828 if ( arg ==
"--compiler" ) { format =
COMPILER_OUT;
break; }
1829 if ( arg ==
"--cerr" ) { target = 1;
break; }
1830 if ( arg ==
"--xsl" )
1832 if (next_arg ==
"") xsl =
"default.xsl";
1833 else xsl = next_arg;
1835 if ( arg ==
"--namespace" )
1839 std::cerr <<
"no namespace specified" << std::endl;
1849 CppUnit::TextUi::TestRunner runner;
1851 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
1853 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest());
1854 CppUnit::Outputter* outputter = 0;
1855 std::ostream* stream = target ? &std::cerr : &std::cout;
1859 outputter =
new CppUnit::TextOutputter(&runner.result(),*stream);
1862 std::cout <<
"XML_OUT" << std::endl;
1863 outputter =
new CppUnit::XmlOutputter(&runner.result(),
1865 static_cast<CppUnit::XmlOutputter*
>(outputter)->setStyleSheet(xsl);
1868 outputter =
new CppUnit::CompilerOutputter(&runner.result(),*stream);
1871 runner.setOutputter(outputter);
1876 #endif // PublisherNew_cpp ConnectorListeners class.
void test_setBuffer(void)
setBuffer()メソッドのテスト
virtual ReturnCode setListener(ConnectorInfo &info, ConnectorListeners *listeners)
Set the listener.
int main(int argc, char **argv)
InPortCorbaCdrConsumer class.
virtual ReturnCode write(const cdrMemoryStream &data, unsigned long sec, unsigned long usec)
Write data.
virtual void operator()(const RTC::ConnectorInfo &info, const RTC::TimedLong &data)
Virtual Callback method.
virtual ReturnCode deactivate()
deactivation
DataListener(const char *name)
void test_pushAll(void)
write(), pushAll() メソッドのテスト
cdrMemoryStream get_m_put_data(void)
void addListener(ConnectorDataListener *listener, bool autoclean)
Add the listener.
virtual ReturnCode setBuffer(CdrBufferBase *buffer)
Setting buffer pointer.
RTC::ReturnCode_t ret(RTC::Local::ReturnCode_t r)
virtual ReturnCode init(coil::Properties &prop)
Initialization.
virtual bool isActive()
If publisher is active state.
void test_pushSkip_2(void)
write(), pushSkip() メソッドのテスト
RingBuffer< cdrMemoryStream > CdrRingBuffer
void test_pushNew(void)
pushNew()メソッドのテスト
int get_m_put_data_len(void)
Enum
DataPortStatus return codes.
virtual ReturnCode activate()
activation
std::vector< std::string > vstring
CPPUNIT_TEST_SUITE_REGISTRATION(PublisherNew::PublisherNewTests)
ConnectorDataListenerHolder connectorData_[CONNECTOR_DATA_LISTENER_NUM]
ConnectorDataListenerType listener array The ConnectorDataListenerType listener is stored...
void test_activate_deactivate_isActive(void)
activate(),deactivate(),isActiveメソッドのテスト
virtual void setUp()
Test initialization.
virtual ReturnCode setConsumer(InPortConsumer *consumer)
Store InPort consumer.
ConnectorDataListenerT class.
RTC::CdrBufferBase * m_buffer
std::string setProperty(const std::string &key, const std::string &value)
Set a value associated with key in the property list.
NameValue and NVList utility functions.
CORBA sequence utility template functions.
void test_pushFifo_2(void)
write(), pushFifo() メソッドのテスト
void test_pushAll_2(void)
write(), pushAll() メソッドのテスト
InPortCorbaCdrConsumerMock(void)
::RTC::BufferStatus::Enum ReturnCode
prop
Organization::get_organization_property ();.
virtual ~PublisherNewMock(void)
::OpenRTM::CdrData m_put_data
RTC::ConnectorListeners m_listeners
Class represents a set of properties.
void test_write(void)
write()メソッドのテスト
void test_pushSkip(void)
pushSklip()メソッドのテスト
void test_pushFifo(void)
pushFifo()メソッドのテスト
virtual ReturnCode put(const cdrMemoryStream &data)
Send data to the destination port.
void test_init(void)
init()メソッドのテスト
InPortCorbaCdrConsumer class.
~PublisherNewTests()
Destructor.
virtual void tearDown()
Test finalization.
PublisherNewTests()
Constructor.
virtual ~InPortCorbaCdrConsumerMock()
void test_setConsumer(void)
setConsumer()メソッドのテスト
BufferBase abstract class.
void set_m_mode(int mode)
int usleep(useconds_t usec)
Stop a processing at specified micro second time.