summaryrefslogtreecommitdiffstats
path: root/tests/scene/test_tree.h
diff options
context:
space:
mode:
authorSpartan322 <Megacake1234@gmail.com>2024-10-26 22:41:20 -0400
committerSpartan322 <Megacake1234@gmail.com>2024-10-26 22:41:20 -0400
commit953af98c795066a5a450a3401cc8a4fbc6c12620 (patch)
tree9e100139ffacbcae90fbb5e6b10413e50a8e76b6 /tests/scene/test_tree.h
parenta43f7f1c02a887d19694bdebac83af4d32cf3433 (diff)
parent61accf060515416da07d913580419fd8c8490f7b (diff)
downloadredot-engine-953af98c795066a5a450a3401cc8a4fbc6c12620.tar.gz
Merge commit godotengine/godot@61accf060515416da07d913580419fd8c8490f7b
Diffstat (limited to 'tests/scene/test_tree.h')
-rw-r--r--tests/scene/test_tree.h126
1 files changed, 126 insertions, 0 deletions
diff --git a/tests/scene/test_tree.h b/tests/scene/test_tree.h
index 5fda4dea73..dc63cb6eb7 100644
--- a/tests/scene/test_tree.h
+++ b/tests/scene/test_tree.h
@@ -141,18 +141,30 @@ TEST_CASE("[SceneTree][Tree]") {
TreeItem *child1 = tree->create_item();
TreeItem *child2 = tree->create_item();
TreeItem *child3 = tree->create_item();
+ CHECK_EQ(root->get_next(), nullptr);
+ CHECK_EQ(root->get_next_visible(), child1);
+ CHECK_EQ(root->get_next_in_tree(), child1);
CHECK_EQ(child1->get_next(), child2);
+ CHECK_EQ(child1->get_next_visible(), child2);
CHECK_EQ(child1->get_next_in_tree(), child2);
CHECK_EQ(child2->get_next(), child3);
+ CHECK_EQ(child2->get_next_visible(), child3);
CHECK_EQ(child2->get_next_in_tree(), child3);
CHECK_EQ(child3->get_next(), nullptr);
+ CHECK_EQ(child3->get_next_visible(), nullptr);
CHECK_EQ(child3->get_next_in_tree(), nullptr);
+ CHECK_EQ(root->get_prev(), nullptr);
+ CHECK_EQ(root->get_prev_visible(), nullptr);
+ CHECK_EQ(root->get_prev_in_tree(), nullptr);
CHECK_EQ(child1->get_prev(), nullptr);
+ CHECK_EQ(child1->get_prev_visible(), root);
CHECK_EQ(child1->get_prev_in_tree(), root);
CHECK_EQ(child2->get_prev(), child1);
+ CHECK_EQ(child2->get_prev_visible(), child1);
CHECK_EQ(child2->get_prev_in_tree(), child1);
CHECK_EQ(child3->get_prev(), child2);
+ CHECK_EQ(child3->get_prev_visible(), child2);
CHECK_EQ(child3->get_prev_in_tree(), child2);
TreeItem *nested1 = tree->create_item(child2);
@@ -160,13 +172,127 @@ TEST_CASE("[SceneTree][Tree]") {
TreeItem *nested3 = tree->create_item(child2);
CHECK_EQ(child1->get_next(), child2);
+ CHECK_EQ(child1->get_next_visible(), child2);
CHECK_EQ(child1->get_next_in_tree(), child2);
CHECK_EQ(child2->get_next(), child3);
+ CHECK_EQ(child2->get_next_visible(), nested1);
CHECK_EQ(child2->get_next_in_tree(), nested1);
CHECK_EQ(child3->get_prev(), child2);
+ CHECK_EQ(child3->get_prev_visible(), nested3);
CHECK_EQ(child3->get_prev_in_tree(), nested3);
CHECK_EQ(nested1->get_prev_in_tree(), child2);
CHECK_EQ(nested1->get_next_in_tree(), nested2);
+ CHECK_EQ(nested3->get_next_in_tree(), child3);
+
+ memdelete(tree);
+ }
+
+ SUBCASE("[Tree] Previous and Next items with hide root.") {
+ Tree *tree = memnew(Tree);
+ tree->set_hide_root(true);
+ TreeItem *root = tree->create_item();
+
+ TreeItem *child1 = tree->create_item();
+ TreeItem *child2 = tree->create_item();
+ TreeItem *child3 = tree->create_item();
+ CHECK_EQ(root->get_next(), nullptr);
+ CHECK_EQ(root->get_next_visible(), child1);
+ CHECK_EQ(root->get_next_in_tree(), child1);
+ CHECK_EQ(child1->get_next(), child2);
+ CHECK_EQ(child1->get_next_visible(), child2);
+ CHECK_EQ(child1->get_next_in_tree(), child2);
+ CHECK_EQ(child2->get_next(), child3);
+ CHECK_EQ(child2->get_next_visible(), child3);
+ CHECK_EQ(child2->get_next_in_tree(), child3);
+ CHECK_EQ(child3->get_next(), nullptr);
+ CHECK_EQ(child3->get_next_visible(), nullptr);
+ CHECK_EQ(child3->get_next_in_tree(), nullptr);
+
+ CHECK_EQ(root->get_prev(), nullptr);
+ CHECK_EQ(root->get_prev_visible(), nullptr);
+ CHECK_EQ(root->get_prev_in_tree(), nullptr);
+ CHECK_EQ(child1->get_prev(), nullptr);
+ CHECK_EQ(child1->get_prev_visible(), nullptr);
+ CHECK_EQ(child1->get_prev_in_tree(), nullptr);
+ CHECK_EQ(child2->get_prev(), child1);
+ CHECK_EQ(child2->get_prev_visible(), child1);
+ CHECK_EQ(child2->get_prev_in_tree(), child1);
+ CHECK_EQ(child3->get_prev(), child2);
+ CHECK_EQ(child3->get_prev_visible(), child2);
+ CHECK_EQ(child3->get_prev_in_tree(), child2);
+
+ memdelete(tree);
+ }
+
+ SUBCASE("[Tree] Previous and Next items wrapping.") {
+ Tree *tree = memnew(Tree);
+ TreeItem *root = tree->create_item();
+
+ TreeItem *child1 = tree->create_item();
+ TreeItem *child2 = tree->create_item();
+ TreeItem *child3 = tree->create_item();
+ CHECK_EQ(root->get_next_visible(true), child1);
+ CHECK_EQ(root->get_next_in_tree(true), child1);
+ CHECK_EQ(child1->get_next_visible(true), child2);
+ CHECK_EQ(child1->get_next_in_tree(true), child2);
+ CHECK_EQ(child2->get_next_visible(true), child3);
+ CHECK_EQ(child2->get_next_in_tree(true), child3);
+ CHECK_EQ(child3->get_next_visible(true), root);
+ CHECK_EQ(child3->get_next_in_tree(true), root);
+
+ CHECK_EQ(root->get_prev_visible(true), child3);
+ CHECK_EQ(root->get_prev_in_tree(true), child3);
+ CHECK_EQ(child1->get_prev_visible(true), root);
+ CHECK_EQ(child1->get_prev_in_tree(true), root);
+ CHECK_EQ(child2->get_prev_visible(true), child1);
+ CHECK_EQ(child2->get_prev_in_tree(true), child1);
+ CHECK_EQ(child3->get_prev_visible(true), child2);
+ CHECK_EQ(child3->get_prev_in_tree(true), child2);
+
+ TreeItem *nested1 = tree->create_item(child2);
+ TreeItem *nested2 = tree->create_item(child2);
+ TreeItem *nested3 = tree->create_item(child2);
+
+ CHECK_EQ(child1->get_next_visible(true), child2);
+ CHECK_EQ(child1->get_next_in_tree(true), child2);
+ CHECK_EQ(child2->get_next_visible(true), nested1);
+ CHECK_EQ(child2->get_next_in_tree(true), nested1);
+ CHECK_EQ(nested3->get_next_visible(true), child3);
+ CHECK_EQ(nested3->get_next_in_tree(true), child3);
+ CHECK_EQ(child3->get_prev_visible(true), nested3);
+ CHECK_EQ(child3->get_prev_in_tree(true), nested3);
+ CHECK_EQ(nested1->get_prev_in_tree(true), child2);
+ CHECK_EQ(nested1->get_next_in_tree(true), nested2);
+ CHECK_EQ(nested3->get_next_in_tree(true), child3);
+
+ memdelete(tree);
+ }
+
+ SUBCASE("[Tree] Previous and Next items wrapping with hide root.") {
+ Tree *tree = memnew(Tree);
+ tree->set_hide_root(true);
+ TreeItem *root = tree->create_item();
+
+ TreeItem *child1 = tree->create_item();
+ TreeItem *child2 = tree->create_item();
+ TreeItem *child3 = tree->create_item();
+ CHECK_EQ(root->get_next_visible(true), child1);
+ CHECK_EQ(root->get_next_in_tree(true), child1);
+ CHECK_EQ(child1->get_next_visible(true), child2);
+ CHECK_EQ(child1->get_next_in_tree(true), child2);
+ CHECK_EQ(child2->get_next_visible(true), child3);
+ CHECK_EQ(child2->get_next_in_tree(true), child3);
+ CHECK_EQ(child3->get_next_visible(true), root);
+ CHECK_EQ(child3->get_next_in_tree(true), root);
+
+ CHECK_EQ(root->get_prev_visible(true), child3);
+ CHECK_EQ(root->get_prev_in_tree(true), child3);
+ CHECK_EQ(child1->get_prev_visible(true), child3);
+ CHECK_EQ(child1->get_prev_in_tree(true), child3);
+ CHECK_EQ(child2->get_prev_visible(true), child1);
+ CHECK_EQ(child2->get_prev_in_tree(true), child1);
+ CHECK_EQ(child3->get_prev_visible(true), child2);
+ CHECK_EQ(child3->get_prev_in_tree(true), child2);
memdelete(tree);
}