Add 340 C++ MSTest tests across 10 modules#46905
Add 340 C++ MSTest tests across 10 modules#46905crutkas wants to merge 11 commits intomicrosoft:mainfrom
Conversation
New test coverage for untested areas, discovered via test-first Rust porting methodology. All tests are pure C++ MSTest — no Rust dependency required. ## New Test Files (155 TEST_METHODs total) ### FancyZones — RustPortedTests.Spec.cpp (85 tests) - Layout calculations: columns, rows, grid, priority grid, focus - Keyboard snap: index-based navigation, position-based, extend selection - Data structures: AppliedLayouts, CustomLayouts, LayoutHotkeys JSON parsing - Device ID parsing: valid/invalid formats, serial numbers - Engine lifecycle: drag start/move/end, cancel, shift-drag ### Runner — HotkeyConflictTests.cpp (15 tests) - Handle hashing: same/different hotkeys - Conflict detection: empty, cross-module, same-module - Module lifecycle: add/remove/enable/disable - System vs in-app priority - JSON serialization ### CursorWrap — TopologyTests.cpp (16 tests) - Monitor layouts: single, side-by-side, stacked, L-shaped - Edge adjacency: within/beyond 50px tolerance - Wrap destinations: coordinate preservation - WrapMode filtering: HorizontalOnly, VerticalOnly, Both - Direction prioritization at corners ### MouseHighlighter — HighlighterTests.cpp (14 tests) - Click colors: left=yellow, right=blue - Fade timing: delay holds opacity, duration fades to zero - Alpha=0 disables button highlight - Cleanup removes expired highlights ### MousePointerCrosshairs — CrosshairsTests.cpp (25 tests) - Line layout: center, near-edge, corners - Fixed length mode - Orientation: Both, VerticalOnly, HorizontalOnly - Radius gap around cursor - Opacity conversion ## Spelling Fixes - expect.txt: 17 new technical terms - code.txt: 25 new code-related terms, alphabetized - excludes.txt: .rustc_info.json pattern Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Create NativeUnitTestProject DLL projects for: - Runner HotkeyConflictTests (src/runner/UnitTests/UnitTests-Runner.vcxproj) - CursorWrap TopologyTests (src/modules/MouseUtils/CursorWrap/UnitTests/UnitTests-CursorWrap.vcxproj) - MouseHighlighter HighlighterTests (src/modules/MouseUtils/MouseHighlighter/UnitTests/UnitTests-MouseHighlighter.vcxproj) - MousePointerCrosshairs CrosshairsTests (src/modules/MouseUtils/MousePointerCrosshairs/UnitTests/UnitTests-Crosshairs.vcxproj) Each project follows the UnitTests-CommonLib pattern with: - DynamicLibrary configuration for MSTest native test DLLs - NativeUnitTestProject subtype - CppUnitTestFramework reference via UnitTest lib paths - Precompiled headers (pch.h/pch.cpp) - Proper include directories for module headers and common libs Move test .cpp files into UnitTests/ subdirectories, add all projects to PowerToys.slnx, and fix code analysis warnings (C26451 overflow, C26497 constexpr, C4189 unused variable). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
src/modules/MouseUtils/MousePointerCrosshairs/UnitTests/CrosshairsTests.cpp
Fixed
Show fixed
Hide fixed
src/modules/MouseUtils/MousePointerCrosshairs/UnitTests/CrosshairsTests.cpp
Fixed
Show fixed
Hide fixed
src/modules/MouseUtils/MousePointerCrosshairs/UnitTests/CrosshairsTests.cpp
Fixed
Show fixed
Hide fixed
src/modules/MouseUtils/MousePointerCrosshairs/UnitTests/CrosshairsTests.cpp
Fixed
Show fixed
Hide fixed
src/modules/MouseUtils/MousePointerCrosshairs/UnitTests/CrosshairsTests.cpp
Fixed
Show fixed
Hide fixed
src/modules/MouseUtils/MousePointerCrosshairs/UnitTests/CrosshairsTests.cpp
Fixed
Show fixed
Hide fixed
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
Adds new native C++ MSTest projects and test suites to increase unit test coverage across Runner and several PowerToys modules (FancyZones, CursorWrap, MouseHighlighter, MousePointerCrosshairs), largely by porting logic-focused tests from corresponding Rust implementations.
Changes:
- Introduces new native unit test projects for Runner, CursorWrap, MouseHighlighter, and MousePointerCrosshairs and wires them into the solution.
- Adds substantial new C++ MSTest suites for FancyZones (ported Rust tests) and new logic tests for Runner hotkey conflict detection and MouseUtils modules.
- Adds per-project PCH + NuGet restore configuration for the new native test projects.
Reviewed changes
Copilot reviewed 27 out of 27 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| src/runner/UnitTests/UnitTests-Runner.vcxproj.filters | Adds filters entries for the new Runner unit test project sources/headers. |
| src/runner/UnitTests/UnitTests-Runner.vcxproj | Adds a new native unit test project for Runner hotkey conflict detection. |
| src/runner/UnitTests/pch.h | Runner unit test PCH intended to mirror Runner includes for shared compilation. |
| src/runner/UnitTests/pch.cpp | PCH TU for Runner unit test project. |
| src/runner/UnitTests/HotkeyConflictTests.cpp | Adds unit tests for HotkeyConflictManager behavior and JSON output. |
| src/modules/MouseUtils/MousePointerCrosshairs/UnitTests/UnitTests-Crosshairs.vcxproj.filters | Adds filters entries for Crosshairs unit test project. |
| src/modules/MouseUtils/MousePointerCrosshairs/UnitTests/UnitTests-Crosshairs.vcxproj | Adds a new native unit test project for Crosshairs. |
| src/modules/MouseUtils/MousePointerCrosshairs/UnitTests/pch.h | PCH for Crosshairs unit test project. |
| src/modules/MouseUtils/MousePointerCrosshairs/UnitTests/pch.cpp | PCH TU for Crosshairs unit test project. |
| src/modules/MouseUtils/MousePointerCrosshairs/UnitTests/packages.config | NuGet restore config for Crosshairs unit test project. |
| src/modules/MouseUtils/MousePointerCrosshairs/UnitTests/CrosshairsTests.cpp | Adds unit tests for crosshair settings defaults and geometry math. |
| src/modules/MouseUtils/MouseHighlighter/UnitTests/UnitTests-MouseHighlighter.vcxproj.filters | Adds filters entries for MouseHighlighter unit test project. |
| src/modules/MouseUtils/MouseHighlighter/UnitTests/UnitTests-MouseHighlighter.vcxproj | Adds a new native unit test project for MouseHighlighter. |
| src/modules/MouseUtils/MouseHighlighter/UnitTests/pch.h | PCH for MouseHighlighter unit test project. |
| src/modules/MouseUtils/MouseHighlighter/UnitTests/pch.cpp | PCH TU for MouseHighlighter unit test project. |
| src/modules/MouseUtils/MouseHighlighter/UnitTests/packages.config | NuGet restore config for MouseHighlighter unit test project. |
| src/modules/MouseUtils/MouseHighlighter/UnitTests/HighlighterTests.cpp | Adds unit tests for MouseHighlighter defaults and fade/expiry arithmetic. |
| src/modules/MouseUtils/CursorWrap/UnitTests/UnitTests-CursorWrap.vcxproj.filters | Adds filters entries for CursorWrap unit test project. |
| src/modules/MouseUtils/CursorWrap/UnitTests/UnitTests-CursorWrap.vcxproj | Adds a new native unit test project for CursorWrap logic/topology. |
| src/modules/MouseUtils/CursorWrap/UnitTests/TopologyTests.cpp | Adds unit tests for monitor topology adjacency and wrap destination behavior. |
| src/modules/MouseUtils/CursorWrap/UnitTests/pch.h | PCH for CursorWrap unit test project. |
| src/modules/MouseUtils/CursorWrap/UnitTests/pch.cpp | PCH TU for CursorWrap unit test project. |
| src/modules/MouseUtils/CursorWrap/UnitTests/packages.config | NuGet restore config for CursorWrap unit test project. |
| src/modules/fancyzones/FancyZonesTests/UnitTests/UnitTests.vcxproj.filters | Adds FancyZones.Tests.cpp to filters file. |
| src/modules/fancyzones/FancyZonesTests/UnitTests/UnitTests.vcxproj | Adds FancyZones.Tests.cpp to FancyZones unit test project build. |
| src/modules/fancyzones/FancyZonesTests/UnitTests/FancyZones.Tests.cpp | Adds a large Rust-ported FancyZones test suite (layouts/zones/keyboard snap/data/util). |
| PowerToys.slnx | Adds the new native unit test projects to the solution. |
src/modules/fancyzones/FancyZonesTests/UnitTests/UnitTests.vcxproj.filters
Outdated
Show resolved
Hide resolved
src/modules/fancyzones/FancyZonesTests/UnitTests/FancyZones.Tests.cpp
Outdated
Show resolved
Hide resolved
src/modules/fancyzones/FancyZonesTests/UnitTests/FancyZones.Tests.cpp
Outdated
Show resolved
Hide resolved
- HotkeyConflictTests: Add assertion to AddHotkey_SuccessReturnsTrue verifying hotkey is visible in manager state via HasConflict - HotkeyConflictTests: Guard AddHotkey result against OS-owned combos to prevent flaky failures from RegisterHotKey system check - TopologyTests: Fix single-monitor comment and assert IsOnOuterEdge directly instead of hiding assertion behind if-guard - TopologyTests: Tighten L-shaped outer edge count from loose range (>=7 && <=9) to deterministic AreEqual(8) - TopologyTests: Assert isOuter and edgeType as preconditions in horizontal and vertical wrap tests instead of if-guards - FancyZones.Tests: Fix comment from #RGB to #RRGGBB format - FancyZones.Tests: Use AreEqual(0L) instead of IsTrue(<=0) for ZoneAreaInverted to catch negative area bugs - UnitTests.vcxproj.filters: Add missing Source Files filter tag for FancyZones.Tests.cpp Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- HotkeyConflictTests: Add assertion to AddHotkey_SuccessReturnsTrue verifying hotkey is visible in manager state via HasConflict - HotkeyConflictTests: Guard AddHotkey result against OS-owned combos to prevent flaky failures from RegisterHotKey system check - TopologyTests: Fix single-monitor comment and assert IsOnOuterEdge directly instead of hiding assertion behind if-guard - TopologyTests: Tighten L-shaped outer edge count from loose range (>=7 && <=9) to deterministic AreEqual(8) - TopologyTests: Assert isOuter and edgeType as preconditions in horizontal and vertical wrap tests instead of if-guards - FancyZones.Tests: Fix comment from #RGB to #RRGGBB format - FancyZones.Tests: Use AreEqual(0L) instead of IsTrue(<=0) for ZoneAreaInverted to catch negative area bugs - UnitTests.vcxproj.filters: Add missing Source Files filter tag for FancyZones.Tests.cpp Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
src/modules/MouseUtils/MousePointerCrosshairs/UnitTests/CrosshairsTests.cpp
Show resolved
Hide resolved
- HotkeyConflictTests: Use Assert::Inconclusive instead of silent return when AddHotkey fails due to OS-registered hotkey, preventing tests from silently passing without assertions - HotkeyConflictTests: Guard AddHotkey_ConflictReturnsFalse and AddHotkey_DisabledDoesNotConflict against system-registered combos - HotkeyConflictTests: Add Assert::Inconclusive else-branch to Win+L SystemConflict_PriorityOverInApp test when OS doesn't exhibit the expected system conflict - HotkeyConflictTests: Guard GetHotkeyConflictsAsJson_ValidJsonOutput against system-registered hotkey preventing in-app conflict setup - CrosshairsTests pch.h: Add explicit <algorithm> include for std::min/std::max used in OpacityNormalisation_Clamped test Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- HotkeyConflictTests: Use Assert::Inconclusive instead of silent return when AddHotkey fails due to OS-registered hotkey, preventing tests from silently passing without assertions - HotkeyConflictTests: Guard AddHotkey_ConflictReturnsFalse and AddHotkey_DisabledDoesNotConflict against system-registered combos - HotkeyConflictTests: Add Assert::Inconclusive else-branch to Win+L SystemConflict_PriorityOverInApp test when OS doesn't exhibit the expected system conflict - HotkeyConflictTests: Guard GetHotkeyConflictsAsJson_ValidJsonOutput against system-registered hotkey preventing in-app conflict setup - CrosshairsTests pch.h: Add explicit <algorithm> include for std::min/std::max used in OpacityNormalisation_Clamped test Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
src/modules/fancyzones/FancyZonesTests/UnitTests/FancyZones.Tests.cpp
Outdated
Show resolved
Hide resolved
src/modules/MouseUtils/MousePointerCrosshairs/UnitTests/CrosshairsTests.cpp
Show resolved
Hide resolved
Assert::Inconclusive is not a member of CppUnitTestFramework::Assert. Use Logger::WriteMessage + return instead to skip environment-dependent tests when system hotkeys are already registered. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- FancyZones.Tests.cpp: Add missing copyright/MIT license header - FancyZones.Tests.cpp: Fix monitor ordering test to actually iterate all permutations via std::next_permutation instead of comparing already-sorted input to sorted output - FancyZones.Tests.cpp: Replace 'aaaa' with 'xxxx' in device-id test to avoid spell-check false positive - HotkeyConflictTests: Guard AddHotkey in DifferentHotkeys, TwoModulesSameHotkey, SameModuleReRegister, and EnableHotkeyByModule tests with Logger::WriteMessage + return Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- FancyZones.Tests.cpp: Add missing copyright/MIT license header - FancyZones.Tests.cpp: Fix monitor ordering test to actually iterate all permutations via std::next_permutation instead of comparing already-sorted input to sorted output - FancyZones.Tests.cpp: Replace 'aaaa' with 'xxxx' in device-id test to avoid spell-check false positive - HotkeyConflictTests: Guard AddHotkey in DifferentHotkeys, TwoModulesSameHotkey, SameModuleReRegister, and EnableHotkeyByModule tests with Logger::WriteMessage + return Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
New test projects wired into PowerToys.slnx: LightSwitch/UnitTests (48 tests): - ShouldBeLight schedule logic with fixed times and wraparound - Sunrise/sunset calculation with daylight-duration validation (Seattle summer/winter solstice, equator, equinox, high latitude) - Timezone-wrap handling for machines in different zones - ScheduleMode enum round-trip, config defaults PowerAccent/UnitTests (38 tests): - Key state machine: letter-down → trigger → show toolbar flow - Activation key filtering (Space-only, Arrow-only, Both) - Arrow cycling with shift detection - Fast activation with left/right arrow hide - Edge cases: trigger without letter, rapid activation cycle, non-letter key ignored, different letter while visible - Punctuation and digit key validation FileLocksmith/UnitTests (38 tests): - Path normalization (forward→backslash, UNC, spaces, multiple seps) - Case-insensitive path comparison (including UNC paths) - File name extraction from various path formats - ProcessResult structure operations - Output formatting (empty, single, multiple results) - Registry constant validation All 124 tests build and pass on main (verified via vstest). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
MeasureTool/UnitTests (39 tests) — NEW module, first ever C++ tests: - BGRATextureView pixel indexing and color proximity - Edge detection: uniform, centered/corner/asymmetric boxes, tolerance - Unit conversion: pixel/inch/cm/mm with DPI scaling, inclusive ranges - Constants validation (frame rate, font size, opacity) FindMyMouse/UnitTests (22 tests) — NEW module: - Shake detection: stationary, slow move, rapid direction changes - Activation guard: game mode blocking, excluded apps (case-insensitive, substring matching for paths), combined scenarios PowerAccent/UnitTests (40 tests, +2 from previous): - OSK_RepeatedLetterSuppressed_Issue36853: 5x rapid repeat verification - DifferentLetterWhileActive_ResetsTracking: matches C++ pass-through All wired into PowerToys.slnx. All build and pass on main. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
| Assert::IsTrue(result == ActivationCheck::BlockedByExcludedApp, L"Should block excluded app"); | ||
| } | ||
|
|
||
| // ── Excluded app case insensitive ── |
| // https://github.com/microsoft/PowerToys/issues/36853 | ||
| // On-screen keyboard sends WM_KEYDOWN continuously while key held. | ||
| // Repeated letter keys must be suppressed while accent picker is visible. | ||
| TEST_METHOD(OSK_RepeatedLetterSuppressed_Issue36853) |
| sm.OnKeyDown(VK_SPACE); | ||
| Assert::IsTrue(sm.toolbarVisible); | ||
|
|
||
| // Simulate OSK repeating the same letter 5 times |
| { | ||
| bool suppressed = sm.OnKeyDown(0x41); | ||
| Assert::IsTrue(suppressed, | ||
| L"OSK repeat must be suppressed while accent picker visible"); |
This comment has been minimized.
This comment has been minimized.
@check-spelling-bot Report🔴 Please reviewSee the 📂 files view, the 📜action log, 👼 SARIF report, or 📝 job summary for details.Unrecognized words (2)AAAAs These words are not needed and should be removedaaaa diu IPREVIEW ITHUMBNAIL LPCFHOOKPROC LUMA MAXDWORD MRT suntimes timespan VSyncTo accept these unrecognized words as correct and remove the previously acknowledged and now absent words, you could run the following commands... in a clone of the git@github.com:crutkas/autoUpgradeAttempt.git repository curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/cfb6f7e75bbfc89c71eaa30366d0c166f1bd9c8c/apply.pl' |
perl - 'https://github.com/microsoft/PowerToys/actions/runs/24310619023/attempts/1' &&
git commit -m 'Update check-spelling metadata'Forbidden patterns 🙅 (1)In order to address this, you could change the content to not match the forbidden patterns (comments before forbidden patterns may help explain why they're forbidden), add patterns for acceptable instances, or adjust the forbidden patterns themselves. These forbidden patterns matched content: Should be
|
| ❌ Errors | Count |
|---|---|
| ❌ forbidden-pattern | 1 |
See ❌ Event descriptions for more information.
If the flagged items are 🤯 false positives
If items relate to a ...
-
binary file (or some other file you wouldn't want to check at all).
Please add a file path to the
excludes.txtfile matching the containing file.File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.
^refers to the file's path from the root of the repository, so^README\.md$would exclude README.md (on whichever branch you're using). -
well-formed pattern.
If you can write a pattern that would match it,
try adding it to thepatterns.txtfile.Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.
Note that patterns can't match multiline strings.
CursorWrap (16 tests): Monitor layouts, edge adjacency, wrap destinations, WrapMode filtering. MouseHighlighter (14 tests): Click colors, fade timing, alpha disables, cleanup. MousePointerCrosshairs (25 tests): Line layout, fixed length, orientation modes, radius gap, opacity. FindMyMouse (22 tests): Shake detection, activation guard, game mode, excluded apps. Split from PR microsoft#46905 (3/7) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
BGRATextureView pixel indexing and color proximity, edge detection (uniform, centered/corner/asymmetric boxes, tolerance), unit conversion (pixel/inch/cm/mm with DPI scaling), and constants validation (frame rate, font size, opacity). Split from PR microsoft#46905 (4/7) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Path normalization (forward->backslash, UNC paths, spaces), case-insensitive path comparison including UNC paths, ProcessResult operations, output formatting, and registry constants. Split from PR microsoft#46905 (7/7) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ShouldBeLight schedule logic with fixed times and midnight wraparound, sunrise/sunset daylight-duration validation (timezone-wrap safe), ScheduleMode enum serialization round-trip, and config defaults. Split from PR microsoft#46905 (5/7) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Layout calculations (columns, rows, grid, priority grid, focus), keyboard snap (index-based navigation, position-based, extend selection), data structures (AppliedLayouts, CustomLayouts, LayoutHotkeys JSON parsing), device ID parsing (valid/invalid formats, serial numbers), and engine lifecycle (drag start/move/end, cancel, shift-drag). Split from PR microsoft#46905 (1/7) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Handle hashing (same/different hotkeys), conflict detection (empty, cross-module, same-module), module lifecycle (add/remove/enable/disable), system vs in-app priority, and JSON serialization. Split from PR microsoft#46905 (2/7) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Key state machine (letter-down -> trigger -> show toolbar flow), activation key filtering (Space-only, Arrow-only, Both modes), OSK repeat suppression (fixes microsoft#36853), and edge cases (trigger without letter, rapid activation cycle). Split from PR microsoft#46905 (6/7) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
I've been experimenting with an idea and as one of the discoveries that came out of it is boosting test coverage.
New Test Files (340 TEST_METHODs total across 10 projects)
FancyZones — FancyZones.Tests.cpp (85 tests)
Runner — HotkeyConflictTests.cpp (15 tests)
CursorWrap — TopologyTests.cpp (16 tests)
MouseHighlighter — HighlighterTests.cpp (14 tests)
MousePointerCrosshairs — CrosshairsTests.cpp (25 tests)
FindMyMouse — FindMyMouseTests.cpp (22 tests) ★ NEW
MeasureTool — MeasureToolTests.cpp (39 tests) ★ NEW
LightSwitch — LightSwitchTests.cpp (48 tests)
PowerAccent — PowerAccentTests.cpp (40 tests)
FileLocksmith — FileLocksmithTests.cpp (38 tests)
Test Infrastructure