d749df70ed
**BE NOT AFRAID**. I know that there's 107 files in this PR, but almost all of it is just find/replacing `TerminalControl` with `Control`. This is the start of the work to move TermControl into multiple pieces, for #5000. The PR starts this work by: * Splits `TerminalControl` into separate lib and dll projects. We'll want control tests in the future, and for that, we'll need a lib. * Moves `ICoreSettings` back into the `Microsoft.Terminal.Core` namespace. We'll have other types in there soon too. * I could not tell you why this works suddenly. New VS versions? New cppwinrt version? Maybe we're just better at dealing with mdmerge bugs these days. * RENAMES `Microsoft.Terminal.TerminalControl` to `Microsoft.Terminal.Control`. This touches pretty much every file in the sln. Sorry about that (not sorry). An upcoming PR will move much of the logic in TermControl into a new `ControlCore` class that we'll add in `Microsoft.Terminal.Core`. `ControlCore` will then be unittest-able in the `UnitTests_TerminalCore`, which will help prevent regressions like #9455 ## Detailed Description of the Pull Request / Additional comments You're really gonna want to clean the sln first, then merge this into your branch, then rebuild. It's very likely that old winmds will get left behind. If you see something like ``` Error MDM2007 Cannot create type Microsoft.Terminal.TerminalControl.KeyModifiers in read-only metadata file Microsoft.Terminal.TerminalControl. ``` then that's what happened to you.
50 lines
1.9 KiB
C++
50 lines
1.9 KiB
C++
/*++
|
|
Copyright (c) Microsoft Corporation
|
|
Licensed under the MIT license.
|
|
|
|
Module Name:
|
|
- TestUtils.h
|
|
|
|
Abstract:
|
|
- This file has helper functions for writing tests for the TerminalApp project.
|
|
|
|
Author(s):
|
|
Mike Griese (migrie) December-2019
|
|
--*/
|
|
|
|
class TestUtils
|
|
{
|
|
public:
|
|
// Function Description:
|
|
// - This is a helper to retrieve the ActionAndArgs from the keybindings
|
|
// for a given chord.
|
|
// Arguments:
|
|
// - keymap: The AppKeyBindings to lookup the ActionAndArgs from.
|
|
// - kc: The key chord to look up the bound ActionAndArgs for.
|
|
// Return Value:
|
|
// - The ActionAndArgs bound to the given key, or nullptr if nothing is bound to it.
|
|
static const winrt::Microsoft::Terminal::Settings::Model::ActionAndArgs GetActionAndArgs(const winrt::Microsoft::Terminal::Settings::Model::KeyMapping& keymap,
|
|
const winrt::Microsoft::Terminal::Control::KeyChord& kc)
|
|
{
|
|
std::wstring buffer{ L"" };
|
|
if (WI_IsFlagSet(kc.Modifiers(), winrt::Microsoft::Terminal::Control::KeyModifiers::Ctrl))
|
|
{
|
|
buffer += L"Ctrl+";
|
|
}
|
|
if (WI_IsFlagSet(kc.Modifiers(), winrt::Microsoft::Terminal::Control::KeyModifiers::Shift))
|
|
{
|
|
buffer += L"Shift+";
|
|
}
|
|
if (WI_IsFlagSet(kc.Modifiers(), winrt::Microsoft::Terminal::Control::KeyModifiers::Alt))
|
|
{
|
|
buffer += L"Alt+";
|
|
}
|
|
buffer += static_cast<wchar_t>(MapVirtualKeyW(kc.Vkey(), MAPVK_VK_TO_CHAR));
|
|
WEX::Logging::Log::Comment(WEX::Common::NoThrowString().Format(L"Looking for key:%s", buffer.c_str()));
|
|
|
|
const auto action = keymap.TryLookup(kc);
|
|
VERIFY_IS_NOT_NULL(action, L"Expected to find an action bound to the given KeyChord");
|
|
return action;
|
|
};
|
|
};
|