Rename IApplication.Current to TopRunnable

Co-authored-by: tig <585482+tig@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-11-20 19:34:48 +00:00
parent 16b42e86fd
commit 4b975fd5b7
90 changed files with 916 additions and 820 deletions

View File

@@ -14,14 +14,14 @@ public class AdornmentSubViewTests (ITestOutputHelper output)
[InlineData (2, 1, true)]
public void Adornment_WithSubView_Finds (int viewMargin, int subViewMargin, bool expectedFound)
{
Application.Current = new Toplevel()
Application.TopRunnable = new Toplevel()
{
Width = 10,
Height = 10
};
Application.Current.Margin!.Thickness = new Thickness (viewMargin);
Application.TopRunnable.Margin!.Thickness = new Thickness (viewMargin);
// Turn of TransparentMouse for the test
Application.Current.Margin!.ViewportSettings = ViewportSettingsFlags.None;
Application.TopRunnable.Margin!.ViewportSettings = ViewportSettingsFlags.None;
var subView = new View ()
{
@@ -34,26 +34,26 @@ public class AdornmentSubViewTests (ITestOutputHelper output)
// Turn of TransparentMouse for the test
subView.Margin!.ViewportSettings = ViewportSettingsFlags.None;
Application.Current.Margin!.Add (subView);
Application.Current.Layout ();
Application.TopRunnable.Margin!.Add (subView);
Application.TopRunnable.Layout ();
var foundView = Application.Current.GetViewsUnderLocation (new Point(0, 0), ViewportSettingsFlags.None).LastOrDefault ();
var foundView = Application.TopRunnable.GetViewsUnderLocation (new Point(0, 0), ViewportSettingsFlags.None).LastOrDefault ();
bool found = foundView == subView || foundView == subView.Margin;
Assert.Equal (expectedFound, found);
Application.Current.Dispose ();
Application.TopRunnable.Dispose ();
Application.ResetState (ignoreDisposed: true);
}
[Fact]
public void Adornment_WithNonVisibleSubView_Finds_Adornment ()
{
Application.Current = new Toplevel ()
Application.TopRunnable = new Toplevel ()
{
Width = 10,
Height = 10
};
Application.Current.Padding.Thickness = new Thickness (1);
Application.TopRunnable.Padding.Thickness = new Thickness (1);
var subView = new View ()
{
@@ -63,11 +63,11 @@ public class AdornmentSubViewTests (ITestOutputHelper output)
Height = 1,
Visible = false
};
Application.Current.Padding.Add (subView);
Application.Current.Layout ();
Application.TopRunnable.Padding.Add (subView);
Application.TopRunnable.Layout ();
Assert.Equal (Application.Current.Padding, Application.Current.GetViewsUnderLocation (new Point(0, 0), ViewportSettingsFlags.None).LastOrDefault ());
Application.Current?.Dispose ();
Assert.Equal (Application.TopRunnable.Padding, Application.TopRunnable.GetViewsUnderLocation (new Point(0, 0), ViewportSettingsFlags.None).LastOrDefault ());
Application.TopRunnable?.Dispose ();
Application.ResetState (ignoreDisposed: true);
}
}

View File

@@ -15,27 +15,27 @@ public class MarginTests (ITestOutputHelper output)
view.Margin!.Diagnostics = ViewDiagnosticFlags.Thickness;
view.Margin.Thickness = new (1);
Application.Current = new Toplevel ();
Application.SessionStack.Push (Application.Current);
Application.TopRunnable = new Toplevel ();
Application.SessionStack.Push (Application.TopRunnable);
Application.Current.SetScheme (new()
Application.TopRunnable.SetScheme (new()
{
Normal = new (Color.Red, Color.Green), Focus = new (Color.Green, Color.Red)
});
Application.Current.Add (view);
Application.TopRunnable.Add (view);
Assert.Equal (ColorName16.Red, view.Margin.GetAttributeForRole (VisualRole.Normal).Foreground.GetClosestNamedColor16 ());
Assert.Equal (ColorName16.Red, Application.Current.GetAttributeForRole (VisualRole.Normal).Foreground.GetClosestNamedColor16 ());
Assert.Equal (ColorName16.Red, Application.TopRunnable.GetAttributeForRole (VisualRole.Normal).Foreground.GetClosestNamedColor16 ());
Application.Current.BeginInit ();
Application.Current.EndInit ();
Application.TopRunnable.BeginInit ();
Application.TopRunnable.EndInit ();
Application.LayoutAndDraw();
DriverAssert.AssertDriverContentsAre (
@"",
output
);
DriverAssert.AssertDriverAttributesAre ("0", output, null, Application.Current.GetAttributeForRole (VisualRole.Normal));
DriverAssert.AssertDriverAttributesAre ("0", output, null, Application.TopRunnable.GetAttributeForRole (VisualRole.Normal));
Application.ResetState (true);
}
@@ -51,20 +51,20 @@ public class MarginTests (ITestOutputHelper output)
view.Margin.Thickness = new (1);
view.Margin.ViewportSettings = ViewportSettingsFlags.None;
Application.Current = new Toplevel ();
Application.SessionStack.Push (Application.Current);
Application.TopRunnable = new Toplevel ();
Application.SessionStack.Push (Application.TopRunnable);
Application.Current.SetScheme (new ()
Application.TopRunnable.SetScheme (new ()
{
Normal = new (Color.Red, Color.Green), Focus = new (Color.Green, Color.Red)
});
Application.Current.Add (view);
Application.TopRunnable.Add (view);
Assert.Equal (ColorName16.Red, view.Margin.GetAttributeForRole (VisualRole.Normal).Foreground.GetClosestNamedColor16 ());
Assert.Equal (ColorName16.Red, Application.Current.GetAttributeForRole (VisualRole.Normal).Foreground.GetClosestNamedColor16 ());
Assert.Equal (ColorName16.Red, Application.TopRunnable.GetAttributeForRole (VisualRole.Normal).Foreground.GetClosestNamedColor16 ());
Application.Current.BeginInit ();
Application.Current.EndInit ();
Application.TopRunnable.BeginInit ();
Application.TopRunnable.EndInit ();
Application.LayoutAndDraw ();
DriverAssert.AssertDriverContentsAre (
@@ -74,7 +74,7 @@ M M
MMM",
output
);
DriverAssert.AssertDriverAttributesAre ("0", output, null, Application.Current.GetAttributeForRole (VisualRole.Normal));
DriverAssert.AssertDriverAttributesAre ("0", output, null, Application.TopRunnable.GetAttributeForRole (VisualRole.Normal));
Application.ResetState (true);
}