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
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 PKG = 'rosjava'
00037 NAME = 'int64_passthrough'
00038 import roslib; roslib.load_manifest(PKG)
00039
00040 from ros import rospy
00041 from ros import std_msgs
00042 from ros import rostest
00043
00044 import sys
00045 import time
00046 import unittest
00047
00048 from std_msgs.msg import Int64
00049
00050 class TestInt64Passthrough(unittest.TestCase):
00051
00052 def setUp(self):
00053 rospy.init_node(NAME)
00054
00055
00056 self.fixture_prev = self.fixture_curr = None
00057 self.test_prev = self.test_curr = None
00058
00059 rospy.Subscriber('int64_in', Int64, self.cb_from_fixture)
00060 rospy.Subscriber('int64_out', Int64, self.cb_from_test)
00061
00062 def cb_from_fixture(self, msg):
00063 self.fixture_prev = self.fixture_curr
00064 self.fixture_curr = msg
00065
00066 def cb_from_test(self, msg):
00067 self.test_prev = self.test_curr
00068 self.test_curr = msg
00069
00070 def test_int64_passthrough(self):
00071
00072 timeout_t = time.time() + 20.
00073 print "waiting for 20 seconds for fixture to verify"
00074 while self.fixture_prev is None and \
00075 not rospy.is_shutdown() and \
00076 timeout_t > time.time():
00077 time.sleep(0.2)
00078
00079 self.failIf(timeout_t < time.time(), "timeout exceeded")
00080 self.failIf(rospy.is_shutdown(), "node shutdown")
00081 self.failIf(self.fixture_prev is None, "no data from fixture")
00082 self.failIf(self.fixture_curr is None, "no data from fixture")
00083 self.assertEquals(self.fixture_prev.data + 1, self.fixture_curr.data, "fixture should incr by one")
00084
00085
00086 timeout_t = time.time() + 20.
00087 print "waiting for 20 seconds for client to verify"
00088 while self.test_prev is None and \
00089 not rospy.is_shutdown() and \
00090 timeout_t > time.time():
00091 time.sleep(0.2)
00092
00093 self.failIf(self.test_prev is None, "no data from test")
00094 self.assertEquals(self.test_prev.data + 1, self.test_curr.data, "test does not appear to match fixture data")
00095
00096
00097 if __name__ == '__main__':
00098 import rostest
00099 rostest.run(PKG, NAME, TestInt64Passthrough, sys.argv)