mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
* Implement Unix driver
* Add more sequences related with macOS
* Helper method to map char to control keys
* Add DriverName property
* Fix error on Unix unit tests
* Fix Non-nullable property 'DriverName' must contain a non-null value when exiting constructor.
* Fix Ctrl being ignored in the range \u0001-\u001a
* Add unit test for the MapChar method
* Fix cursor visibility and cursor styles
* Avoid sometimes error when running gnome-terminal
* Captures Ctrl+Shift+Alt+D7
* Captures Ctrl+D4, Ctrl+D5, Ctrl+D6 and Ctrl+D7
* Add unit test for Ctrl+Shift+Alt+7
* Fix issue on Windows where sending AltGr+some key fail assertion
* Exclude Oem1 from assertion
* Fix regex pattern
* Remove driverName from the constructor
* Revert "Remove driverName from the constructor"
This reverts commit 004e9f9588.
* Remove driverName from the constructor
* Add generic CreateSubcomponents method avoiding redundancy
* Add v2unix profiles
* Replace with hexadecimal values
---------
Co-authored-by: Tig <tig@users.noreply.github.com>
130 lines
4.1 KiB
C#
130 lines
4.1 KiB
C#
// Alias Console to MockConsole so we don't accidentally use Console
|
|
|
|
using UnitTests;
|
|
|
|
namespace Terminal.Gui.ApplicationTests;
|
|
|
|
public class SyncrhonizationContextTests
|
|
{
|
|
[Fact]
|
|
public void SynchronizationContext_CreateCopy ()
|
|
{
|
|
ConsoleDriver.RunningUnitTests = true;
|
|
Application.Init ();
|
|
SynchronizationContext context = SynchronizationContext.Current;
|
|
Assert.NotNull (context);
|
|
|
|
SynchronizationContext contextCopy = context.CreateCopy ();
|
|
Assert.NotNull (contextCopy);
|
|
|
|
Assert.NotEqual (context, contextCopy);
|
|
Application.Shutdown ();
|
|
}
|
|
|
|
private object _lockPost = new ();
|
|
|
|
[Theory]
|
|
[InlineData (typeof (FakeDriver))]
|
|
[InlineData (typeof (NetDriver))]
|
|
[InlineData (typeof (WindowsDriver))]
|
|
[InlineData (typeof (CursesDriver))]
|
|
[InlineData (typeof (ConsoleDriverFacade<WindowsConsole.InputRecord>), "v2win")]
|
|
[InlineData (typeof (ConsoleDriverFacade<ConsoleKeyInfo>), "v2net")]
|
|
[InlineData (typeof (ConsoleDriverFacade<char>), "v2unix")]
|
|
public void SynchronizationContext_Post (Type driverType, string driverName = null)
|
|
{
|
|
lock (_lockPost)
|
|
{
|
|
ConsoleDriver.RunningUnitTests = true;
|
|
|
|
if (driverType.Name.Contains ("ConsoleDriverFacade"))
|
|
{
|
|
Application.Init (driverName: driverName);
|
|
}
|
|
else
|
|
{
|
|
Application.Init (driverName: driverType.Name);
|
|
}
|
|
|
|
SynchronizationContext context = SynchronizationContext.Current;
|
|
|
|
var success = false;
|
|
|
|
Task.Run (() =>
|
|
{
|
|
while (Application.Top is null || Application.Top is { Running: false })
|
|
{
|
|
Thread.Sleep (500);
|
|
}
|
|
|
|
// non blocking
|
|
context.Post (
|
|
delegate
|
|
{
|
|
success = true;
|
|
|
|
// then tell the application to quit
|
|
Application.Invoke (() => Application.RequestStop ());
|
|
},
|
|
null
|
|
);
|
|
|
|
if (Application.Top is { Running: true })
|
|
{
|
|
Assert.False (success);
|
|
}
|
|
}
|
|
);
|
|
|
|
// blocks here until the RequestStop is processed at the end of the test
|
|
Application.Run ().Dispose ();
|
|
Assert.True (success);
|
|
|
|
if (ApplicationImpl.Instance is ApplicationV2)
|
|
{
|
|
ApplicationImpl.Instance.Shutdown ();
|
|
}
|
|
else
|
|
{
|
|
Application.Shutdown ();
|
|
}
|
|
}
|
|
}
|
|
|
|
[Fact]
|
|
[AutoInitShutdown]
|
|
public void SynchronizationContext_Send ()
|
|
{
|
|
ConsoleDriver.RunningUnitTests = true;
|
|
Application.Init ();
|
|
SynchronizationContext context = SynchronizationContext.Current;
|
|
|
|
var success = false;
|
|
|
|
Task.Run (
|
|
() =>
|
|
{
|
|
Thread.Sleep (500);
|
|
|
|
// blocking
|
|
context.Send (
|
|
delegate
|
|
{
|
|
success = true;
|
|
|
|
// then tell the application to quit
|
|
Application.Invoke (() => Application.RequestStop ());
|
|
},
|
|
null
|
|
);
|
|
Assert.True (success);
|
|
}
|
|
);
|
|
|
|
// blocks here until the RequestStop is processed at the end of the test
|
|
Application.Run ().Dispose ();
|
|
Assert.True (success);
|
|
Application.Shutdown ();
|
|
}
|
|
}
|