mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
Fixed netdriver running in unit tests
This commit is contained in:
@@ -572,14 +572,16 @@ internal class NetDriver : ConsoleDriver {
|
||||
}
|
||||
|
||||
StopReportingMouseMoves ();
|
||||
Console.ResetColor ();
|
||||
|
||||
//Disable alternative screen buffer.
|
||||
Console.Out.Write (EscSeqUtils.CSI_RestoreCursorAndActivateAltBufferWithBackscroll);
|
||||
if (!_runningUnitTests) {
|
||||
Console.ResetColor ();
|
||||
|
||||
//Set cursor key to cursor.
|
||||
Console.Out.Write (EscSeqUtils.CSI_ShowCursor);
|
||||
//Disable alternative screen buffer.
|
||||
Console.Out.Write (EscSeqUtils.CSI_RestoreCursorAndActivateAltBufferWithBackscroll);
|
||||
|
||||
//Set cursor key to cursor.
|
||||
Console.Out.Write (EscSeqUtils.CSI_ShowCursor);
|
||||
}
|
||||
Console.Out.Close ();
|
||||
}
|
||||
|
||||
@@ -608,13 +610,13 @@ internal class NetDriver : ConsoleDriver {
|
||||
|
||||
TerminalResized = terminalResized;
|
||||
|
||||
//Enable alternative screen buffer.
|
||||
Console.Out.Write (EscSeqUtils.CSI_SaveCursorAndActivateAltBufferNoBackscroll);
|
||||
|
||||
//Set cursor key to application.
|
||||
Console.Out.Write (EscSeqUtils.CSI_HideCursor);
|
||||
|
||||
try {
|
||||
//Enable alternative screen buffer.
|
||||
Console.Out.Write (EscSeqUtils.CSI_SaveCursorAndActivateAltBufferNoBackscroll);
|
||||
|
||||
//Set cursor key to application.
|
||||
Console.Out.Write (EscSeqUtils.CSI_HideCursor);
|
||||
|
||||
Console.TreatControlCAsInput = true;
|
||||
Cols = Console.WindowWidth;
|
||||
Rows = Console.WindowHeight;
|
||||
|
||||
@@ -834,7 +834,7 @@ internal class WindowsDriver : ConsoleDriver {
|
||||
Cols = e.Width;
|
||||
Rows = e.Height;
|
||||
|
||||
if (WinConsole != null) {
|
||||
if (!_runningUnitTests) {
|
||||
var newSize = WinConsole.SetConsoleWindow (
|
||||
(short)Math.Max (w, 16), (short)Math.Max (e.Height, 0));
|
||||
|
||||
@@ -1447,6 +1447,8 @@ internal class WindowsDriver : ConsoleDriver {
|
||||
return base.IsRuneSupported (rune) && rune.IsBmp;
|
||||
}
|
||||
|
||||
bool _runningUnitTests = false;
|
||||
|
||||
public override void Init (Action terminalResized)
|
||||
{
|
||||
TerminalResized = terminalResized;
|
||||
@@ -1472,7 +1474,9 @@ internal class WindowsDriver : ConsoleDriver {
|
||||
Console.Out.Write (EscSeqUtils.CSI_SaveCursorAndActivateAltBufferNoBackscroll);
|
||||
}
|
||||
} catch (Win32Exception e) {
|
||||
// Likely running unit tests. Set WinConsole to null so we can test it elsewhere.
|
||||
// We are being run in an environment that does not support a console
|
||||
// such as a unit test, or a pipe.
|
||||
_runningUnitTests = true;
|
||||
Debug.WriteLine ($"Likely running unit tests. Setting WinConsole to null so we can test it elsewhere. Exception: {e}");
|
||||
WinConsole = null;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Terminal.Gui.DriverTests {
|
||||
{
|
||||
var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
|
||||
Application.Init (driver);
|
||||
// driver.Init (() => { });
|
||||
|
||||
Assert.Equal (ConsoleColor.Gray, Console.ForegroundColor);
|
||||
Assert.Equal (ConsoleColor.Black, Console.BackgroundColor);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user