mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
* Fixed MouseGrabView bug. Added extensive test coverage for `Keyboard`, `Mouse`, `Timeout`, and `Popover` functionalities, including edge cases and concurrent access. Introduced parameterized and data-driven tests to reduce redundancy and improve clarity. Refactored codebase for modularity and maintainability, introducing new namespaces and reorganizing classes. Enhanced `MouseImpl`, `KeyboardImpl`, and `Runnable` implementations with improved event handling, thread safety, and support for the Terminal.Gui Cancellable Work Pattern (CWP). Removed deprecated code and legacy tests, such as `LogarithmicTimeout` and `SmoothAcceleratingTimeout`. Fixed bugs related to mouse grabbing during drag operations and unbalanced `ApplicationImpl.Begin/End` calls. Improved documentation and code readability with modern C# features. * Code cleanup. * Update Tests/UnitTestsParallelizable/Application/Runnable/RunnableIntegrationTests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Improve null handling and simplify test setup In `MouseImpl.cs`, added an early `return` after the `UngrabMouse()` call within the `if (view is null)` block to prevent further execution when `view` is `null`, improving null reference handling. In `RunnableIntegrationTests.cs`, removed the initialization of the `IApplication` object (`app`) from the `MultipleRunnables_IndependentResults` test method, simplifying the test setup and focusing on runnable behavior. * Code cleanup * API doc link cleanup --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
66 lines
1.9 KiB
C#
66 lines
1.9 KiB
C#
namespace ApplicationTests.Popover;
|
|
|
|
public class PopoverBaseImplTests
|
|
{
|
|
// Minimal concrete implementation for testing
|
|
private class TestPopover : PopoverBaseImpl
|
|
{ }
|
|
|
|
[Fact]
|
|
public void Constructor_SetsDefaults ()
|
|
{
|
|
var popover = new TestPopover ();
|
|
|
|
Assert.Equal ("popoverBaseImpl", popover.Id);
|
|
Assert.True (popover.CanFocus);
|
|
Assert.Equal (Dim.Fill (), popover.Width);
|
|
Assert.Equal (Dim.Fill (), popover.Height);
|
|
Assert.True (popover.ViewportSettings.HasFlag (ViewportSettingsFlags.Transparent));
|
|
Assert.True (popover.ViewportSettings.HasFlag (ViewportSettingsFlags.TransparentMouse));
|
|
}
|
|
|
|
[Fact]
|
|
public void Runnable_Property_CanBeSetAndGet ()
|
|
{
|
|
var popover = new TestPopover ();
|
|
var top = new Runnable ();
|
|
popover.Current = top;
|
|
Assert.Same (top, popover.Current);
|
|
}
|
|
|
|
[Fact]
|
|
public void Show_ThrowsIfPopoverMissingRequiredFlags ()
|
|
{
|
|
var popover = new TestPopover ();
|
|
|
|
// Popover missing Transparent flags
|
|
popover.ViewportSettings = ViewportSettingsFlags.None; // Remove required flags
|
|
|
|
var popoverManager = new ApplicationPopover ();
|
|
|
|
// Test missing Transparent flags
|
|
Assert.ThrowsAny<Exception> (() => popoverManager.Show (popover));
|
|
}
|
|
|
|
[Fact]
|
|
public void Show_ThrowsIfPopoverMissingQuitCommand ()
|
|
{
|
|
var popover = new TestPopover ();
|
|
|
|
// Popover missing Command.Quit binding
|
|
popover.KeyBindings.Clear (); // Remove all key bindings
|
|
|
|
var popoverManager = new ApplicationPopover ();
|
|
Assert.ThrowsAny<Exception> (() => popoverManager.Show (popover));
|
|
}
|
|
|
|
[Fact]
|
|
public void Show_Throw_If_Not_Registered ()
|
|
{
|
|
var popover = new TestPopover ();
|
|
|
|
var popoverManager = new ApplicationPopover ();
|
|
Assert.Throws<InvalidOperationException> (() => popoverManager.Show (popover));
|
|
}
|
|
}
|