test_plugins.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. from nose.tools import ok_
  2. from autoware_launcher.core.plugin import AwPluginTree
  3. from autoware_launcher.gui.guimgr import AwQtGuiManager
  4. import rospkg
  5. import re
  6. import xml.etree.ElementTree as xtree
  7. def test_plugin_type():
  8. guimgr = AwQtGuiManager(None)
  9. plugins = AwPluginTree()
  10. for plugin_path in plugins.scan(""):
  11. plugin = plugins.find(plugin_path)
  12. fields = plugin.fields()
  13. for frame in plugin.panel().frames:
  14. print(plugin.path() + " " + str(frame.target))
  15. yield ok_, guimgr.widget(frame).validate_argtypes(fields, frame)
  16. print("")
  17. def test_plugin_field():
  18. rospack = rospkg.RosPack()
  19. regexp = re.compile("\$\(find (.*?)\)(.*)")
  20. plugins = AwPluginTree()
  21. for plugin_path in plugins.scan(""):
  22. plugin = plugins.find(plugin_path)
  23. if plugin.isleaf():
  24. result = regexp.match(plugin.rosxml())
  25. try:
  26. path = rospack.get_path(result.group(1)) + result.group(2)
  27. root = xtree.parse(path).getroot()
  28. xmlargs = {child.attrib["name"] for child in root if child.tag == "arg"}
  29. ymlargs = {arg.name for arg in plugin.args()}
  30. print(plugin.path())
  31. yield ok_, (xmlargs == ymlargs)
  32. print("")
  33. if xmlargs != ymlargs:
  34. print(ymlargs)
  35. print(xmlargs)
  36. except:
  37. print(result.group(1) + " is not built")