diff --git a/UnitTests/Views/ColorPickerTests.cs b/UnitTests/Views/ColorPickerTests.cs index 2256c6ba2..a55c92b7c 100644 --- a/UnitTests/Views/ColorPickerTests.cs +++ b/UnitTests/Views/ColorPickerTests.cs @@ -1,4 +1,5 @@ -using Xunit.Abstractions; +using System.Reflection.Emit; +using Xunit.Abstractions; using Color = Terminal.Gui.Color; namespace Terminal.Gui.ViewsTests; @@ -692,6 +693,10 @@ public class ColorPickerTests public void ColorPicker_TabCompleteColorName () { var cp = GetColorPicker (ColorModel.RGB, true, true); + Application.Navigation = new (); + Application.Current = new (); + Application.Current.Add (cp); + cp.Draw (); var r = GetColorBar (cp, ColorPickerPart.Bar1); @@ -728,6 +733,7 @@ public class ColorPickerTests Assert.Equal ("#7FFFD4", hex.Text); Application.Current?.Dispose (); + Application.ResetState (); } [Fact] @@ -735,6 +741,10 @@ public class ColorPickerTests public void ColorPicker_EnterHexFor_ColorName () { var cp = GetColorPicker (ColorModel.RGB, true, true); + Application.Navigation = new (); + Application.Current = new (); + Application.Current.Add (cp); + cp.Draw (); var name = GetTextField (cp, ColorPickerPart.ColorName); @@ -777,6 +787,7 @@ public class ColorPickerTests Assert.Equal ("Aquamarine", name.Text); Application.Current?.Dispose (); + Application.ResetState (); } [Fact] diff --git a/UnitTests/Views/LabelTests.cs b/UnitTests/Views/LabelTests.cs index aa7f466b8..0ccf17d3a 100644 --- a/UnitTests/Views/LabelTests.cs +++ b/UnitTests/Views/LabelTests.cs @@ -1321,6 +1321,7 @@ e { Label label = new () { Text = "label" }; View view = new () { Text = "view", CanFocus = true }; + Application.Navigation = new (); Application.Current = new (); Application.Current.Add (label, view); diff --git a/docfx/docs/navigation.md b/docfx/docs/navigation.md index 64349b031..c68b56d61 100644 --- a/docfx/docs/navigation.md +++ b/docfx/docs/navigation.md @@ -98,7 +98,7 @@ Causes the focus to advance (forward or backwards) to the next View in the appli The implementation is simple: ```cs -return Application.GetFocused()?.AdvanceFocus (direction, behavior) ?? false; +return Application.Current?.AdvanceFocus (direction, behavior); ``` This method is called from the `Command` handlers bound to the application-scoped keybindings created during `Application.Init`. It is `public` as a convenience.