mirror of
https://github.com/microsoft/terminal.git
synced 2026-05-21 22:37:19 +00:00
Fix compilation failures?
This commit is contained in:
@@ -4,6 +4,7 @@ namespace TestHook
|
||||
{
|
||||
struct LayoutGuard
|
||||
{
|
||||
LayoutGuard() = default;
|
||||
LayoutGuard(HKL layout, bool needsUnload) noexcept;
|
||||
~LayoutGuard();
|
||||
|
||||
|
||||
@@ -628,7 +628,17 @@ void InputTest::TerminalInputNullKeyTests()
|
||||
{
|
||||
using namespace std::string_view_literals;
|
||||
|
||||
const auto layout = TestHook::SetTerminalInputKeyboardLayout(L"00000409"); // US English
|
||||
TestHook::LayoutGuard layout;
|
||||
try
|
||||
{
|
||||
layout = TestHook::SetTerminalInputKeyboardLayout(L"00000409"); // US English
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
Log::Result(TestResults::Result::Skipped);
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned int uiKeystate = LEFT_CTRL_PRESSED;
|
||||
|
||||
TerminalInput input;
|
||||
|
||||
@@ -252,10 +252,29 @@ extern "C" HRESULT __declspec(dllexport) __cdecl KittyKeyTestDataSource(IDataSou
|
||||
|
||||
class KittyKeyboardProtocolTests
|
||||
{
|
||||
TestHook::LayoutGuard layout = TestHook::SetTerminalInputKeyboardLayout(L"0001040c"); // French (Standard, AZERTY)
|
||||
TestHook::LayoutGuard layout;
|
||||
|
||||
TEST_CLASS(KittyKeyboardProtocolTests);
|
||||
|
||||
TEST_CLASS_SETUP(ClassSetup)
|
||||
{
|
||||
try
|
||||
{
|
||||
layout = TestHook::SetTerminalInputKeyboardLayout(L"0001040c"); // French (Standard, AZERTY)
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
Log::Result(TestResults::Result::Skipped);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
TEST_CLASS_CLEANUP(ClassCleanup)
|
||||
{
|
||||
layout = {};
|
||||
return true;
|
||||
}
|
||||
|
||||
TEST_METHOD(KeyPressTests)
|
||||
{
|
||||
BEGIN_TEST_METHOD_PROPERTIES()
|
||||
|
||||
14
src/terminal/input/TestHook.cpp
Normal file
14
src/terminal/input/TestHook.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#include "precomp.h"
|
||||
|
||||
// This default no-op implementation lives in its own .obj so that the linker
|
||||
// can skip it when a test DLL supplies its own definition. The classic linking
|
||||
// model only pulls in .obj files from a .lib if they resolve an otherwise
|
||||
// unresolved symbol - and nothing else in the test DLL refers to this file.
|
||||
// See: https://devblogs.microsoft.com/oldnewthing/20250416-00/?p=111077
|
||||
extern "C" HKL TestHook_TerminalInput_KeyboardLayout()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
@@ -13,6 +13,7 @@
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\mouseInput.cpp" />
|
||||
<ClCompile Include="..\terminalInput.cpp" />
|
||||
<ClCompile Include="..\TestHook.cpp" />
|
||||
<ClCompile Include="..\precomp.cpp">
|
||||
<PrecompiledHeader>Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
|
||||
@@ -30,6 +30,7 @@ PRECOMPILED_INCLUDE = ..\precomp.h
|
||||
SOURCES= \
|
||||
..\terminalInput.cpp \
|
||||
..\mouseInput.cpp \
|
||||
..\TestHook.cpp \
|
||||
|
||||
INCLUDES = \
|
||||
$(INCLUDES); \
|
||||
|
||||
@@ -1497,15 +1497,10 @@ void TerminalInput::KeyboardHelper::init() noexcept
|
||||
}
|
||||
}
|
||||
|
||||
#pragma comment(linker, "/alternatename:TestHook_TerminalInput_KeyboardLayout=TestHook_TerminalInput_KeyboardLayout_Default")
|
||||
// The default no-op implementation lives in TestHook.cpp (its own .obj) so the
|
||||
// linker can skip it when a test DLL supplies its own definition.
|
||||
extern "C" HKL TestHook_TerminalInput_KeyboardLayout();
|
||||
|
||||
// Thanks to LTCG this should get inlined in Release builds and the test branch removed.
|
||||
extern "C" HKL TestHook_TerminalInput_KeyboardLayout_Default()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void TerminalInput::KeyboardHelper::initSlow() noexcept
|
||||
{
|
||||
if (const auto hkl = TestHook_TerminalInput_KeyboardLayout())
|
||||
|
||||
Reference in New Issue
Block a user