diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-06-19 22:33:46 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-06-19 22:33:46 +0200 |
commit | cce100a84058999ad28007efe36bac32896e8cc9 (patch) | |
tree | 5aac00dd27036603ec3b8c59b4f7b10005d25e4c /tests/scene/test_node.h | |
parent | 080d471e9812323b177492ec90fad34c3da38869 (diff) | |
parent | d159123633beb756c923d1dbb3faee6657269b2c (diff) | |
download | redot-engine-cce100a84058999ad28007efe36bac32896e8cc9.tar.gz |
Merge pull request #75459 from kleonc/node-fix-find-children
Fix recursive `Node.find_children`
Diffstat (limited to 'tests/scene/test_node.h')
-rw-r--r-- | tests/scene/test_node.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/scene/test_node.h b/tests/scene/test_node.h index 8b0655125d..b3362b02a8 100644 --- a/tests/scene/test_node.h +++ b/tests/scene/test_node.h @@ -308,6 +308,9 @@ TEST_CASE("[SceneTree][Node] Testing node operations with a more complex simple Node *child = SceneTree::get_singleton()->get_root()->find_child("NestedNode", true, false); CHECK_EQ(child, nullptr); + TypedArray<Node> children = SceneTree::get_singleton()->get_root()->find_children("NestedNode", "", true, false); + CHECK_EQ(children.size(), 0); + node1->set_name("Node1"); node2->set_name("Node2"); node1_1->set_name("NestedNode"); @@ -315,15 +318,29 @@ TEST_CASE("[SceneTree][Node] Testing node operations with a more complex simple child = SceneTree::get_singleton()->get_root()->find_child("NestedNode", true, false); CHECK_EQ(child, node1_1); + children = SceneTree::get_singleton()->get_root()->find_children("NestedNode", "", true, false); + CHECK_EQ(children.size(), 1); + CHECK_EQ(Object::cast_to<Node>(children[0]), node1_1); + // First node that matches with the name is node1. child = SceneTree::get_singleton()->get_root()->find_child("Node?", true, false); CHECK_EQ(child, node1); + children = SceneTree::get_singleton()->get_root()->find_children("Node?", "", true, false); + CHECK_EQ(children.size(), 2); + CHECK_EQ(Object::cast_to<Node>(children[0]), node1); + CHECK_EQ(Object::cast_to<Node>(children[1]), node2); + SceneTree::get_singleton()->get_root()->move_child(node2, 0); // It should be node2, as it is now the first one in the tree. child = SceneTree::get_singleton()->get_root()->find_child("Node?", true, false); CHECK_EQ(child, node2); + + children = SceneTree::get_singleton()->get_root()->find_children("Node?", "", true, false); + CHECK_EQ(children.size(), 2); + CHECK_EQ(Object::cast_to<Node>(children[0]), node2); + CHECK_EQ(Object::cast_to<Node>(children[1]), node1); } SUBCASE("Nodes should be accessible via their node path") { |