|
1 | 1 | #include <gtest/gtest.h> |
2 | 2 | #include <filesystem> |
3 | | -#include "action_test_node.h" |
4 | | -#include "condition_test_node.h" |
5 | 3 | #include "behaviortree_cpp/xml_parsing.h" |
6 | 4 | #include "../sample_nodes/crossdoor_nodes.h" |
7 | 5 | #include "../sample_nodes/dummy_nodes.h" |
@@ -372,3 +370,36 @@ TEST(BehaviorTreeReload, ReloadSameTree) |
372 | 370 | ASSERT_EQ(NodeStatus::FAILURE, tree.tickWhileRunning()); |
373 | 371 | } |
374 | 372 | } |
| 373 | + |
| 374 | +class DescriptiveAction : public SyncActionNode |
| 375 | +{ |
| 376 | +public: |
| 377 | + DescriptiveAction(const std::string& name, const NodeConfig& config): |
| 378 | + SyncActionNode(name, config) {} |
| 379 | + |
| 380 | + BT::NodeStatus tick() override { |
| 381 | + return NodeStatus::SUCCESS; |
| 382 | + } |
| 383 | + |
| 384 | + static PortsList providedPorts() { |
| 385 | + return {}; |
| 386 | + } |
| 387 | + |
| 388 | + static std::string description() { |
| 389 | + return "THE DESCRIPTION"; |
| 390 | + } |
| 391 | +}; |
| 392 | + |
| 393 | +TEST(BehaviorTreeFactory, DescriptionMethod) |
| 394 | +{ |
| 395 | + |
| 396 | + BehaviorTreeFactory factory; |
| 397 | + factory.registerNodeType<DescriptiveAction>("DescriptiveAction"); |
| 398 | + const auto& manifest = factory.manifests().at("DescriptiveAction"); |
| 399 | + ASSERT_EQ(manifest.description, "THE DESCRIPTION"); |
| 400 | + |
| 401 | + auto xml = writeTreeNodesModelXML(factory, false); |
| 402 | + std::cout << xml << std::endl; |
| 403 | + |
| 404 | + ASSERT_NE(xml.find( "<description>THE DESCRIPTION</description>"), std::string::npos); |
| 405 | +} |
0 commit comments