@@ -162,7 +162,54 @@ TEST_CASE("[SceneTree][Control] Find next/prev valid focus") {
162162 CHECK_UNARY (ctrl->has_focus ());
163163 }
164164
165- SUBCASE (" [SceneTree][Control] Has a sibling control but the parent node is not a control" ) {
165+ SUBCASE (" [SceneTree][Control] Has a sibling control and the parent is a window" ) {
166+ Control *ctrl1 = memnew (Control);
167+ Control *ctrl2 = memnew (Control);
168+ Control *ctrl3 = memnew (Control);
169+ Window *win = SceneTree::get_singleton ()->get_root ();
170+
171+ ctrl1->set_focus_mode (Control::FocusMode::FOCUS_ALL);
172+ ctrl2->set_focus_mode (Control::FocusMode::FOCUS_ALL);
173+ ctrl3->set_focus_mode (Control::FocusMode::FOCUS_ALL);
174+
175+ ctrl2->add_child (ctrl3);
176+ win->add_child (ctrl1);
177+ win->add_child (ctrl2);
178+
179+ SUBCASE (" [SceneTree][Control] Focus Next" ) {
180+ ctrl1->grab_focus ();
181+ CHECK_UNARY (ctrl1->has_focus ());
182+
183+ SEND_GUI_ACTION (" ui_focus_next" );
184+ CHECK_UNARY (ctrl2->has_focus ());
185+
186+ SEND_GUI_ACTION (" ui_focus_next" );
187+ CHECK_UNARY (ctrl3->has_focus ());
188+
189+ SEND_GUI_ACTION (" ui_focus_next" );
190+ CHECK_UNARY (ctrl1->has_focus ());
191+ }
192+
193+ SUBCASE (" [SceneTree][Control] Focus Prev" ) {
194+ ctrl1->grab_focus ();
195+ CHECK_UNARY (ctrl1->has_focus ());
196+
197+ SEND_GUI_ACTION (" ui_focus_prev" );
198+ CHECK_UNARY (ctrl3->has_focus ());
199+
200+ SEND_GUI_ACTION (" ui_focus_prev" );
201+ CHECK_UNARY (ctrl2->has_focus ());
202+
203+ SEND_GUI_ACTION (" ui_focus_prev" );
204+ CHECK_UNARY (ctrl1->has_focus ());
205+ }
206+
207+ memdelete (ctrl3);
208+ memdelete (ctrl1);
209+ memdelete (ctrl2);
210+ }
211+
212+ SUBCASE (" [SceneTree][Control] Has a sibling control but the parent node is not a control or window" ) {
166213 Control *other_ctrl = memnew (Control);
167214 intermediate->add_child (other_ctrl);
168215
0 commit comments