[openrtm-commit:01264] r2459 - in branches/work_ForDoil/OpenRTM-aist/src/lib/doil/utils/omniidl_be/tests: . ExecutionContextServiceProxy
openrtm @ openrtm.org
openrtm @ openrtm.org
2014年 2月 12日 (水) 17:52:37 JST
Author: win-ei
Date: 2014-02-12 17:52:37 +0900 (Wed, 12 Feb 2014)
New Revision: 2459
Added:
branches/work_ForDoil/OpenRTM-aist/src/lib/doil/utils/omniidl_be/tests/ExecutionContextServiceProxy/
branches/work_ForDoil/OpenRTM-aist/src/lib/doil/utils/omniidl_be/tests/ExecutionContextServiceProxy/ExecutionContextServiceProxyTests.cpp
branches/work_ForDoil/OpenRTM-aist/src/lib/doil/utils/omniidl_be/tests/ExecutionContextServiceProxy/Makefile.am
Log:
Added the test code of Proxy.
Added: branches/work_ForDoil/OpenRTM-aist/src/lib/doil/utils/omniidl_be/tests/ExecutionContextServiceProxy/ExecutionContextServiceProxyTests.cpp
===================================================================
--- branches/work_ForDoil/OpenRTM-aist/src/lib/doil/utils/omniidl_be/tests/ExecutionContextServiceProxy/ExecutionContextServiceProxyTests.cpp (rev 0)
+++ branches/work_ForDoil/OpenRTM-aist/src/lib/doil/utils/omniidl_be/tests/ExecutionContextServiceProxy/ExecutionContextServiceProxyTests.cpp 2014-02-12 08:52:37 UTC (rev 2459)
@@ -0,0 +1,341 @@
+// -*- C++ -*-
+/*!
+ * @file ExecutionContextServiceProxyTests.cpp
+ * @brief ExecutionContextServiceProxy test class
+ * @date $Date$
+ * @author Noriaki Ando <n-ando at aist.go.jp>
+ *
+ * $Id$
+ *
+ */
+
+/*
+ * $Log$
+ *
+ */
+
+#ifndef ExecutionContextServiceProxy_cpp
+#define ExecutionContextServiceProxy_cpp
+
+#include <cppunit/ui/text/TestRunner.h>
+#include <cppunit/TextOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/TestAssert.h>
+#include <string>
+#include <iostream>
+#include <idl/SDOPackageSkel.h>
+#include <idl/RTCSkel.h>
+#include <ExecutionContextServiceProxy.h>
+#include <rtm/NVUtil.h>
+#include <ISDOService.h>
+#include <ISDOSystemElement.h>
+#include <IOrganization.h>
+#include <doil/corba/CORBAManager.h>
+
+
+/*!
+ * @class ExecutionContextServiceProxyTests class
+ * @brief ExecutionContextServiceProxy test
+ */
+namespace ExecutionContextServiceProxy
+{
+ class Logger
+ {
+ public:
+ void log(const std::string& msg)
+ {
+ m_log.push_back(msg);
+ }
+
+ int countLog(const std::string& msg)
+ {
+ int count = 0;
+ for (int i = 0; i < (int) m_log.size(); ++i)
+ {
+ if (m_log[i] == msg) ++count;
+ }
+ return count;
+ }
+
+ private:
+ std::vector<std::string> m_log;
+ };
+
+ /*!
+ *
+ *
+ *
+ */
+ class ExecutionContextServiceMock
+ : public virtual ::POA_RTC::ExecutionContextService
+ {
+ protected:
+ ::std::vector<std::string> m_log;
+ private:
+ ::std::string m_name;
+ ::std::string m_code;
+ ::std::string m_val;
+ ::SDOPackage::Parameter m_par;
+ ::SDOPackage::StringList m_stlist;
+ ::SDOPackage::EnumerationType m_etype;
+ ::CORBA::Any m_any;
+ public :
+ ExecutionContextServiceMock(){}
+ virtual ~ExecutionContextServiceMock()
+ {
+ }
+
+ void setLogger(Logger* logger)
+ {
+ m_logger = logger;
+ }
+
+ /*!
+ *
+ */
+ ::RTC::ExecutionContextProfile* get_profile()
+ throw (CORBA::SystemException,
+ ::SDOPackage::InvalidParameter,
+ ::SDOPackage::NotAvailable,
+ ::SDOPackage::InternalError)
+ {
+ if (m_logger != NULL) m_logger->log("get_profile");
+ return NULL;
+ }
+ /*!
+ *
+ */
+ ::CORBA::Boolean is_running()
+ {
+ return false;
+ }
+
+
+ /*!
+ *
+ */
+ ::RTC::ReturnCode_t start()
+ {
+ return RTC::RTC_OK;
+ }
+
+
+ /*!
+ *
+ */
+ ::RTC::ReturnCode_t stop()
+ {
+ return RTC::RTC_OK;
+ }
+
+
+ /*!
+ *
+ */
+ ::CORBA::Double get_rate()
+ {
+ if (m_logger != NULL)
+ {
+ m_logger->log("get_rate");
+ }
+ return (CORBA::Double)3.14159;
+ }
+
+
+ /*!
+ *
+ */
+ ::RTC::ReturnCode_t set_rate(::CORBA::Double rate)
+ {
+ if (m_logger != NULL)
+ {
+ m_logger->log("set_rate");
+ ::std::ostringstream os;
+ os<<rate;
+ m_logger->log(os.str());
+ }
+
+ return RTC::BAD_PARAMETER;
+ }
+
+
+ /*!
+ *
+ */
+ ::RTC::ReturnCode_t activate_component(::RTC::LightweightRTObject_ptr comp)
+ {
+ return RTC::RTC_OK;
+ }
+
+
+ /*!
+ *
+ */
+ ::RTC::ReturnCode_t deactivate_component(::RTC::LightweightRTObject_ptr comp)
+ {
+ return RTC::RTC_OK;
+ }
+
+
+ /*!
+ *
+ */
+ ::RTC::ReturnCode_t reset_component(::RTC::LightweightRTObject_ptr comp)
+ {
+ return RTC::RTC_OK;
+ }
+
+
+ /*!
+ *
+ */
+ ::RTC::LifeCycleState get_component_state(::RTC::LightweightRTObject_ptr comp)
+ {
+ return RTC::INACTIVE_STATE;
+ }
+
+
+ /*!
+ *
+ */
+ ::RTC::ExecutionKind get_kind()
+ {
+// return m_profile.kind;
+ }
+ /*!
+ *
+ */
+ ::RTC::ReturnCode_t add_component(::RTC::LightweightRTObject_ptr comp)
+ {
+ if (m_logger != NULL)
+ {
+ m_logger->log("add_component");
+// ::std::ostringstream os;
+// os<<rate;
+// m_logger->log(os.str());
+ }
+ return RTC::BAD_PARAMETER;
+ }
+
+
+ /*!
+ *
+ */
+ ::RTC::ReturnCode_t remove_component(::RTC::LightweightRTObject_ptr comp)
+ {
+ CORBA::ULong index;
+// index = CORBA_SeqUtil::find(m_profile.participants,
+// find_objref<RTObject_ptr>(RTC::RTObject::_narrow(comp)));
+
+ if (index < 0) return RTC::BAD_PARAMETER;
+// CORBA_SeqUtil::erase(m_profile.participants, index);
+ return RTC::RTC_OK;
+ }
+ private:
+ Logger* m_logger;
+
+ };
+
+ class ExecutionContextServiceProxyTests
+ : public CppUnit::TestFixture
+ {
+ CPPUNIT_TEST_SUITE(ExecutionContextServiceProxyTests);
+ CPPUNIT_TEST(test_get_profile);
+ CPPUNIT_TEST_SUITE_END();
+
+ private:
+ CORBA::ORB_ptr m_pORB;
+ PortableServer::POA_ptr m_pPOA;
+
+ public:
+
+ /*!
+ * @brief Constructor
+ */
+ ExecutionContextServiceProxyTests()
+ {
+ int argc = 0;
+ char** argv = NULL;
+ m_pORB = CORBA::ORB_init(argc, argv);
+ m_pPOA = PortableServer::POA::_narrow(
+ m_pORB->resolve_initial_references("RootPOA"));
+ m_pPOA->the_POAManager()->activate();
+ }
+
+ /*!
+ * @brief Destructor
+ */
+ ~ExecutionContextServiceProxyTests()
+ {
+ }
+
+ /*!
+ * @brief Test initialization
+ */
+ virtual void setUp()
+ {
+ }
+
+ /*!
+ * @brief Test finalization
+ */
+ virtual void tearDown()
+ {
+ }
+
+ /*!
+ *
+ *
+ *
+ */
+ void test_get_profile()
+ {
+ ExecutionContextServiceMock* obj = new ExecutionContextServiceMock();
+ ::CORBA::Object_ptr ref = obj->_this();
+ if(::CORBA::is_nil(ref))
+ {
+ std::cout<<"ref is nil.Abort test."<<std::endl;
+ return;
+ }
+ ::RTC::CORBA::ExecutionContextServiceProxy* ap
+ = new ::RTC::CORBA::ExecutionContextServiceProxy(ref);
+
+ Logger logger;
+ obj->setLogger(&logger);
+
+ CPPUNIT_ASSERT_EQUAL(0, logger.countLog("get_profile"));
+ const ::SDOPackage::Local::DeviceProfile porf;
+ ap->get_profile();
+ CPPUNIT_ASSERT_EQUAL(1, logger.countLog("get_profile"));
+
+
+
+ delete ap;
+ CORBA::release(ref);
+ }
+ /* test case */
+ void test_case0()
+ {
+ }
+ };
+}; // namespace ExecutionContextServiceProxy
+
+/*
+ * Register test suite
+ */
+CPPUNIT_TEST_SUITE_REGISTRATION(ExecutionContextServiceProxy::ExecutionContextServiceProxyTests);
+
+#ifdef LOCAL_MAIN
+int main(int argc, char* argv[])
+{
+ CppUnit::TextUi::TestRunner runner;
+ runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
+ CppUnit::Outputter* outputter =
+ new CppUnit::TextOutputter(&runner.result(), std::cout);
+ runner.setOutputter(outputter);
+ bool retcode = runner.run();
+ return !retcode;
+}
+#endif // MAIN
+#endif // ExecutionContextServiceProxy_cpp
Added: branches/work_ForDoil/OpenRTM-aist/src/lib/doil/utils/omniidl_be/tests/ExecutionContextServiceProxy/Makefile.am
===================================================================
--- branches/work_ForDoil/OpenRTM-aist/src/lib/doil/utils/omniidl_be/tests/ExecutionContextServiceProxy/Makefile.am (rev 0)
+++ branches/work_ForDoil/OpenRTM-aist/src/lib/doil/utils/omniidl_be/tests/ExecutionContextServiceProxy/Makefile.am 2014-02-12 08:52:37 UTC (rev 2459)
@@ -0,0 +1,144 @@
+# -*- Makefile -*-
+#------------------------------------------------------------
+# @file Makefile.am
+# @brief Makefile.am for ExecutionContextServiceProxy unit test
+# @date $Date$
+# @author Noriaki Ando <n-ando at aist.go.jp>
+#
+# $Id$
+#
+#------------------------------------------------------------
+
+#
+# $Log$
+#
+
+
+AUTOMAKE_OPTIONS = 1.9
+
+IDLC = @IDLC@
+IDLFLAGS = @IDL_FLAGS@
+LIBS = @LIBS@
+
+
+AM_CPPFLAGS= -I. \
+ -I$(includedir) \
+ -I$(top_builddir) \
+ -I. \
+ -I../ \
+ -I$(top_builddir)/../../../../ \
+ -I../../../../ \
+ -I../../../../../ \
+ -I../../../../../rtm \
+ -I../../../../../coil/include \
+ -I../../../../../rtc/corba/idl \
+ -I../../../../../rtc/corba \
+ -I/usr/include/ \
+ -I/usr/include/omniORB4/
+
+AM_LDFLAGS= -L. \
+ -L$(top_builddir) \
+ -L$(top_builddir)/../../../../coil/lib
+
+
+IDL_SOURCES = \
+ ../../../../../rtc/corba/idl/SDOPackage.idl \
+ ../../../../../rtc/corba/idl/RTC.idl \
+ ../../../../../rtc/corba/idl/OpenRTM.idl
+# $(top_builddir)/../../../../rtc/corba/idl/SDOPackage.idl \
+# $(top_builddir)/../../../../rtc/corba/idl/RTC.idl \
+# $(top_builddir)/../../../../rtc/corba/idl/OpenRTM.idl
+
+noinst_PROGRAMS = ExecutionContextServiceProxyTests
+
+ExecutionContextServiceProxyTests_SOURCES = \
+ ../TestRunner.cpp \
+ $(IDL_SOURCES:.idl=Skel.cpp) \
+ ../../../../../doil/corba/CORBAManager.cpp \
+ ../../../../../doil/ORBManager.cpp \
+ ../../../../../rtm/NVUtil.cpp \
+ ../RTCTypeConversion.cpp \
+ ../SDOPackageTypeConversion.cpp \
+ ../ExecutionContextProxy.cpp \
+ ../SDOServiceProxy.cpp \
+ ../ExecutionContextServiceProxy.cpp \
+ ExecutionContextServiceProxyTests.cpp
+
+# $(top_builddir)/../../../../doil/corba/CORBAManager.cpp \
+# $(top_builddir)/../../../../doil/ORBManager.cpp \
+# $(top_builddir)/../../../../rtm/NVUtil.cpp \
+# $(top_builddir)/RTCTypeConversion.cpp \
+# $(top_builddir)/SDOPackageTypeConversion.cpp \
+# $(top_builddir)/ExecutionContextServiceProxy.cpp \
+#
+
+ExecutionContextServiceProxyTests_LDFLAGS = -L$(libdir)
+ExecutionContextServiceProxyTests_LDADD = \
+ -lcppunit \
+ -lomniORB4 \
+ -lomnithread \
+ -lomniDynamic4 \
+ -lcoil
+
+TEST_SRC = $(ExecutionContextServiceProxyTests_SOURCES)
+TEST_H =
+
+# all
+all: do-test
+
+# do tests
+do-test:
+ ./ExecutionContextServiceProxyTests
+
+# clean-up
+clean-local:
+ rm -f *.o *.Po *.gch *.la
+ rm -f *~ *core
+ rm -f *.xml
+ rm -f Makefile.old
+ rm -f *.vcproj
+ rm -rf Release Debug
+
+#------------------------------------------------------------
+# vcproj file build rules
+#------------------------------------------------------------
+win32_builddir = .
+
+vcproj: ExecutionContextServiceProxy_vc8.vcproj ExecutionContextServiceProxy_vc9.vcproj ExecutionContextServiceProxy_vc10.vcproj
+
+ExecutionContextServiceProxy_vc8.vcproj:
+ $(top_builddir)/build/vcprojtool.py vcproj \
+ --projectname ExecutionContextServiceProxyTest \
+ --type EXE \
+ --vcversion "8.00" \
+ --version $(COIL_VERSION) \
+ --out $(win32_builddir)/ExecutionContextServiceProxy_vc8.vcproj \
+ --yaml ../coil_test.vcproj.yaml \
+ --source $(TEST_SRC)
+# --header $(TEST_H)
+ qkc -sm $(win32_builddir)/ExecutionContextServiceProxy_vc8.vcproj
+
+ExecutionContextServiceProxy_vc9.vcproj:
+ $(top_builddir)/build/vcprojtool.py vcproj \
+ --projectname ExecutionContextServiceProxyTest \
+ --type EXE \
+ --vcversion "9.00" \
+ --version $(COIL_VERSION) \
+ --out $(win32_builddir)/ExecutionContextServiceProxy_vc9.vcproj \
+ --yaml ../coil_test.vcproj.yaml \
+ --source $(TEST_SRC)
+# --header $(TEST_H)
+ qkc -sm $(win32_builddir)/ExecutionContextServiceProxy_vc9.vcproj
+
+ExecutionContextServiceProxy_vc10.vcproj:
+ $(top_builddir)/build/vcprojtool.py vcproj \
+ --projectname ExecutionContextServiceProxyTest \
+ --type EXE \
+ --vcversion "10.00" \
+ --version $(COIL_VERSION) \
+ --out $(win32_builddir)/ExecutionContextServiceProxy_vc10.vcproj \
+ --yaml ../coil_test.vcproj.yaml \
+ --source $(TEST_SRC)
+ qkc -sm $(win32_builddir)/ExecutionContextServiceProxy_vc10.vcproj
+
+
More information about the openrtm-commit
mailing list