mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
WIP: Almost there!
Refactored tests and code to align with the modern instance-based application model. Key changes include: - Disabled Sixel rendering in `OutputBase.cs` due to dependency on legacy static `Application` object. - Hardcoded `force16Colors` to `false` in `WindowsOutput.cs` with a `BUGBUG` note. - Updated `ApplicationImplTests` to use `ApplicationImpl.SetInstance` and return `ApplicationImpl.Instance`. - Refactored `ApplicationModelFencingTests` to use `Application.Create()` and added `ResetModelUsageTracking()` for model switching. - Removed legacy `DriverTests` and reintroduced updated versions with cross-platform driver tests. - Reverted `ArrangementTests` and `ShortcutTests` to use legacy static `ApplicationImpl.Instance`. - Reintroduced driver tests in `DriverTests.cs` with modern `Application.Create()` and added `TestTop` for driver content verification. - General cleanup, including removal of outdated code and addition of `BUGBUG` notes for temporary workarounds.
This commit is contained in:
@@ -27,7 +27,9 @@ public class ApplicationImplTests
|
||||
m.Setup (f => f.CreateOutput ()).Returns (consoleOutput.Object);
|
||||
m.Setup (f => f.CreateSizeMonitor (It.IsAny<IOutput> (), It.IsAny<IOutputBuffer> ())).Returns (Mock.Of<ISizeMonitor> ());
|
||||
|
||||
return new ApplicationImpl (m.Object);
|
||||
// TODO: Move these tests to Parallelizable tests
|
||||
ApplicationImpl.SetInstance(new ApplicationImpl (m.Object));
|
||||
return ApplicationImpl.Instance;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -17,7 +17,7 @@ public class ApplicationModelFencingTests
|
||||
public void Create_ThenInstanceAccess_ThrowsInvalidOperationException ()
|
||||
{
|
||||
// Create a modern instance-based application
|
||||
IApplication app = ApplicationImpl.Instance; // Force legacy
|
||||
IApplication app = Application.Create ();
|
||||
app.Init ("fake");
|
||||
|
||||
// Attempting to initialize using the legacy static model should throw
|
||||
@@ -31,6 +31,8 @@ public class ApplicationModelFencingTests
|
||||
|
||||
// Clean up
|
||||
app.Shutdown ();
|
||||
ApplicationImpl.ResetModelUsageTracking ();
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -43,7 +45,7 @@ public class ApplicationModelFencingTests
|
||||
// Attempting to create and initialize with modern instance-based model should throw
|
||||
InvalidOperationException ex = Assert.Throws<InvalidOperationException> (() =>
|
||||
{
|
||||
IApplication app = ApplicationImpl.Instance; // Force legacy
|
||||
IApplication app = Application.Create ();
|
||||
app.Init ("fake");
|
||||
});
|
||||
|
||||
@@ -52,6 +54,7 @@ public class ApplicationModelFencingTests
|
||||
|
||||
// Clean up
|
||||
staticInstance.Shutdown ();
|
||||
ApplicationImpl.ResetModelUsageTracking ();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -72,13 +75,14 @@ public class ApplicationModelFencingTests
|
||||
|
||||
// Clean up
|
||||
staticInstance.Shutdown ();
|
||||
ApplicationImpl.ResetModelUsageTracking ();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Create_ThenInit_ThrowsInvalidOperationException ()
|
||||
{
|
||||
// Create a modern instance-based application
|
||||
IApplication app = ApplicationImpl.Instance; // Force legacy
|
||||
IApplication app = Application.Create ();
|
||||
app.Init ("fake");
|
||||
|
||||
// Attempting to initialize using the legacy static model should throw
|
||||
@@ -92,6 +96,7 @@ public class ApplicationModelFencingTests
|
||||
|
||||
// Clean up
|
||||
app.Shutdown ();
|
||||
ApplicationImpl.ResetModelUsageTracking ();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -110,6 +115,7 @@ public class ApplicationModelFencingTests
|
||||
app1.Shutdown ();
|
||||
app2.Shutdown ();
|
||||
app3.Shutdown ();
|
||||
ApplicationImpl.ResetModelUsageTracking ();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -126,6 +132,7 @@ public class ApplicationModelFencingTests
|
||||
|
||||
// Clean up
|
||||
instance1.Shutdown ();
|
||||
ApplicationImpl.ResetModelUsageTracking ();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -150,5 +157,6 @@ public class ApplicationModelFencingTests
|
||||
IApplication app2 = Application.Create ();
|
||||
Assert.NotNull (app2);
|
||||
app2.Shutdown ();
|
||||
ApplicationImpl.ResetModelUsageTracking ();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
#nullable enable
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace UnitTests.DriverTests;
|
||||
|
||||
public class DriverTests (ITestOutputHelper output)
|
||||
{
|
||||
private readonly ITestOutputHelper _output = output;
|
||||
|
||||
[Theory]
|
||||
[InlineData ("fake")]
|
||||
[InlineData ("windows")]
|
||||
[InlineData ("dotnet")]
|
||||
[InlineData ("unix")]
|
||||
public void All_Drivers_Init_Shutdown_Cross_Platform (string driverName)
|
||||
{
|
||||
IApplication? app = Application.Create ();
|
||||
app.Init (driverName);
|
||||
app.Shutdown ();
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData ("fake")]
|
||||
[InlineData ("windows")]
|
||||
[InlineData ("dotnet")]
|
||||
[InlineData ("unix")]
|
||||
public void All_Drivers_Run_Cross_Platform (string driverName)
|
||||
{
|
||||
IApplication? app = Application.Create ();
|
||||
app.Init (driverName);
|
||||
app.StopAfterFirstIteration = true;
|
||||
app.Run ().Dispose ();
|
||||
app.Shutdown ();
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData ("fake")]
|
||||
[InlineData ("windows")]
|
||||
[InlineData ("dotnet")]
|
||||
[InlineData ("unix")]
|
||||
public void All_Drivers_LayoutAndDraw_Cross_Platform (string driverName)
|
||||
{
|
||||
IApplication? app = Application.Create ();
|
||||
app.Init (driverName);
|
||||
app.StopAfterFirstIteration = true;
|
||||
app.Run<TestTop> ().Dispose ();
|
||||
|
||||
DriverAssert.AssertDriverContentsWithFrameAre (driverName!, _output, app.Driver);
|
||||
|
||||
app.Shutdown ();
|
||||
}
|
||||
}
|
||||
|
||||
public class TestTop : Toplevel
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override void BeginInit ()
|
||||
{
|
||||
Text = Driver!.GetName ()!;
|
||||
BorderStyle = LineStyle.None;
|
||||
base.BeginInit ();
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ public class ArrangementTests (ITestOutputHelper output)
|
||||
Width = 80,
|
||||
Height = 25
|
||||
};
|
||||
superView.App = Application.Create ();
|
||||
superView.App = ApplicationImpl.Instance;
|
||||
|
||||
var movableView = new View
|
||||
{
|
||||
@@ -82,7 +82,7 @@ public class ArrangementTests (ITestOutputHelper output)
|
||||
|
||||
var superView = new View
|
||||
{
|
||||
App = Application.Create (),
|
||||
App = ApplicationImpl.Instance,
|
||||
Width = 80,
|
||||
Height = 25
|
||||
};
|
||||
@@ -148,7 +148,7 @@ public class ArrangementTests (ITestOutputHelper output)
|
||||
// This test verifies MouseGrabHandler properly releases when switching between views
|
||||
|
||||
var superView = new View { Width = 80, Height = 25 };
|
||||
superView.App = Application.Create ();
|
||||
superView.App = ApplicationImpl.Instance;
|
||||
|
||||
var view1 = new View
|
||||
{
|
||||
|
||||
@@ -349,7 +349,7 @@ public class ShortcutTests
|
||||
[InlineData (KeyCode.F1, 0)]
|
||||
public void KeyDown_App_Scope_Invokes_Accept (KeyCode key, int expectedAccept)
|
||||
{
|
||||
Application.TopRunnable = new () { App = Application.Create () };
|
||||
Application.TopRunnable = new () { App = ApplicationImpl.Instance };
|
||||
|
||||
var shortcut = new Shortcut
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user