22 #include <cppunit/ui/text/TestRunner.h> 23 #include <cppunit/TextOutputter.h> 24 #include <cppunit/extensions/TestFactoryRegistry.h> 25 #include <cppunit/extensions/HelperMacros.h> 26 #include <cppunit/TestAssert.h> 28 #include <idl/SDOPackageSkel.h> 29 #include <idl/RTCSkel.h> 30 #include <idl/OpenRTMSkel.h> 39 class DataFlowComponentMock
40 :
public virtual POA_OpenRTM::DataFlowComponent,
41 public virtual PortableServer::RefCountServantBase
55 virtual SDOPackage::_objref_SDOService*
get_sdo_service(
const char*) {
return NULL; }
60 virtual CORBA::Any*
get_status(
const char*) {
return NULL; }
97 virtual CORBA::Boolean
is_alive(RTC::_objref_ExecutionContext*) {
return true; }
106 :
public virtual POA_RTC::FsmObject
117 :
public virtual POA_RTC::MultiModeObject
181 virtual CORBA::Boolean
is_alive(RTC::_objref_ExecutionContext*)
217 :
public CppUnit::TestFixture
221 CPPUNIT_TEST(test_isDataFlowComponent_DataFlowComponent);
222 CPPUNIT_TEST(test_isDataFlowComponent_FsmObject);
223 CPPUNIT_TEST(test_isDataFlowComponent_MultiModeObject);
225 CPPUNIT_TEST(test_isFsmParticipant_DataFlowComponent);
226 CPPUNIT_TEST(test_isFsmParticipant_FsmObject);
227 CPPUNIT_TEST(test_isFsmParticipant_MultiModeObject);
229 CPPUNIT_TEST(test_isFsmObject_DataFlowComponent);
230 CPPUNIT_TEST(test_isFsmObject_FsmObject);
231 CPPUNIT_TEST(test_isFsmObject_MultiModeObject);
233 CPPUNIT_TEST(test_isMultiModeObject_DataFlowComponent);
234 CPPUNIT_TEST(test_isMultiModeObject_FsmObject);
235 CPPUNIT_TEST(test_isMultiModeObject_MultiModeObject);
237 CPPUNIT_TEST_SUITE_END();
251 m_pORB = CORBA::ORB_init(argc, argv);
252 m_pPOA = PortableServer::POA::_narrow(
253 m_pORB->resolve_initial_references(
"RootPOA"));
254 m_pPOA->the_POAManager()->activate();
281 CORBA::Object_ptr ref = obj->_this();
282 CPPUNIT_ASSERT(! CORBA::is_nil(ref));
285 m_pPOA->deactivate_object(*m_pPOA->servant_to_id(obj));
292 CORBA::Object_ptr ref = obj->_this();
293 CPPUNIT_ASSERT(! CORBA::is_nil(ref));
296 m_pPOA->deactivate_object(*m_pPOA->servant_to_id(obj));
304 CORBA::Object_ptr ref = obj->_this();
305 CPPUNIT_ASSERT(! CORBA::is_nil(ref));
308 m_pPOA->deactivate_object(*m_pPOA->servant_to_id(obj));
315 CORBA::Object_ptr ref = obj->_this();
316 CPPUNIT_ASSERT(! CORBA::is_nil(ref));
319 m_pPOA->deactivate_object(*m_pPOA->servant_to_id(obj));
326 CORBA::Object_ptr ref = obj->_this();
327 CPPUNIT_ASSERT(! CORBA::is_nil(ref));
330 m_pPOA->deactivate_object(*m_pPOA->servant_to_id(obj));
338 CORBA::Object_ptr ref = obj->_this();
339 CPPUNIT_ASSERT(! CORBA::is_nil(ref));
342 m_pPOA->deactivate_object(*m_pPOA->servant_to_id(obj));
349 CORBA::Object_ptr ref = obj->_this();
350 CPPUNIT_ASSERT(! CORBA::is_nil(ref));
353 m_pPOA->deactivate_object(*m_pPOA->servant_to_id(obj));
360 CORBA::Object_ptr ref = obj->_this();
361 CPPUNIT_ASSERT(! CORBA::is_nil(ref));
364 m_pPOA->deactivate_object(*m_pPOA->servant_to_id(obj));
372 CORBA::Object_ptr ref = obj->_this();
373 CPPUNIT_ASSERT(! CORBA::is_nil(ref));
376 m_pPOA->deactivate_object(*m_pPOA->servant_to_id(obj));
383 CORBA::Object_ptr ref = obj->_this();
384 CPPUNIT_ASSERT(! CORBA::is_nil(ref));
387 m_pPOA->deactivate_object(*m_pPOA->servant_to_id(obj));
394 CORBA::Object_ptr ref = obj->_this();
395 CPPUNIT_ASSERT(! CORBA::is_nil(ref));
398 m_pPOA->deactivate_object(*m_pPOA->servant_to_id(obj));
406 CORBA::Object_ptr ref = obj->_this();
407 CPPUNIT_ASSERT(! CORBA::is_nil(ref));
410 m_pPOA->deactivate_object(*m_pPOA->servant_to_id(obj));
423 int main(
int argc,
char* argv[])
436 std::string arg(argv[i]);
437 std::string next_arg;
438 if (i + 1 < argc) next_arg = argv[i + 1];
441 if (arg ==
"--text") { format =
TEXT_OUT;
break; }
454 ofs.open(fname.c_str());
456 if ( arg ==
"--compiler" ) { format =
COMPILER_OUT;
break; }
457 if ( arg ==
"--cerr" ) { target = 1;
break; }
458 if ( arg ==
"--xsl" )
460 if (next_arg ==
"") xsl =
"default.xsl";
463 if ( arg ==
"--namespace" )
467 std::cerr <<
"no namespace specified" << std::endl;
477 CppUnit::TextUi::TestRunner runner;
479 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
481 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest());
482 CppUnit::Outputter* outputter = 0;
483 std::ostream* stream = target ? &std::cerr : &std::cout;
487 outputter =
new CppUnit::TextOutputter(&runner.result(),*stream);
490 std::cout <<
"XML_OUT" << std::endl;
491 outputter =
new CppUnit::XmlOutputter(&runner.result(),
493 static_cast<CppUnit::XmlOutputter*
>(outputter)->setStyleSheet(xsl);
496 outputter =
new CppUnit::CompilerOutputter(&runner.result(),*stream);
499 runner.setOutputter(outputter);
505 #endif // RTCUtil_cpp virtual RTC::ExecutionContextHandle_t get_context_handle(RTC::_objref_ExecutionContext *)
bool isDataFlowComponent(CORBA::Object_ptr obj)
Confirm whether specified RT-Component is DataFlowComponent.
int main(int argc, char **argv)
virtual RTC::ReturnCode_t finalize()
[CORBA interface] Finalize the RTC for destruction
bool isMultiModeObject(CORBA::Object_ptr obj)
Confirm whether specified RT-Component is multiModeComponent.
EXECUTION_HANDLE_TYPE_NATIVE ExecutionContextHandle_t
virtual RTC::ExecutionContextHandle_t get_context_handle(RTC::_objref_ExecutionContext *)
virtual RTC::ReturnCode_t on_deactivated(RTC::ExecutionContextHandle_t)
virtual SDOPackage::_objref_SDOService * get_sdo_service(const char *)
[SDO interface] Get specified SDO Service's reference
void test_isMultiModeObject_MultiModeObject()
virtual char * get_sdo_id()
[SDO interface] Get the SDO ID
virtual RTC::ExecutionContextHandle_t attach_context(RTC::_objref_ExecutionContext *)
virtual RTC::ReturnCode_t send_stimulus(const char *, RTC::ExecutionContextHandle_t)
virtual SDOPackage::ServiceProfile * get_service_profile(const char *)
[SDO interface] Get specified ServiceProfile
virtual RTC::_objref_Mode * get_current_mode_in_context(RTC::_objref_ExecutionContext *)
PortableServer::POA_ptr m_pPOA
std::vector< std::pair< std::string, std::string > > NVList
void test_isFsmObject_DataFlowComponent()
void test_isFsmObject_MultiModeObject()
bool isFsmParticipant(CORBA::Object_ptr obj)
Confirm whether specified RT-Component is FsmParticipant.
virtual RTC::ReturnCode_t on_shutdown(RTC::ExecutionContextHandle_t)
virtual SDOPackage::OrganizationList * get_organizations()
[SDO interface] Get Organization list
virtual RTC::ReturnCode_t on_initialize()
virtual RTC::ReturnCode_t on_startup(RTC::ExecutionContextHandle_t)
void test_isFsmParticipant_MultiModeObject()
virtual RTC::ReturnCode_t on_finalize()
virtual RTC::ReturnCode_t on_startup(RTC::ExecutionContextHandle_t)
virtual RTC::ReturnCode_t send_stimulus(const char *, RTC::ExecutionContextHandle_t)
virtual RTC::ReturnCode_t finalize()
virtual SDOPackage::NVList * get_status_list()
[SDO interface] Get SDO Status list
virtual RTC::_objref_ExecutionContext * get_context(RTC::ExecutionContextHandle_t)
virtual RTC::ReturnCode_t on_finalize()
[ComponentAction CORBA interface] Finalize RTC
virtual ~DataFlowComponentMock()
void test_isDataFlowComponent_MultiModeObject()
void test_isDataFlowComponent_DataFlowComponent()
virtual CORBA::Boolean is_alive(RTC::_objref_ExecutionContext *)
void test_isMultiModeObject_FsmObject()
CPPUNIT_TEST_SUITE_REGISTRATION(Tests::RTCUtilTests)
virtual CORBA::Any * get_status(const char *)
[SDO interface] Get SDO Status
virtual RTC::ExecutionContextList * get_participating_contexts()
[CORBA interface] Get participating ExecutionContextList.
virtual RTC::ReturnCode_t on_error(RTC::ExecutionContextHandle_t)
virtual RTC::ReturnCode_t detach_context(RTC::ExecutionContextHandle_t)
virtual RTC::ReturnCode_t on_mode_changed(RTC::ExecutionContextHandle_t)
virtual SDOPackage::DeviceProfile * get_device_profile()
[SDO interface] Get SDO DeviceProfile list
virtual RTC::ReturnCode_t exit()
std::vector< ExecutionContext * > ExecutionContextList
virtual RTC::ReturnCode_t on_activated(RTC::ExecutionContextHandle_t)
virtual RTC::ReturnCode_t on_error(RTC::ExecutionContextHandle_t)
virtual RTC::ExecutionContextHandle_t attach_context(RTC::_objref_ExecutionContext *)
virtual RTC::ExecutionContextList * get_owned_contexts()
[CORBA interface] Get ExecutionContextList.
virtual RTC::PortServiceList * get_ports()
[RTObject CORBA interface] Get Ports
virtual SDOPackage::OrganizationList * get_owned_organizations()
[SDO interface] Get Organization list
virtual RTC::_objref_Mode * get_current_mode()
virtual SDOPackage::_objref_Configuration * get_configuration()
[SDO interface] Get Configuration object
virtual RTC::_objref_Mode * get_pending_mode()
virtual RTC::_objref_ExecutionContext * get_context(RTC::ExecutionContextHandle_t)
virtual ~RTCUtilTests()
Destructor.
virtual RTC::_objref_Mode * get_pending_mode_in_context(RTC::_objref_ExecutionContext *)
virtual RTC::ReturnCode_t on_deactivated(RTC::ExecutionContextHandle_t)
virtual RTC::ReturnCode_t on_aborting(RTC::ExecutionContextHandle_t)
virtual RTC::ReturnCode_t initialize()
[CORBA interface] Initialize the RTC that realizes this interface.
virtual RTC::ReturnCode_t on_aborting(RTC::ExecutionContextHandle_t)
virtual RTC::ReturnCode_t stimulate(const char *, RTC::ExecutionContextHandle_t)
void test_isFsmParticipant_DataFlowComponent()
virtual RTC::ReturnCode_t exit()
[CORBA interface]top the RTC's execution context(s) and finalize it along with its contents...
virtual RTC::ReturnCode_t send_stimulus(const char *, RTC::ExecutionContextHandle_t)
virtual RTC::ReturnCode_t on_activated(RTC::ExecutionContextHandle_t)
virtual RTC::ReturnCode_t detach_context(RTC::ExecutionContextHandle_t)
virtual RTC::ReturnCode_t on_reset(RTC::ExecutionContextHandle_t)
virtual RTC::ReturnCode_t on_initialize()
[RTObject CORBA interface] Get ExecutionContextAdmin
virtual RTC::ReturnCode_t on_state_update(RTC::ExecutionContextHandle_t)
virtual RTC::ReturnCode_t set_mode(RTC::_objref_Mode *, CORBA::Boolean)
virtual RTC::ExecutionContextList * get_participating_contexts()
std::vector< IPortService * > PortServiceList
void test_isFsmObject_FsmObject()
void test_isMultiModeObject_DataFlowComponent()
virtual RTC::ExecutionContextList * get_owned_contexts()
bool isFsmObject(CORBA::Object_ptr obj)
Confirm whether specified RT-Component is Fsm.
RTCUtilTests()
Constructor.
virtual RTC::ReturnCode_t on_execute(RTC::ExecutionContextHandle_t)
virtual RTC::ComponentProfile * get_component_profile()
[RTObject CORBA interface] Get RTC's profile
virtual void setUp()
Test initialization.
virtual RTC::ReturnCode_t on_rate_changed(RTC::ExecutionContextHandle_t)
void test_isFsmParticipant_FsmObject()
virtual RTC::_objref_Mode * get_default_mode()
virtual char * get_sdo_type()
[SDO interface] Get SDO type
virtual SDOPackage::ServiceProfileList * get_service_profiles()
[SDO interface] Get SDO ServiceProfile
virtual CORBA::Boolean is_alive(RTC::_objref_ExecutionContext *)
void test_isDataFlowComponent_FsmObject()
virtual RTC::ReturnCode_t on_shutdown(RTC::ExecutionContextHandle_t)
virtual SDOPackage::_objref_Monitoring * get_monitoring()
[SDO interface] Get Monitoring object
virtual void tearDown()
Test finalization.
virtual RTC::ReturnCode_t initialize()
virtual RTC::ReturnCode_t on_reset(RTC::ExecutionContextHandle_t)