Fixes #4456 - Clear MouseGrabView in App.End (#4460)

* 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>
This commit is contained in:
Tig
2025-12-07 13:01:19 -07:00
committed by GitHub
parent 0270183686
commit 5da7e59aa2
32 changed files with 791 additions and 768 deletions

View File

@@ -1,7 +1,7 @@
using Terminal.Gui.App;
using Xunit.Abstractions;
namespace ApplicationTests;
namespace ApplicationTests.Mouse;
/// <summary>
/// Parallelizable tests for mouse event routing and coordinate transformation.
@@ -283,10 +283,10 @@ public class MouseEventRoutingTests (ITestOutputHelper output)
#region Mouse Button Events
[Theory]
[InlineData (MouseFlags.Button1Pressed, 1, 0, 0)]
[InlineData (MouseFlags.Button1Released, 0, 1, 0)]
[InlineData (MouseFlags.Button1Clicked, 0, 0, 1)]
public void View_MouseButtonEvents_RaiseCorrectHandlers (MouseFlags flags, int expectedPressed, int expectedReleased, int expectedClicked)
[InlineData (MouseFlags.Button1Pressed, 1, 0)]
[InlineData (MouseFlags.Button1Released, 0, 1)]
[InlineData (MouseFlags.Button1Clicked, 0, 0)]
public void View_MouseButtonEvents_RaiseCorrectHandlers (MouseFlags flags, int expectedPressed, int expectedReleased)
{
// Arrange
View view = new () { Width = 10, Height = 10 };