-
-
Notifications
You must be signed in to change notification settings - Fork 22.9k
Add layout and focus behavior unit test for Control #107037
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add layout and focus behavior unit test for Control #107037
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following suggestions should make your code pass the style check.
#include "scene/gui/control.h" | ||
#include "scene/main/window.h" | ||
#include "scene/main/scene_tree.h" | ||
#include "tests/test_macros.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#include "scene/gui/control.h" | |
#include "scene/main/window.h" | |
#include "scene/main/scene_tree.h" | |
#include "tests/test_macros.h" | |
#include "scene/gui/control.h" | |
#include "scene/main/scene_tree.h" | |
#include "scene/main/window.h" | |
#include "tests/test_macros.h" |
CHECK_MESSAGE( | ||
child->get_position().is_equal_approx(Vector2(100, 100)), | ||
"Child should be positioned at 25% of parent size."); | ||
CHECK_MESSAGE( | ||
child->get_size().is_equal_approx(Vector2(200, 200)), | ||
"Child should be sized to 50% of parent width and height."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CHECK_MESSAGE( | |
child->get_position().is_equal_approx(Vector2(100, 100)), | |
"Child should be positioned at 25% of parent size."); | |
CHECK_MESSAGE( | |
child->get_size().is_equal_approx(Vector2(200, 200)), | |
"Child should be sized to 50% of parent width and height."); | |
CHECK_MESSAGE( | |
child->get_position().is_equal_approx(Vector2(100, 100)), | |
"Child should be positioned at 25% of parent size."); | |
CHECK_MESSAGE( | |
child->get_size().is_equal_approx(Vector2(200, 200)), | |
"Child should be sized to 50% of parent width and height."); |
CHECK_MESSAGE( | ||
child->get_focus_neighbour(SIDE_LEFT) == NodePath("LeftControl"), | ||
"Left focus neighbor should be correctly set."); | ||
CHECK_MESSAGE( | ||
child->get_focus_neighbour(SIDE_RIGHT) == NodePath("RightControl"), | ||
"Right focus neighbor should be correctly set."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CHECK_MESSAGE( | |
child->get_focus_neighbour(SIDE_LEFT) == NodePath("LeftControl"), | |
"Left focus neighbor should be correctly set."); | |
CHECK_MESSAGE( | |
child->get_focus_neighbour(SIDE_RIGHT) == NodePath("RightControl"), | |
"Right focus neighbor should be correctly set."); | |
CHECK_MESSAGE( | |
child->get_focus_neighbour(SIDE_LEFT) == NodePath("LeftControl"), | |
"Left focus neighbor should be correctly set."); | |
CHECK_MESSAGE( | |
child->get_focus_neighbour(SIDE_RIGHT) == NodePath("RightControl"), | |
"Right focus neighbor should be correctly set."); |
This pull request contributes to issue #43440.
I have added unit tests to check anchor margins to position a child Control within a parent. Verifies that position and size are calculated correctly after the scene is processed. Also checks focus neighbor: the test sets left and right focus neighbors using set_focus_neighbour() and checks that get_focus_neighbour() returns the expected NodePath.