@@ -218,7 +218,54 @@ TEST_CASE("[SceneTree][Control] Find next/prev valid focus") {
218218 CHECK_UNARY (ctrl->has_focus ());
219219 }
220220
221- SUBCASE (" [SceneTree][Control] Has a sibling control but the parent node is not a control" ) {
221+ SUBCASE (" [SceneTree][Control] Has a sibling control and the parent is a window" ) {
222+ Control *ctrl1 = memnew (Control);
223+ Control *ctrl2 = memnew (Control);
224+ Control *ctrl3 = memnew (Control);
225+ Window *win = SceneTree::get_singleton ()->get_root ();
226+
227+ ctrl1->set_focus_mode (Control::FocusMode::FOCUS_ALL);
228+ ctrl2->set_focus_mode (Control::FocusMode::FOCUS_ALL);
229+ ctrl3->set_focus_mode (Control::FocusMode::FOCUS_ALL);
230+
231+ ctrl2->add_child (ctrl3);
232+ win->add_child (ctrl1);
233+ win->add_child (ctrl2);
234+
235+ SUBCASE (" [SceneTree][Control] Focus Next" ) {
236+ ctrl1->grab_focus ();
237+ CHECK_UNARY (ctrl1->has_focus ());
238+
239+ SEND_GUI_ACTION (" ui_focus_next" );
240+ CHECK_UNARY (ctrl2->has_focus ());
241+
242+ SEND_GUI_ACTION (" ui_focus_next" );
243+ CHECK_UNARY (ctrl3->has_focus ());
244+
245+ SEND_GUI_ACTION (" ui_focus_next" );
246+ CHECK_UNARY (ctrl1->has_focus ());
247+ }
248+
249+ SUBCASE (" [SceneTree][Control] Focus Prev" ) {
250+ ctrl1->grab_focus ();
251+ CHECK_UNARY (ctrl1->has_focus ());
252+
253+ SEND_GUI_ACTION (" ui_focus_prev" );
254+ CHECK_UNARY (ctrl3->has_focus ());
255+
256+ SEND_GUI_ACTION (" ui_focus_prev" );
257+ CHECK_UNARY (ctrl2->has_focus ());
258+
259+ SEND_GUI_ACTION (" ui_focus_prev" );
260+ CHECK_UNARY (ctrl1->has_focus ());
261+ }
262+
263+ memdelete (ctrl3);
264+ memdelete (ctrl1);
265+ memdelete (ctrl2);
266+ }
267+
268+ SUBCASE (" [SceneTree][Control] Has a sibling control but the parent node is not a control or window" ) {
222269 Control *other_ctrl = memnew (Control);
223270 intermediate->add_child (other_ctrl);
224271
0 commit comments