-
Notifications
You must be signed in to change notification settings - Fork 730
Fixes #4389 - Add comprehensive unit tests for WindowsKeyConverter #4390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: v2_develop
Are you sure you want to change the base?
Conversation
- Implement 118 parallelizable unit tests for WindowsKeyConverter - Cover ToKey and ToKeyInfo methods with full bidirectional testing - Test basic characters, modifiers, special keys, function keys - Test VK_PACKET Unicode/IME input - Test OEM keys, NumPad keys, and lock states - Include round-trip conversion tests - All tests passing successfully Fixes gui-cs#4389
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## v2_develop #4390 +/- ##
==============================================
- Coverage 74.56% 74.55% -0.01%
==============================================
Files 388 388
Lines 46568 46568
Branches 6548 6548
==============================================
- Hits 34723 34721 -2
- Misses 9993 9996 +3
+ Partials 1852 1851 -1
... and 2 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds comprehensive unit tests for the WindowsKeyConverter class, which handles bidirectional conversion between Windows native InputRecord format and Terminal.Gui's Key representation. The tests provide extensive coverage with 118 parallelizable test cases covering basic character keys, modifiers, special keys, Unicode/IME input, OEM keys, NumPad keys, function keys, scan codes, round-trip conversions, and lock state handling.
Key Changes:
- Added 118 parallelizable unit tests organized into 13 test categories
- Comprehensive testing of
ToKeyandToKeyInfoconversion methods - Full bidirectional round-trip conversion validation
Tests/UnitTestsParallelizable/Drivers/WindowsKeyConverterTests.cs
Outdated
Show resolved
Hide resolved
Tests/UnitTestsParallelizable/Drivers/WindowsKeyConverterTests.cs
Outdated
Show resolved
Hide resolved
VK_PACKET sends surrogate pairs (e.g., emoji) as two separate events. Current WindowsKeyConverter processes each independently without combining. Test documents this limitation for future fix at InputProcessor level.
Tests now skip on non-Windows platforms using SkipException in constructor. This prevents CI failures on macOS and Linux where Windows Console API is not available.
Created custom xUnit attributes SkipOnNonWindowsFact and SkipOnNonWindowsTheory that automatically skip tests on non-Windows platforms. This prevents CI failures on macOS and Linux.
Refactored `ApplicationImpl.cs` to simplify its structure by removing the `_stopAfterFirstIteration` field. Reintroduced and modernized test files with improved structure and coverage: - `NetInputProcessorTests.cs`: Added tests for `ConsoleKeyInfo` to `Rune`/`Key` conversion and queue processing. - `WindowSizeMonitorTests.cs`: Added tests for size change event handling. - `WindowsInputProcessorTests.cs`: Added tests for keyboard and mouse input processing, including mouse flag mapping. - `WindowsKeyConverterTests.cs`: Added comprehensive tests for `InputRecord` to `Key` conversion, covering OEM keys, modifiers, Unicode, and round-trip integrity. Improved test coverage for edge cases, introduced parameterized tests, and documented known limitations for future improvements.
Added [Trait('Platform', 'Windows')] and [Collection('Global Test Setup')] attributes. Tests will run on Windows but can be filtered in CI on other platforms using --filter 'Platform!=Windows' if needed. This approach doesn't interfere with GlobalTestSetup and works correctly with xUnit.
43b0373 to
8ebf25a
Compare
Added --filter 'Platform!=Windows' for Linux and macOS runners to exclude WindowsKeyConverterTests which require Windows Console APIs. Windows runner runs all tests normally.
Corrected a typo in the log directory path from `logs/UnitTestsParallelable/` to `logs/UnitTestsParallelizable/`. Removed the "Upload Parallelizable UnitTests Coverage to Codecov" step, which was conditional on `matrix.os == 'ubuntu-latest'` and used the `codecov/codecov-action@v4` action. This change improves log handling and removes the Codecov integration.
Summary
This PR adds comprehensive parallelizable unit tests for
WindowsKeyConverterto ensure proper keyboard input conversion between Windows nativeInputRecordformat and Terminal.Gui'sKeyrepresentation.Changes
Tests/UnitTestsParallelizable/Drivers/WindowsKeyConverterTests.csToKeyandToKeyInfomethodsTest Coverage
Test Categories (118 tests total)
ToKey Tests - Basic Characters (7 tests)
ToKey Tests - Modifiers (5 tests)
ToKey Tests - Special Keys (26 tests)
ToKey Tests - VK_PACKET (Unicode/IME) (7 tests)
ToKey Tests - OEM Keys (12 tests)
ToKey Tests - NumPad (9 tests)
ToKey Tests - Null/Empty (1 test)
ToKeyInfo Tests - Basic Keys (7 tests)
ToKeyInfo Tests - Special Keys (15 tests)
ToKeyInfo Tests - Modifiers (5 tests)
ToKeyInfo Tests - Scan Codes (8 tests)
Round-Trip Tests (13 tests)
CapsLock/NumLock Tests (2 tests)
Test Results
All 118 tests passing successfully: