mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-04 18:26:39 +02:00
* Move KBM engine into separate process (#10672) * [KBM] Migrate KBM UI out of the runner (#10709) * Clean up keyboard hook handles (#10817) * [C++ common] Unhandled exception handler (#10821) * [KBM] Use icon in the KeyboardManagerEditor (#10845) * [KBM] Move resources from the Common project to the Editor. (#10844) * KBM Editor tests (#10858) * Rename engine executable (#10868) * clean up (#10870) * [KBM] Changed Editor and libraries output folders (#10871) * [KBM] New logs structure (#10872) * Add unhandled exception handling to the editor (#10874) * [KBM] Trace for edit keyboard window * Logging for XamlBridge message loop * [KBM] Added Editor and Engine to the installer (#10876) * Fix spelling * Interprocess communication logs, remove unnecessary windows message logs * [KBM] Separated telemetry for the engine and editor. (#10889) * [KBM] Editor test project (#10891) * Versions for the engine and the editor (#10897) * Add the editor's and the engine's executables to signing process (#10900) * [KBM editor] Run only one instance, exit when parent process exits (#10890) * [KBM] Force kill editor process to avoid XAML crash (#10907) * [KBM] Force kill editor process to avoid XAML crash * Fix event releasing Co-authored-by: mykhailopylyp <17161067+mykhailopylyp@users.noreply.github.com> * Make the editor dpi aware (#10908) * [KBM] KeyboardManagerCommon refactoring (#10909) * Do not start the process if it is already started (#10910) * logs * Update src/modules/keyboardmanager/KeyboardManagerEditorLibrary/EditKeyboardWindow.cpp * Update src/modules/keyboardmanager/KeyboardManagerEditorLibrary/EditKeyboardWindow.cpp * [KBM] Rename InitUnhandledExceptionHandler to make it explicit that is for x64 only. We will fix it properly when adding support for ARM64 and add a header with the proper conditional building. * [KBM] rename file/class/variables using camel case * [KBM] Rename "event_locker" -> "EventLocker" * [KBM] rename process_waiter Add a TODO comment * [KBM] rename methods Add TODO comment * [KBM] use uppercase for function names * [KBM] use uppercase for methos, lowercase for properties * [KBM] rename method, make methods private, formatting * [KBM] rename private variables * [KBM] use uppercase for function names * [KBM] Added support to run the editor stand-alone when built in debug mode * Update src/modules/keyboardmanager/KeyboardManagerEditor/KeyboardManagerEditor.cpp * Check success of event creation, comment (#10947) * [KBM] code formatting (#10951) * [KBM] code formatting * Update src/modules/keyboardmanager/KeyboardManagerEditorLibrary/BufferValidationHelpers.cpp * [KBM] tracing * [KBM] Remappings not showing fix. (#10954) * removed mutex * retry loop for reading * retry on reading config once * log error Co-authored-by: Enrico Giordani <enricogior@users.noreply.github.com> Co-authored-by: Enrico Giordani <enricogior@users.noreply.github.com> Co-authored-by: Seraphima Zykova <zykovas91@gmail.com> Co-authored-by: Enrico Giordani <enricogior@users.noreply.github.com> Co-authored-by: Enrico Giordani <enrico.giordani@gmail.com>
144 lines
5.1 KiB
C++
144 lines
5.1 KiB
C++
#include "pch.h"
|
|
#include "CppUnitTest.h"
|
|
#include <keyboardmanager/common/ErrorTypes.h>
|
|
#include <keyboardmanager/common/Helpers.h>
|
|
#include "TestHelpers.h"
|
|
#include <common/interop/keyboard_layout.h>
|
|
|
|
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
|
|
|
namespace KeyboardManagerCommonTests
|
|
{
|
|
// Tests for methods in the KeyboardManagerHelper namespace
|
|
TEST_CLASS (KeyboardManagerHelperTests)
|
|
{
|
|
public:
|
|
TEST_METHOD_INITIALIZE(InitializeTestEnv)
|
|
{
|
|
}
|
|
|
|
// Test if the DoKeysOverlap method returns SameKeyPreviouslyMapped on passing the same key for both arguments
|
|
TEST_METHOD (DoKeysOverlap_ShouldReturnSameKeyPreviouslyMapped_OnPassingSameKeyForBothArguments)
|
|
{
|
|
// Arrange
|
|
DWORD key1 = 0x41;
|
|
DWORD key2 = key1;
|
|
|
|
// Act
|
|
auto result = KeyboardManagerHelper::DoKeysOverlap(key1, key2);
|
|
|
|
// Assert
|
|
Assert::IsTrue(result == KeyboardManagerHelper::ErrorType::SameKeyPreviouslyMapped);
|
|
}
|
|
|
|
// Test if the DoKeysOverlap method returns ConflictingModifierKey on passing left modifier and common modifier
|
|
TEST_METHOD (DoKeysOverlap_ShouldReturnConflictingModifierKey_OnPassingLeftModifierAndCommonModifierOfSameType)
|
|
{
|
|
// Arrange
|
|
DWORD key1 = VK_LCONTROL;
|
|
DWORD key2 = VK_CONTROL;
|
|
|
|
// Act
|
|
auto result = KeyboardManagerHelper::DoKeysOverlap(key1, key2);
|
|
|
|
// Assert
|
|
Assert::IsTrue(result == KeyboardManagerHelper::ErrorType::ConflictingModifierKey);
|
|
}
|
|
|
|
// Test if the DoKeysOverlap method returns ConflictingModifierKey on passing right modifier and common modifier
|
|
TEST_METHOD (DoKeysOverlap_ShouldReturnConflictingModifierKey_OnPassingRightModifierAndCommonModifierOfSameType)
|
|
{
|
|
// Arrange
|
|
DWORD key1 = VK_RCONTROL;
|
|
DWORD key2 = VK_CONTROL;
|
|
|
|
// Act
|
|
auto result = KeyboardManagerHelper::DoKeysOverlap(key1, key2);
|
|
|
|
// Assert
|
|
Assert::IsTrue(result == KeyboardManagerHelper::ErrorType::ConflictingModifierKey);
|
|
}
|
|
|
|
// Test if the DoKeysOverlap method returns NoError on passing left modifier and right modifier
|
|
TEST_METHOD (DoKeysOverlap_ShouldReturnNoError_OnPassingLeftModifierAndRightModifierOfSameType)
|
|
{
|
|
// Arrange
|
|
DWORD key1 = VK_LCONTROL;
|
|
DWORD key2 = VK_RCONTROL;
|
|
|
|
// Act
|
|
auto result = KeyboardManagerHelper::DoKeysOverlap(key1, key2);
|
|
|
|
// Assert
|
|
Assert::IsTrue(result == KeyboardManagerHelper::ErrorType::NoError);
|
|
}
|
|
|
|
// Test if the DoKeysOverlap method returns NoError on passing keys of different types
|
|
TEST_METHOD (DoKeysOverlap_ShouldReturnNoError_OnPassingKeysOfDifferentTypes)
|
|
{
|
|
// Arrange
|
|
DWORD key1 = VK_CONTROL;
|
|
DWORD key2 = VK_SHIFT;
|
|
|
|
// Act
|
|
auto result = KeyboardManagerHelper::DoKeysOverlap(key1, key2);
|
|
|
|
// Assert
|
|
Assert::IsTrue(result == KeyboardManagerHelper::ErrorType::NoError);
|
|
}
|
|
|
|
// Test if the DoKeysOverlap method returns NoError on passing different action keys
|
|
TEST_METHOD (DoKeysOverlap_ShouldReturnNoError_OnPassingDifferentActionKeys)
|
|
{
|
|
// Arrange
|
|
DWORD key1 = 0x41;
|
|
DWORD key2 = 0x42;
|
|
|
|
// Act
|
|
auto result = KeyboardManagerHelper::DoKeysOverlap(key1, key2);
|
|
|
|
// Assert
|
|
Assert::IsTrue(result == KeyboardManagerHelper::ErrorType::NoError);
|
|
}
|
|
|
|
// Test if the CheckRepeatedModifier method returns true on passing vector with same modifier repeated
|
|
TEST_METHOD (CheckRepeatedModifier_ShouldReturnTrue_OnPassingSameModifierRepeated)
|
|
{
|
|
// Arrange
|
|
std::vector<int32_t> keys = { VK_CONTROL, VK_CONTROL, 0x41 };
|
|
|
|
// Act
|
|
bool result = KeyboardManagerHelper::CheckRepeatedModifier(keys, VK_CONTROL);
|
|
|
|
// Assert
|
|
Assert::IsTrue(result);
|
|
}
|
|
|
|
// Test if the CheckRepeatedModifier method returns true on passing vector with conflicting modifier repeated
|
|
TEST_METHOD (CheckRepeatedModifier_ShouldReturnTrue_OnPassingConflictingModifierRepeated)
|
|
{
|
|
// Arrange
|
|
std::vector<int32_t> keys = { VK_CONTROL, VK_LCONTROL, 0x41 };
|
|
|
|
// Act
|
|
bool result = KeyboardManagerHelper::CheckRepeatedModifier(keys, VK_LCONTROL);
|
|
|
|
// Assert
|
|
Assert::IsTrue(result);
|
|
}
|
|
|
|
// Test if the CheckRepeatedModifier method returns false on passing vector with different modifiers
|
|
TEST_METHOD (CheckRepeatedModifier_ShouldReturnFalse_OnPassingDifferentModifiers)
|
|
{
|
|
// Arrange
|
|
std::vector<int32_t> keys = { VK_CONTROL, VK_SHIFT, 0x41 };
|
|
|
|
// Act
|
|
bool result = KeyboardManagerHelper::CheckRepeatedModifier(keys, VK_SHIFT);
|
|
|
|
// Assert
|
|
Assert::IsFalse(result);
|
|
}
|
|
};
|
|
}
|