Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 16 additions & 24 deletions src/terminal/parser/ut_parser/InputEngineTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -554,47 +554,38 @@ 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<TestInteractDispatch>(pfn, &testState);
auto inputEngine = std::make_unique<InputStateMachineEngine>(std::move(dispatch));
auto _stateMachine = std::make_unique<StateMachine>(std::move(inputEngine));
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<BYTE> 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;
Expand All @@ -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()
Expand Down
Loading