mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
* Initial plan * Phase 1: Update IConsoleDriver.Init() to return void instead of MainLoop Co-authored-by: tig <585482+tig@users.noreply.github.com> * Phase 2: Remove legacy MainLoop infrastructure Co-authored-by: tig <585482+tig@users.noreply.github.com> * Complete Phase 1 and Phase 2 - All tests pass Co-authored-by: tig <585482+tig@users.noreply.github.com> * Update deep dive docs to reflect MainLoop removal Co-authored-by: tig <585482+tig@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tig <585482+tig@users.noreply.github.com> Co-authored-by: Tig <tig@users.noreply.github.com>
66 lines
1.9 KiB
C#
66 lines
1.9 KiB
C#
using System.Reflection;
|
|
using UnitTests;
|
|
using Xunit.Abstractions;
|
|
|
|
namespace UnitTests.ViewsTests;
|
|
|
|
public class AllViewsTests (ITestOutputHelper output) : TestsAllViews
|
|
{
|
|
// TODO: Update all these tests to use AllViews like AllViews_Center_Properly does
|
|
|
|
[Theory]
|
|
[MemberData (nameof (AllViewTypes))]
|
|
[SetupFakeDriver] // Required for spinner view that wants to register timeouts
|
|
public void AllViews_Center_Properly (Type viewType)
|
|
{
|
|
// Required for spinner view that wants to register timeouts
|
|
|
|
var view = CreateInstanceIfNotGeneric (viewType);
|
|
|
|
// See https://github.com/gui-cs/Terminal.Gui/issues/3156
|
|
|
|
if (view == null)
|
|
{
|
|
output.WriteLine ($"Ignoring {viewType} - It's a Generic");
|
|
Application.Shutdown ();
|
|
|
|
return;
|
|
}
|
|
|
|
if (view is IDesignable designable)
|
|
{
|
|
designable.EnableForDesign ();
|
|
}
|
|
|
|
view.X = Pos.Center ();
|
|
view.Y = Pos.Center ();
|
|
|
|
// Ensure the view has positive dimensions
|
|
view.Width = 10;
|
|
view.Height = 10;
|
|
|
|
var frame = new View { X = 0, Y = 0, Width = 50, Height = 50 };
|
|
frame.Add (view);
|
|
frame.BeginInit ();
|
|
frame.EndInit ();
|
|
frame.LayoutSubViews ();
|
|
frame.Dispose ();
|
|
Application.Shutdown ();
|
|
|
|
// What's the natural width/height?
|
|
int expectedX = (frame.Frame.Width - view.Frame.Width) / 2;
|
|
int expectedY = (frame.Frame.Height - view.Frame.Height) / 2;
|
|
|
|
Assert.True (
|
|
view.Frame.Left == expectedX,
|
|
$"{view} did not center horizontally. Expected: {expectedX}. Actual: {view.Frame.Left}"
|
|
);
|
|
|
|
Assert.True (
|
|
view.Frame.Top == expectedY,
|
|
$"{view} did not center vertically. Expected: {expectedY}. Actual: {view.Frame.Top}"
|
|
);
|
|
}
|
|
|
|
}
|