Unit tests

This commit is contained in:
Tigger Kindel
2023-08-11 12:57:15 -06:00
committed by Tig
parent a23a33f20c
commit 33befa249e
2 changed files with 17 additions and 11 deletions

View File

@@ -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 {
/// </remarks>
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);
}
}
/// <summary>
@@ -136,8 +140,9 @@ namespace Terminal.Gui {
/// </remarks>
public object AddWatch (int fileDescriptor, Condition condition, Func<MainLoop, bool> 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];

View File

@@ -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)
{