Fixed ApplicatonTests.
This commit is contained in:
Tig
2024-05-30 06:21:19 -06:00
7 changed files with 37 additions and 7 deletions

View File

@@ -40,10 +40,12 @@ public class ApplicationTests
public void Begin_Sets_Application_Top_To_Console_Size ()
{
Assert.Null (Application.Top);
Application.Begin (new ());
Toplevel top = new ();
Application.Begin (top);
Assert.Equal (new (0, 0, 80, 25), Application.Top.Frame);
((FakeDriver)Application.Driver).SetBufferSize (5, 5);
Assert.Equal (new (0, 0, 5, 5), Application.Top.Frame);
top.Dispose ();
}
[Fact]
@@ -347,6 +349,7 @@ public class ApplicationTests
Assert.Null (Application.MouseGrabView); // public
Assert.Null (Application.WantContinuousButtonPressedView); // public
Assert.False (Application.MoveToOverlappedChild (Application.Top));
Application.Top.Dispose ();
}
// Invoke Tests

View File

@@ -172,6 +172,7 @@ public class KeyboardTests
Assert.True (win2.CanFocus);
Assert.True (win2.HasFocus);
Assert.Equal ("win2", ((Window)top.Subviews [^1]).Title);
top.Dispose ();
}
[Fact]
@@ -224,6 +225,7 @@ public class KeyboardTests
Assert.True (win2.CanFocus);
Assert.False (win2.HasFocus);
Assert.Equal ("win", ((Window)top.Subviews [^1]).Title);
top.Dispose ();
}
[Fact]
@@ -358,6 +360,7 @@ public class KeyboardTests
Assert.True (view.ApplicationCommand);
Assert.True (view.HotKeyCommand);
Assert.False (view.FocusedCommand);
top.Dispose ();
}
[Fact]
@@ -385,6 +388,7 @@ public class KeyboardTests
Assert.False (view.ApplicationCommand);
Assert.False (view.HotKeyCommand);
Assert.False (view.FocusedCommand);
top.Dispose ();
}
[Fact]
@@ -423,6 +427,7 @@ public class KeyboardTests
// Reset the QuitKey to avoid throws errors on another tests
Application.QuitKey = Key.Q.WithCtrl;
top.Dispose ();
}
// test Application key Bindings

View File

@@ -640,6 +640,7 @@ public class MainLoopTests
await task; // Propagate exception if any occurred
Assert.Equal (numIncrements * numPasses, tbCounter);
top.Dispose ();
}
[Theory]
@@ -714,6 +715,7 @@ public class MainLoopTests
};
Application.Run (top);
top.Dispose ();
Assert.True (taskCompleted);
Assert.Equal (clickMe, btn.Text);

View File

@@ -130,6 +130,7 @@ public class MouseTests
Application.OnMouseEvent (mouseEvent);
Assert.Equal (expectedClicked, clicked);
top.Dispose ();
}
/// <summary>
@@ -224,6 +225,7 @@ public class MouseTests
Application.OnMouseEvent (mouseEvent);
Assert.Equal (expectedClicked, clicked);
top.Dispose ();
}
#endregion mouse coordinate tests
@@ -290,6 +292,7 @@ public class MouseTests
};
Application.Run (top);
top.Dispose ();
}
[Fact]
@@ -396,6 +399,7 @@ public class MouseTests
Application.OnMouseEvent (new () { Position = new (0, 0), Flags = MouseFlags.Button1Pressed });
Assert.Null (Application.MouseGrabView);
Assert.Equal (0, count);
top.Dispose ();
}
#endregion
}

View File

@@ -77,7 +77,7 @@ public class AutoInitShutdownAttribute : BeforeAfterTestAttribute
if (AutoInit)
{
// TODO: This Dispose call is here until all unit tests that don't correctly dispose Toplevel's they create are fixed.
Application.Top?.Dispose ();
//Application.Top?.Dispose ();
Application.Shutdown ();
#if DEBUG_IDISPOSABLE
if (Responder.Instances.Count == 0)