@@ -51,7 +51,8 @@ TEST_CASE("[SceneTree][TabBar] tab operations") {
5151 CHECK (tab_bar->get_previous_tab () == -1 );
5252 }
5353
54- SUBCASE (" [TabBar] add tabs" ) {
54+ SUBCASE (" [TabBar] add tabs disallowing deselection" ) {
55+ tab_bar->set_deselect_enabled (false );
5556 tab_bar->add_tab (" tab0" );
5657 CHECK (tab_bar->get_tab_count () == 1 );
5758 CHECK (tab_bar->get_current_tab () == 0 );
@@ -92,6 +93,23 @@ TEST_CASE("[SceneTree][TabBar] tab operations") {
9293 CHECK_FALSE (tab_bar->is_tab_hidden (2 ));
9394 }
9495
96+ SUBCASE (" [TabBar] add tabs allowing deselection" ) {
97+ tab_bar->set_deselect_enabled (true );
98+ tab_bar->add_tab (" tab0" );
99+ CHECK (tab_bar->get_tab_count () == 1 );
100+ CHECK (tab_bar->get_current_tab () == -1 );
101+ CHECK (tab_bar->get_previous_tab () == -1 );
102+ SIGNAL_CHECK_FALSE (" tab_selected" );
103+ SIGNAL_CHECK_FALSE (" tab_changed" );
104+
105+ tab_bar->add_tab (" tab1" );
106+ CHECK (tab_bar->get_tab_count () == 2 );
107+ CHECK (tab_bar->get_current_tab () == -1 );
108+ CHECK (tab_bar->get_previous_tab () == -1 );
109+ SIGNAL_CHECK_FALSE (" tab_selected" );
110+ SIGNAL_CHECK_FALSE (" tab_changed" );
111+ }
112+
95113 SUBCASE (" [TabBar] set tab count" ) {
96114 // Adds multiple tabs at once.
97115 tab_bar->set_tab_count (3 );
@@ -320,7 +338,7 @@ TEST_CASE("[SceneTree][TabBar] tab operations") {
320338 SIGNAL_CHECK (" tab_selected" , { { -1 } });
321339 SIGNAL_CHECK (" tab_changed" , { { -1 } });
322340
323- // Adding a tab will still set the current tab to 0.
341+ // Adding first tab will NOT change the current tab. (stays deselected)
324342 tab_bar->clear_tabs ();
325343 CHECK (tab_bar->get_current_tab () == -1 );
326344 CHECK (tab_bar->get_previous_tab () == -1 );
@@ -329,10 +347,10 @@ TEST_CASE("[SceneTree][TabBar] tab operations") {
329347 tab_bar->add_tab (" tab1" );
330348 tab_bar->add_tab (" tab2" );
331349 CHECK (tab_bar->get_tab_count () == 3 );
332- CHECK (tab_bar->get_current_tab () == 0 );
350+ CHECK (tab_bar->get_current_tab () == - 1 );
333351 CHECK (tab_bar->get_previous_tab () == -1 );
334- SIGNAL_CHECK (" tab_selected" , { { 0 } } );
335- SIGNAL_CHECK (" tab_changed" , { { 0 } } );
352+ SIGNAL_CHECK_FALSE (" tab_selected" );
353+ SIGNAL_CHECK_FALSE (" tab_changed" );
336354
337355 tab_bar->set_current_tab (-1 );
338356 SIGNAL_DISCARD (" tab_selected" );
0 commit comments