Browse Source

Fixed unit test

Tig 1 năm trước cách đây
mục cha
commit
207266b68f

+ 28 - 0
Terminal.Gui/View/Navigation/TabStop.cs

@@ -0,0 +1,28 @@
+namespace Terminal.Gui;
+
+/// <summary>
+///     Describes a TabStop; a stop-point for keyboard navigation between Views.
+/// </summary>
+/// <remarks>
+///     <para>
+///         TabStop does not impact whether a view is focusable or not. <see cref="View.CanFocus"/> determines this independently of TabStop.
+///     </para>
+/// </remarks>
+[Flags]
+public enum TabStop
+{
+    /// <summary>
+    ///     The View will not be a stop-poknt for keyboard-based navigation.
+    /// </summary>
+    None = 0,
+
+    /// <summary>
+    ///     The View will be a stop-point for keybaord-based navigation across Views (e.g. if the user presses `Tab`).
+    /// </summary>
+    TabStop = 1,
+
+    /// <summary>
+    ///     The View will be a stop-point for keyboard-based navigation across TabGroups (e.g. if the user preesses <see cref="Application.NextTabGroupKey"/> (`Ctrl-PageDown`).
+    /// </summary>
+    TabGroup = 2,
+}

+ 3 - 3
Terminal.Gui/View/View.Navigation.cs

@@ -583,7 +583,7 @@ public partial class View // Focus and cross-view navigation management (TabStop
                     }
                 }
 
-                Debug.Assert (w.HasFocus);
+                //Debug.Assert (w.HasFocus);
 
                 if (w.Focused is null)
                 {
@@ -766,7 +766,7 @@ public partial class View // Focus and cross-view navigation management (TabStop
     private bool _tabStop = true;
 
     /// <summary>
-    ///     Gets or sets whether the view is a stop-point for keyboard navigation of focus. Will be <see langword="true"/>
+    ///     Gets or sets whether the view is a stop-point for keyboard navigation between Views. Will be <see langword="true"/>
     ///     only if <see cref="CanFocus"/> is <see langword="true"/>. Set to <see langword="false"/> to prevent the
     ///     view from being a stop-point for keyboard navigation.
     /// </summary>
@@ -783,7 +783,7 @@ public partial class View // Focus and cross-view navigation management (TabStop
             {
                 return;
             }
-            
+
             // BUGBUG: TabStop and CanFocus should be decoupled.
             _tabStop = CanFocus && value;
         }

+ 8 - 0
UnitTests/Application/Application.NavigationTests.cs

@@ -101,6 +101,8 @@ public class ApplicationNavigationTests (ITestOutputHelper output)
 
         // Assert
         Assert.True (view2.HasFocus);
+
+        top.Dispose ();
     }
 
     [Fact]
@@ -120,6 +122,8 @@ public class ApplicationNavigationTests (ITestOutputHelper output)
 
         // Assert
         Assert.True (view2.HasFocus);
+
+        top.Dispose ();
     }
 
     [Fact]
@@ -139,6 +143,8 @@ public class ApplicationNavigationTests (ITestOutputHelper output)
 
         // Assert
         Assert.True (view1.HasFocus);
+
+        top.Dispose ();
     }
 
     [Fact]
@@ -158,5 +164,7 @@ public class ApplicationNavigationTests (ITestOutputHelper output)
 
         // Assert
         Assert.True (view1.HasFocus);
+
+        top.Dispose ();
     }
 }