From ad23a100df95a87b4f93b7128edb94a94130f05c Mon Sep 17 00:00:00 2001 From: Tigger Kindel Date: Sat, 12 Aug 2023 10:27:01 -0600 Subject: [PATCH] fixed local test issue with curses --- .../ConsoleDrivers/CursesDriver/UnixMainLoop.cs | 4 ++++ Terminal.Gui/ConsoleDrivers/WindowsDriver.cs | 2 +- UnitTests/ConsoleDrivers/ColorTests.cs | 14 ++++---------- UnitTests/ConsoleDrivers/ConsoleDriverTests.cs | 1 + 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Terminal.Gui/ConsoleDrivers/CursesDriver/UnixMainLoop.cs b/Terminal.Gui/ConsoleDrivers/CursesDriver/UnixMainLoop.cs index 16006f39c..b9d70b0f0 100644 --- a/Terminal.Gui/ConsoleDrivers/CursesDriver/UnixMainLoop.cs +++ b/Terminal.Gui/ConsoleDrivers/CursesDriver/UnixMainLoop.cs @@ -98,6 +98,10 @@ namespace Terminal.Gui { void IMainLoopDriver.Setup (MainLoop mainLoop) { this.mainLoop = mainLoop; + if (ConsoleDriver.RunningUnitTests) { + return; + } + try { pipe (wakeupPipes); AddWatch (wakeupPipes [1], Condition.PollIn, ml => { diff --git a/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs b/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs index 6de41c1e1..6b2178a6a 100644 --- a/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs +++ b/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs @@ -1563,7 +1563,7 @@ internal class WindowsDriver : ConsoleDriver { Right = (short)Cols }; - if (WinConsole != null && !WinConsole.WriteToConsole (new Size (Cols, Rows), _outputBuffer, bufferCoords, _damageRegion, Force16Colors)) { + if (!RunningUnitTests && WinConsole != null && !WinConsole.WriteToConsole (new Size (Cols, Rows), _outputBuffer, bufferCoords, _damageRegion, Force16Colors)) { var err = Marshal.GetLastWin32Error (); if (err != 0) { throw new System.ComponentModel.Win32Exception (err); diff --git a/UnitTests/ConsoleDrivers/ColorTests.cs b/UnitTests/ConsoleDrivers/ColorTests.cs index 80c00b62b..e3757e030 100644 --- a/UnitTests/ConsoleDrivers/ColorTests.cs +++ b/UnitTests/ConsoleDrivers/ColorTests.cs @@ -5,18 +5,12 @@ using Xunit; using Console = Terminal.Gui.FakeConsole; namespace Terminal.Gui.DriverTests { - public class ColorTests: IDisposable - { + public class ColorTests { public ColorTests () { ConsoleDriver.RunningUnitTests = true; } - public void Dispose () - { - // ... clean up test data from the database ... - } - [Theory] [InlineData (typeof (FakeDriver))] [InlineData (typeof (NetDriver))] @@ -100,12 +94,12 @@ namespace Terminal.Gui.DriverTests { // Shutdown must be called to safely clean up Application if Init has been called Application.Shutdown (); } - + [Theory] [InlineData (typeof (FakeDriver))] [InlineData (typeof (NetDriver))] [InlineData (typeof (CursesDriver))] - [InlineData (typeof (WindowsDriver))] + [InlineData (typeof (WindowsDriver))] public void Force16Colors_Sets (Type driverType) { var driver = (ConsoleDriver)Activator.CreateInstance (driverType); @@ -113,7 +107,7 @@ namespace Terminal.Gui.DriverTests { driver.Force16Colors = true; Assert.True (driver.Force16Colors); - + driver.End (); // Shutdown must be called to safely clean up Application if Init has been called diff --git a/UnitTests/ConsoleDrivers/ConsoleDriverTests.cs b/UnitTests/ConsoleDrivers/ConsoleDriverTests.cs index 9779c79b4..dd52320b9 100644 --- a/UnitTests/ConsoleDrivers/ConsoleDriverTests.cs +++ b/UnitTests/ConsoleDrivers/ConsoleDriverTests.cs @@ -14,6 +14,7 @@ namespace Terminal.Gui.DriverTests { public ConsoleDriverTests (ITestOutputHelper output) { + ConsoleDriver.RunningUnitTests = true; this.output = output; }