test_controller.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 PKG = 'ez_interactive_marker'
3 import roslib; roslib.load_manifest(PKG)
4 import unittest
5 import rospy
9 
10 class TestController(unittest.TestCase):
12  rospy.init_node("test")
13  server = InteractiveMarkerServer("test")
14  menu_handler = MenuHandler()
15  controller = ec.GroupedCheckStateController(server, menu_handler)
16  e0 = menu_handler.insert("menu0")
17  controller.add_group("group0", e0)
18  e1 = menu_handler.insert("menu1")
19  controller.add_group("group0", e1)
20  e2 = menu_handler.insert("menu2")
21  controller.add_group("group0", e2)
22  e3 = menu_handler.insert("menu3")
23  controller.add_group("group1", e3)
24  e4 = menu_handler.insert("menu4")
25  controller.add_group("group1", e4)
26  controller.update_check_state(e0)
27  self.assertEqual(menu_handler.getCheckState(e0), MenuHandler.CHECKED)
28  self.assertEqual(menu_handler.getCheckState(e1), MenuHandler.UNCHECKED)
29  self.assertEqual(menu_handler.getCheckState(e2), MenuHandler.UNCHECKED)
30  self.assertEqual(menu_handler.getCheckState(e3), MenuHandler.UNCHECKED)
31  self.assertEqual(menu_handler.getCheckState(e4), MenuHandler.UNCHECKED)
32 
33  controller.update_check_state(e2)
34  self.assertEqual(menu_handler.getCheckState(e0), MenuHandler.UNCHECKED)
35  self.assertEqual(menu_handler.getCheckState(e1), MenuHandler.UNCHECKED)
36  self.assertEqual(menu_handler.getCheckState(e2), MenuHandler.CHECKED)
37  self.assertEqual(menu_handler.getCheckState(e3), MenuHandler.UNCHECKED)
38  self.assertEqual(menu_handler.getCheckState(e4), MenuHandler.UNCHECKED)
39 
40  controller.update_check_state(e4)
41  self.assertEqual(menu_handler.getCheckState(e0), MenuHandler.UNCHECKED)
42  self.assertEqual(menu_handler.getCheckState(e1), MenuHandler.UNCHECKED)
43  self.assertEqual(menu_handler.getCheckState(e2), MenuHandler.CHECKED)
44  self.assertEqual(menu_handler.getCheckState(e3), MenuHandler.UNCHECKED)
45  self.assertEqual(menu_handler.getCheckState(e4), MenuHandler.CHECKED)
46 
47 if __name__ == '__main__':
48  import rostest
49  rostest.rosrun(PKG, 'test_controller', TestController)


ez_interactive_marker
Author(s):
autogenerated on Mon Jun 10 2019 13:15:06