|
2 | 2 | #include "action_test_node.h" |
3 | 3 | #include "condition_test_node.h" |
4 | 4 | #include "behaviortree_cpp_v3/xml_parsing.h" |
| 5 | +#include "environment.h" |
5 | 6 | #include "../sample_nodes/crossdoor_nodes.h" |
6 | 7 | #include "../sample_nodes/dummy_nodes.h" |
7 | 8 |
|
@@ -303,4 +304,58 @@ TEST(BehaviorTreeFactory, SubTreeWithRemapping) |
303 | 304 | ASSERT_FALSE( talk_bb->getAny("talk_out") ); |
304 | 305 | } |
305 | 306 |
|
| 307 | +#if !defined(USING_ROS) && !defined(USING_ROS2) |
| 308 | +TEST(BehaviorTreeFactory, CreateTreeFromFile) |
| 309 | +{ |
| 310 | + BehaviorTreeFactory factory; |
| 311 | + |
| 312 | + // should not throw |
| 313 | + Tree tree = factory.createTreeFromFile((environment->executable_path.parent_path() / "trees/parent_no_include.xml").str()); |
| 314 | + ASSERT_EQ(NodeStatus::SUCCESS, tree.tickRoot()); |
| 315 | +} |
| 316 | + |
| 317 | +TEST(BehaviorTreeFactory, CreateTreeFromFileWhichIncludesFileFromSameDirectory) |
| 318 | +{ |
| 319 | + BehaviorTreeFactory factory; |
| 320 | + |
| 321 | + // should not throw |
| 322 | + Tree tree = factory.createTreeFromFile((environment->executable_path.parent_path() / "trees/child/child_include_sibling.xml").str()); |
| 323 | + ASSERT_EQ(NodeStatus::SUCCESS, tree.tickRoot()); |
| 324 | +} |
| 325 | + |
| 326 | +TEST(BehaviorTreeFactory, CreateTreeFromFileWhichIncludesFileFromChildDirectory) |
| 327 | +{ |
| 328 | + BehaviorTreeFactory factory; |
| 329 | + |
| 330 | + // should not throw |
| 331 | + Tree tree = factory.createTreeFromFile((environment->executable_path.parent_path() / "trees/parent_include_child.xml").str()); |
| 332 | + ASSERT_EQ(NodeStatus::SUCCESS, tree.tickRoot()); |
| 333 | +} |
306 | 334 |
|
| 335 | +TEST(BehaviorTreeFactory, CreateTreeFromFileWhichIncludesFileFromChildDirectoryWhichIncludesFileFromSameDirectory) |
| 336 | +{ |
| 337 | + BehaviorTreeFactory factory; |
| 338 | + |
| 339 | + // should not throw |
| 340 | + Tree tree = factory.createTreeFromFile((environment->executable_path.parent_path() / "trees/parent_include_child_include_sibling.xml").str()); |
| 341 | + ASSERT_EQ(NodeStatus::SUCCESS, tree.tickRoot()); |
| 342 | +} |
| 343 | + |
| 344 | +TEST(BehaviorTreeFactory, CreateTreeFromFileWhichIncludesFileFromChildDirectoryWhichIncludesFileFromChildDirectory) |
| 345 | +{ |
| 346 | + BehaviorTreeFactory factory; |
| 347 | + |
| 348 | + // should not throw |
| 349 | + Tree tree = factory.createTreeFromFile((environment->executable_path.parent_path() / "trees/parent_include_child_include_child.xml").str()); |
| 350 | + ASSERT_EQ(NodeStatus::SUCCESS, tree.tickRoot()); |
| 351 | +} |
| 352 | + |
| 353 | +TEST(BehaviorTreeFactory, CreateTreeFromFileWhichIncludesFileFromChildDirectoryWhichIncludesFileFromParentDirectory) |
| 354 | +{ |
| 355 | + BehaviorTreeFactory factory; |
| 356 | + |
| 357 | + // should not throw |
| 358 | + Tree tree = factory.createTreeFromFile((environment->executable_path.parent_path() / "trees/parent_include_child_include_parent.xml").str()); |
| 359 | + ASSERT_EQ(NodeStatus::SUCCESS, tree.tickRoot()); |
| 360 | +} |
| 361 | +#endif |
0 commit comments