test_Timer.py
Go to the documentation of this file.
00001 #!/usr/bin/env/python
00002 # -*- Python -*-
00003 
00004 #
00005 # \file Timer.py
00006 # \brief Timer class
00007 # \date $Date: $
00008 # \author Noriaki Ando <n-ando@aist.go.jp>
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,time
00019 sys.path.insert(1,"../")
00020 
00021 import unittest
00022 import OpenRTM_aist
00023 
00024 from Timer import *
00025 
00026 
00027 class test:
00028   def func(self):
00029     print "test.hello."
00030 
00031   def invoke(self):
00032     print "test invoke"
00033     
00034 class TestTimer(unittest.TestCase):
00035   def setUp(self):
00036     self.tm = Timer(OpenRTM_aist.TimeValue())
00037     
00038   def tearDown(self):
00039     self.tm.__del__()
00040     OpenRTM_aist.Manager.instance().shutdownManager()
00041     time.sleep(0.1)
00042 
00043   def test_start_stop(self):
00044     self.tm.start()
00045     self.tm.stop()
00046     
00047 
00048   def test_invoke(self):
00049     self.tm.registerListenerFunc(test().func, OpenRTM_aist.TimeValue())
00050     self.tm.registerListenerFunc(test().func, OpenRTM_aist.TimeValue())
00051     self.tm.invoke()
00052     
00053 
00054   def test_registerListener(self):
00055     self.tm.registerListener(test(), OpenRTM_aist.TimeValue())
00056     self.tm.invoke()
00057     pass
00058 
00059     
00060   def test_registerListenerObj(self):
00061     self.tm.registerListenerObj(test(), test.func, OpenRTM_aist.TimeValue())
00062     self.tm.invoke()
00063     
00064 
00065   def test_registerListenerFunc(self):
00066     self.tm.registerListenerFunc(test().func, OpenRTM_aist.TimeValue())
00067     self.tm.invoke()
00068 
00069 
00070   def test_unregisterListener(self):
00071     obj = OpenRTM_aist.ListenerObject(test(),test.func)
00072     self.tm.registerListener(obj, OpenRTM_aist.TimeValue())
00073     self.assertEqual(self.tm.unregisterListener(obj),True)
00074     self.assertEqual(self.tm.unregisterListener(obj),False)
00075 
00076 
00077 ############### test #################
00078 if __name__ == '__main__':
00079   unittest.main()


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