Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
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
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
00080 if __name__ == '__main__':
00081 unittest.main()