mirror of
https://github.com/microsoft/terminal.git
synced 2025-12-11 04:38:24 -06:00
Make a VTApiRoutines servicer that does minimal translations instead of environmental simulation for some output methods. Remaining methods are backed on the existing console host infrastructure (primarily input related methods). ## PR Checklist * [x] I work here * [x] It's Fix-Hack-Learn quality so it's behind a feature gate so we can keep refining it. But it's a start! To turn this on, you will have to be in the Dev or Preview rings (feature staged). Then add `experimental.connection.passthroughMode: true` to a profile and on the next launch, the flags will propagate down through the `ConptyConnection` into the underlying `Openconsole.exe` startup and tell it to use the passthrough mode instead of the full simulation mode. ## Validation Steps Performed - Played with it manually in CMD.exe, it seems to work mostly. - Played with it manually in Ubuntu WSL, it seems to work. - Played with it manually in Powershell and it's mostly sad. It'll get there. Starts #1173
67 lines
2.1 KiB
C++
67 lines
2.1 KiB
C++
// Copyright (c) Microsoft Corporation.
|
|
// Licensed under the MIT license.
|
|
|
|
#include "pch.h"
|
|
#include <WexTestClass.h>
|
|
|
|
#include "../cascadia/TerminalCore/Terminal.hpp"
|
|
#include "../renderer/inc/DummyRenderer.hpp"
|
|
#include "consoletaeftemplates.hpp"
|
|
|
|
using namespace WEX::Logging;
|
|
using namespace WEX::TestExecution;
|
|
|
|
using namespace Microsoft::Terminal::Core;
|
|
using namespace Microsoft::Console::Render;
|
|
|
|
namespace TerminalCoreUnitTests
|
|
{
|
|
class InputTest
|
|
{
|
|
TEST_CLASS(InputTest);
|
|
TEST_CLASS_SETUP(ClassSetup)
|
|
{
|
|
DummyRenderer renderer;
|
|
term.Create({ 100, 100 }, 0, renderer);
|
|
auto inputFn = std::bind(&InputTest::_VerifyExpectedInput, this, std::placeholders::_1);
|
|
term.SetWriteInputCallback(inputFn);
|
|
return true;
|
|
};
|
|
|
|
TEST_METHOD(AltShiftKey);
|
|
TEST_METHOD(InvalidKeyEvent);
|
|
|
|
void _VerifyExpectedInput(std::wstring_view actualInput)
|
|
{
|
|
VERIFY_ARE_EQUAL(expectedinput.size(), actualInput.size());
|
|
VERIFY_ARE_EQUAL(expectedinput, actualInput);
|
|
};
|
|
|
|
Terminal term{};
|
|
std::wstring expectedinput{};
|
|
};
|
|
|
|
void InputTest::AltShiftKey()
|
|
{
|
|
// Tests GH:637
|
|
|
|
// Verify that Alt+a generates a lowercase a on the input
|
|
expectedinput = L"\x1b"
|
|
"a";
|
|
VERIFY_IS_TRUE(term.SendCharEvent(L'a', 0, ControlKeyStates::LeftAltPressed));
|
|
|
|
// Verify that Alt+shift+a generates a uppercase a on the input
|
|
expectedinput = L"\x1b"
|
|
"A";
|
|
VERIFY_IS_TRUE(term.SendCharEvent(L'A', 0, ControlKeyStates::LeftAltPressed | ControlKeyStates::ShiftPressed));
|
|
}
|
|
|
|
void InputTest::InvalidKeyEvent()
|
|
{
|
|
// Certain applications like AutoHotKey and its keyboard remapping feature,
|
|
// send us key events using SendInput() whose values are outside of the valid range.
|
|
VERIFY_IS_FALSE(term.SendKeyEvent(0, 123, {}, true));
|
|
VERIFY_IS_FALSE(term.SendKeyEvent(255, 123, {}, true));
|
|
}
|
|
}
|