test_ExtTrigExecutionContext.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # -*- Python -*-
00003 
00004 #
00005 # \file test_ExtTrigExecutionContext.py
00006 # \brief ExtTrigExecutionContext class
00007 # \date $Date: 2007/09/06$
00008 # \author Shinji Kurihara
00009 #
00010 # Copyright (C) 2007
00011 #     Task-intelligence Research Group,
00012 #     Intelligent Systems Research Institute,
00013 #     National Institute of
00014 #         Advanced Industrial Science and Technology (AIST), Japan
00015 #     All rights reserved.
00016 #
00017 
00018 import sys
00019 sys.path.insert(1,"../")
00020 import threading
00021 
00022 import unittest
00023 import OpenRTM_aist
00024 import RTC, RTC__POA
00025 
00026 from ExtTrigExecutionContext import *
00027 
00028 from omniORB import CORBA, PortableServer
00029 
00030 class DFP(OpenRTM_aist.RTObject_impl):
00031   def __init__(self):
00032     self._orb = CORBA.ORB_init()
00033     self._poa = self._orb.resolve_initial_references("RootPOA")
00034     OpenRTM_aist.RTObject_impl.__init__(self, orb=self._orb, poa=self._poa)
00035     self._error = False
00036     self._ref = self._this()
00037     self._eclist = []
00038 
00039   def on_execute(self, ec_id):
00040     return RTC.RTC_OK
00041 
00042 class TestExtTrigExecutionContext(unittest.TestCase):
00043   def setUp(self):
00044     self._dfp = DFP()
00045     self._dfp._poa._get_the_POAManager().activate()
00046     self.etec = ExtTrigExecutionContext()
00047     #self.etec = ExtTrigExecutionContext(self._dfp._ref)
00048 
00049   def tearDown(self):
00050     OpenRTM_aist.Manager.instance().shutdownManager()
00051     return
00052 
00053   def test_tick(self):
00054     pass
00055 
00056   def test_run(self):
00057     self.assertEqual(self.etec.start(),RTC.RTC_OK)
00058     self.assertEqual(self.etec.add_component(self._dfp._this()),RTC.RTC_OK)
00059     self.assertEqual(self.etec.activate_component(self._dfp._this()),RTC.RTC_OK)
00060     import time
00061     time.sleep(1)
00062     self.etec.tick()
00063     self.etec.tick()
00064     time.sleep(1)
00065     self.assertEqual(self.etec.deactivate_component(self._dfp._this()),RTC.RTC_OK)
00066     time.sleep(1)
00067     self.assertEqual(self.etec.remove_component(self._dfp._this()),RTC.RTC_OK)
00068     th = threading.Thread(target=self.stop)
00069     th.start()
00070     self.etec.tick()
00071     if th:
00072       th.join()
00073     self._dfp._poa.deactivate_object(self._dfp._poa.servant_to_id(self.etec))
00074     self._dfp._poa.deactivate_object(self._dfp._poa.servant_to_id(self._dfp))
00075 
00076   def stop(self):
00077     self.etec.stop()
00078 
00079 ############### test #################
00080 if __name__ == '__main__':
00081         unittest.main()


openrtm_aist_python
Author(s): Shinji Kurihara
autogenerated on Thu Aug 27 2015 14:17:28