#ifndef NOMINMAX #define NOMINMAX #endif #include #include "Host/InputModifierTracker.h" #include #include namespace { using XCEngine::UI::Editor::Host::InputModifierTracker; using XCEngine::UI::UIInputEventType; TEST(InputModifierTrackerTest, ControlStatePersistsAcrossChordKeyDownAndClearsOnKeyUp) { InputModifierTracker tracker = {}; const auto ctrlDown = tracker.ApplyKeyMessage( UIInputEventType::KeyDown, VK_CONTROL, 0x001D0001); EXPECT_TRUE(ctrlDown.control); EXPECT_FALSE(ctrlDown.shift); EXPECT_FALSE(ctrlDown.alt); const auto chordKeyDown = tracker.ApplyKeyMessage( UIInputEventType::KeyDown, 'P', 0x00190001); EXPECT_TRUE(chordKeyDown.control); const auto ctrlUp = tracker.ApplyKeyMessage( UIInputEventType::KeyUp, VK_CONTROL, static_cast(0xC01D0001u)); EXPECT_FALSE(ctrlUp.control); const auto nextKeyDown = tracker.ApplyKeyMessage( UIInputEventType::KeyDown, 'P', 0x00190001); EXPECT_FALSE(nextKeyDown.control); } TEST(InputModifierTrackerTest, PointerModifiersMergeMouseFlagsWithTrackedKeyboardState) { InputModifierTracker tracker = {}; tracker.ApplyKeyMessage( UIInputEventType::KeyDown, VK_MENU, 0x00380001); const auto modifiers = tracker.BuildPointerModifiers(MK_SHIFT); EXPECT_TRUE(modifiers.shift); EXPECT_TRUE(modifiers.alt); EXPECT_FALSE(modifiers.control); EXPECT_FALSE(modifiers.super); } TEST(InputModifierTrackerTest, RightControlIsTrackedIndependentlyFromLeftControl) { InputModifierTracker tracker = {}; tracker.ApplyKeyMessage( UIInputEventType::KeyDown, VK_CONTROL, static_cast(0x011D0001u)); EXPECT_TRUE(tracker.GetCurrentModifiers().control); tracker.ApplyKeyMessage( UIInputEventType::KeyDown, VK_CONTROL, 0x001D0001); EXPECT_TRUE(tracker.GetCurrentModifiers().control); tracker.ApplyKeyMessage( UIInputEventType::KeyUp, VK_CONTROL, static_cast(0xC11D0001u)); EXPECT_TRUE(tracker.GetCurrentModifiers().control); tracker.ApplyKeyMessage( UIInputEventType::KeyUp, VK_CONTROL, static_cast(0xC01D0001u)); EXPECT_FALSE(tracker.GetCurrentModifiers().control); } } // namespace