diff --git a/src/terminal/parser/ut_parser/InputEngineTest.cpp b/src/terminal/parser/ut_parser/InputEngineTest.cpp index 19aa93919e9..dcae5bcb815 100644 --- a/src/terminal/parser/ut_parser/InputEngineTest.cpp +++ b/src/terminal/parser/ut_parser/InputEngineTest.cpp @@ -554,11 +554,6 @@ void InputEngineTest::AlphanumericTest() void InputEngineTest::RoundTripTest() { - // TODO GH #4405: This test fails. - Log::Result(WEX::Logging::TestResults::Skipped); - return; - - /* auto pfn = std::bind(&TestState::TestInputCallback, &testState, std::placeholders::_1); auto dispatch = std::make_unique(pfn, &testState); auto inputEngine = std::make_unique(std::move(dispatch)); @@ -566,35 +561,31 @@ void InputEngineTest::RoundTripTest() VERIFY_IS_NOT_NULL(_stateMachine); testState._stateMachine = _stateMachine.get(); - // Send Every VKEY through the TerminalInput module, then take the char's - // from the generated INPUT_RECORDs and put them through the InputEngine. + // Send known round-trip capable VKEYs through the TerminalInput module, then take the chars + // from the generated INPUT_RECORDs and put them through the InputEngine. // The VKEY sequence it writes out should be the same as the original. + // Note: We only test VKEYs that generate VT sequences (alphanumerics and space). + // Testing all VKEYs fails (GH #4405) because many keys don't generate VT and won't roundtrip. + + TerminalInput terminalInput; - auto pfn2 = std::bind(&TestState::RoundtripTerminalInputCallback, &testState, std::placeholders::_1); - TerminalInput terminalInput{ pfn2 }; + std::vector testKeys; + testKeys.push_back(VK_SPACE); + for (BYTE k = '0'; k <= '9'; k++) { testKeys.push_back(k); } + for (BYTE k = 'A'; k <= 'Z'; k++) { testKeys.push_back(k); } - for (BYTE vkey = 0; vkey < BYTE_MAX; vkey++) + for (const BYTE vkey : testKeys) { wchar_t wch = (wchar_t)OneCoreSafeMapVirtualKeyW(vkey, MAPVK_VK_TO_CHAR); - WORD scanCode = (wchar_t)OneCoreSafeMapVirtualKeyW(vkey, MAPVK_VK_TO_VSC); + WORD scanCode = (WORD)OneCoreSafeMapVirtualKeyW(vkey, MAPVK_VK_TO_VSC); unsigned int uiActualKeystate = 0; - // Couple of exceptional cases here: if (vkey >= 'A' && vkey <= 'Z') { // A-Z need shift pressed in addition to the 'a'-'z' chars. uiActualKeystate = WI_SetFlag(uiActualKeystate, SHIFT_PRESSED); } - else if (vkey == VK_CANCEL || vkey == VK_PAUSE) - { - uiActualKeystate = WI_SetFlag(uiActualKeystate, LEFT_CTRL_PRESSED); - } - - if (vkey == UNICODE_ETX) - { - testState._expectSendCtrlC = true; - } INPUT_RECORD irTest = { 0 }; irTest.EventType = KEY_EVENT; @@ -612,12 +603,13 @@ void InputEngineTest::RoundTripTest() testState.vExpectedInput.clear(); testState.vExpectedInput.push_back(irTest); - auto inputKey = IInputEvent::Create(irTest); - terminalInput.HandleKey(inputKey.get()); + if (const auto str = terminalInput.HandleKey(irTest)) + { + testState._stateMachine->ProcessString(*str); + } } VerifyExpectedInputDrained(); - */ } void InputEngineTest::NonAsciiTest()