From 33befa249e9c138a9973aa06d264298d565d54ac Mon Sep 17 00:00:00 2001 From: Tigger Kindel Date: Fri, 11 Aug 2023 12:57:15 -0600 Subject: [PATCH] Unit tests --- .../CursesDriver/UnixMainLoop.cs | 22 ++++++++++++------- UnitTests/ConsoleDrivers/ColorTests.cs | 6 ++--- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/Terminal.Gui/ConsoleDrivers/CursesDriver/UnixMainLoop.cs b/Terminal.Gui/ConsoleDrivers/CursesDriver/UnixMainLoop.cs index 3aeb1b3f8..1bad4a24a 100644 --- a/Terminal.Gui/ConsoleDrivers/CursesDriver/UnixMainLoop.cs +++ b/Terminal.Gui/ConsoleDrivers/CursesDriver/UnixMainLoop.cs @@ -87,12 +87,14 @@ namespace Terminal.Gui { bool winChanged; bool _runningUnitTests = false; - + public Action WinChanged; void IMainLoopDriver.Wakeup () { - write (wakeupPipes [1], ignore, (IntPtr)1); + if (!_runningUnitTests) { + write (wakeupPipes [1], ignore, (IntPtr)1); + } } void IMainLoopDriver.Setup (MainLoop mainLoop) @@ -117,10 +119,12 @@ namespace Terminal.Gui { /// public void RemoveWatch (object token) { - var watch = token as Watch; - if (watch == null) - return; - descriptorWatchers.Remove (watch.File); + if (!_runningUnitTests) { + var watch = token as Watch; + if (watch == null) + return; + descriptorWatchers.Remove (watch.File); + } } /// @@ -136,8 +140,9 @@ namespace Terminal.Gui { /// public object AddWatch (int fileDescriptor, Condition condition, Func callback) { - if (callback == null) + if (callback == null) { throw new ArgumentNullException (nameof (callback)); + } var watch = new Watch () { Condition = condition, Callback = callback, File = fileDescriptor }; descriptorWatchers [fileDescriptor] = watch; @@ -147,8 +152,9 @@ namespace Terminal.Gui { void UpdatePollMap () { - if (!poll_dirty) + if (!poll_dirty) { return; + } poll_dirty = false; pollmap = new Pollfd [descriptorWatchers.Count]; diff --git a/UnitTests/ConsoleDrivers/ColorTests.cs b/UnitTests/ConsoleDrivers/ColorTests.cs index 73afd090c..966091f4c 100644 --- a/UnitTests/ConsoleDrivers/ColorTests.cs +++ b/UnitTests/ConsoleDrivers/ColorTests.cs @@ -90,11 +90,11 @@ namespace Terminal.Gui.DriverTests { // Shutdown must be called to safely clean up Application if Init has been called Application.Shutdown (); } - + [Theory] - [InlineData (typeof (FakeDriver), false)] + [InlineData (typeof (FakeDriver), true)] [InlineData (typeof (NetDriver), false)] - [InlineData (typeof (CursesDriver), false)] + [InlineData (typeof (CursesDriver), true)] [InlineData (typeof (WindowsDriver), false)] public void Force16Colors_Sets (Type driverType, bool expectedSetting) {