[openrtm-commit:01277] r2472 - in branches/work_ForDoil/OpenRTM-aist/src/lib/doil/utils/omniidl_be/tests: . ModeProxy

openrtm @ openrtm.org openrtm @ openrtm.org
2014年 2月 13日 (木) 00:00:26 JST


Author: win-ei
Date: 2014-02-13 00:00:26 +0900 (Thu, 13 Feb 2014)
New Revision: 2472

Added:
   branches/work_ForDoil/OpenRTM-aist/src/lib/doil/utils/omniidl_be/tests/ModeProxy/
   branches/work_ForDoil/OpenRTM-aist/src/lib/doil/utils/omniidl_be/tests/ModeProxy/Makefile.am
   branches/work_ForDoil/OpenRTM-aist/src/lib/doil/utils/omniidl_be/tests/ModeProxy/ModeProxyTests.cpp
Log:
Added the test code of Proxy. 

Added: branches/work_ForDoil/OpenRTM-aist/src/lib/doil/utils/omniidl_be/tests/ModeProxy/Makefile.am
===================================================================
--- branches/work_ForDoil/OpenRTM-aist/src/lib/doil/utils/omniidl_be/tests/ModeProxy/Makefile.am	                        (rev 0)
+++ branches/work_ForDoil/OpenRTM-aist/src/lib/doil/utils/omniidl_be/tests/ModeProxy/Makefile.am	2014-02-12 15:00:26 UTC (rev 2472)
@@ -0,0 +1,142 @@
+# -*- Makefile -*-
+#------------------------------------------------------------
+# @file   Makefile.am
+# @brief  Makefile.am for ModeProxy 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 = ModeProxyTests
+
+ModeProxyTests_SOURCES = \
+        ../TestRunner.cpp                                       \
+	$(IDL_SOURCES:.idl=Skel.cpp)                            \
+        ../../../../../doil/corba/CORBAManager.cpp \
+        ../../../../../doil/ORBManager.cpp         \
+        ../../../../../rtm/NVUtil.cpp              \
+        ../RTCTypeConversion.cpp                   \
+        ../SDOPackageTypeConversion.cpp            \
+        ../ModeProxy.cpp \
+        ModeProxyTests.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)/ModeProxy.cpp \
+#
+
+ModeProxyTests_LDFLAGS = -L$(libdir)
+ModeProxyTests_LDADD   = \
+         -lcppunit                                 \
+         -lomniORB4                                \
+         -lomnithread                              \
+         -lomniDynamic4                            \
+         -lcoil 
+
+TEST_SRC = $(ModeProxyTests_SOURCES)
+TEST_H   = 
+
+# all
+all: do-test
+
+# do tests
+do-test:
+	./ModeProxyTests
+
+# 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: ModeProxy_vc8.vcproj ModeProxy_vc9.vcproj  ModeProxy_vc10.vcproj
+
+ModeProxy_vc8.vcproj:
+	$(top_builddir)/build/vcprojtool.py vcproj \
+		--projectname ModeProxyTest \
+		--type EXE \
+		--vcversion "8.00" \
+		--version $(COIL_VERSION) \
+		--out $(win32_builddir)/ModeProxy_vc8.vcproj \
+		--yaml ../coil_test.vcproj.yaml \
+		--source $(TEST_SRC)
+#		--header $(TEST_H)
+	qkc -sm $(win32_builddir)/ModeProxy_vc8.vcproj
+
+ModeProxy_vc9.vcproj:
+	$(top_builddir)/build/vcprojtool.py vcproj \
+		--projectname ModeProxyTest \
+		--type EXE \
+		--vcversion "9.00" \
+		--version $(COIL_VERSION) \
+		--out $(win32_builddir)/ModeProxy_vc9.vcproj \
+		--yaml ../coil_test.vcproj.yaml \
+		--source $(TEST_SRC)
+#		--header $(TEST_H)
+	qkc -sm $(win32_builddir)/ModeProxy_vc9.vcproj
+
+ModeProxy_vc10.vcproj:
+	$(top_builddir)/build/vcprojtool.py vcproj \
+		--projectname ModeProxyTest \
+		--type EXE \
+		--vcversion "10.00" \
+		--version $(COIL_VERSION) \
+		--out $(win32_builddir)/ModeProxy_vc10.vcproj \
+		--yaml ../coil_test.vcproj.yaml \
+		--source $(TEST_SRC)
+	qkc -sm $(win32_builddir)/ModeProxy_vc10.vcproj
+
+

Added: branches/work_ForDoil/OpenRTM-aist/src/lib/doil/utils/omniidl_be/tests/ModeProxy/ModeProxyTests.cpp
===================================================================
--- branches/work_ForDoil/OpenRTM-aist/src/lib/doil/utils/omniidl_be/tests/ModeProxy/ModeProxyTests.cpp	                        (rev 0)
+++ branches/work_ForDoil/OpenRTM-aist/src/lib/doil/utils/omniidl_be/tests/ModeProxy/ModeProxyTests.cpp	2014-02-12 15:00:26 UTC (rev 2472)
@@ -0,0 +1,220 @@
+// -*- C++ -*-
+/*!
+ * @file   ModeProxyTests.cpp
+ * @brief  ModeProxy test class
+ * @date   $Date$ 
+ * @author Noriaki Ando <n-ando at aist.go.jp>
+ *
+ * $Id$ 
+ *
+ */
+
+/*
+ * $Log$
+ *
+ */
+
+#ifndef ModeProxy_cpp
+#define ModeProxy_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 <ModeProxy.h>
+#include <rtm/NVUtil.h>
+#include <ISDOService.h>
+#include <ISDOSystemElement.h>
+#include <IOrganization.h>
+#include <doil/corba/CORBAManager.h>
+
+
+/*!
+ * @class ModeProxyTests class
+ * @brief ModeProxy test
+ */
+namespace ModeProxy
+{
+  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 ModeMock
+    : public virtual ::POA_RTC::Mode
+  {
+  protected:
+      ::std::vector<std::string> m_log;
+  private:
+  public :
+      ModeMock(){}
+      virtual ~ModeMock()
+      {
+      }
+
+      void setLogger(Logger* logger)
+      {
+        m_logger = logger;
+      }
+
+  private:
+    Logger* m_logger;
+
+  };
+
+  class ModeProxyTests
+   : public CppUnit::TestFixture
+  {
+    CPPUNIT_TEST_SUITE(ModeProxyTests);
+    //CPPUNIT_TEST(test_set_service_profile);
+    CPPUNIT_TEST_SUITE_END();
+  
+  private:
+    CORBA::ORB_ptr m_pORB;
+    PortableServer::POA_ptr m_pPOA;
+  
+  public:
+  
+    /*!
+     * @brief Constructor
+     */
+    ModeProxyTests()
+    {
+      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
+     */
+    ~ModeProxyTests()
+    {
+    }
+  
+    /*!
+     * @brief Test initialization
+     */
+    virtual void setUp()
+    {
+    }
+    
+    /*!
+     * @brief Test finalization
+     */
+    virtual void tearDown()
+    { 
+    }
+  
+    /*! 
+     *
+     *
+     *
+     */
+/*
+    void test_set_service_profile()
+    {
+      std::cout <<"test_set_service_profile() entry "<<std::endl;
+      doil::CORBA::CORBAManager& 
+                            mgr(doil::CORBA::CORBAManager::instance());
+      std::cout <<"Manager Name==>"<< mgr.name() << std::endl;
+
+      ModeMock* obj = new ModeMock();
+      ::CORBA::Object_ptr ref = obj->_this();
+      if(::CORBA::is_nil(ref))
+      {
+         std::cout<<"ref is nil.Abort test."<<std::endl;
+         return;
+      }
+      
+      std::cout <<"test_set_service_profile() ref: "<<ref<<std::endl;
+      ::SDOPackage::CORBA::ModeProxy* ap 
+                 = new ::SDOPackage::CORBA::ModeProxy(ref);
+
+      Logger logger;
+      obj->setLogger(&logger);
+
+      std::cout <<"test_set_service_profile() 030 "<<std::endl;
+      CPPUNIT_ASSERT_EQUAL(0, logger.countLog("set_service_profile"));
+      ::SDOPackage::Local::ServiceProfile porf;
+      ISDOServiceMock service;
+
+      std::cout <<"test_set_service_profile() 040 "<<std::endl;
+      mgr.registerFactory(service.id(), 
+                          doil::New<ISDOServiceServantMock>,
+                          doil::Delete<ISDOServiceServantMock>);
+      std::cout <<"test_set_service_profile() 050 "<<std::endl;
+      mgr.activateObject(&service);
+
+      porf.service = &service;
+      const ::SDOPackage::Local::ServiceProfile _porf = porf;
+      std::cout <<"test_set_service_profile() 060 "<<std::endl;
+      ap->set_service_profile(_porf);
+      std::cout <<"test_set_service_profile() 070 "<<std::endl;
+      CPPUNIT_ASSERT_EQUAL(1, logger.countLog("set_service_profile"));
+
+      std::cout <<"test_set_service_profile() 080 "<<std::endl;
+      mgr.deactivateObject(&service);
+      std::cout <<"test_set_service_profile() 080 "<<std::endl;
+
+      delete ap;
+      CORBA::release(ref);
+      mgr.shutdown();
+      std::cout <<"test_set_service_profile() ret "<<std::endl;
+    }
+*/
+    /* test case */
+    void test_case0()
+    {
+    }
+  };
+}; // namespace ModeProxy
+
+/*
+ * Register test suite
+ */
+CPPUNIT_TEST_SUITE_REGISTRATION(ModeProxy::ModeProxyTests);
+
+#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 // ModeProxy_cpp



More information about the openrtm-commit mailing list