https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c1c127932d9f22d0a0f34…
commit c1c127932d9f22d0a0f348a0ce620915e4e61f93
Author: Stanislav Motylkov <x86corez(a)gmail.com>
AuthorDate: Sat Oct 1 14:28:42 2022 +0300
Commit: Stanislav Motylkov <x86corez(a)gmail.com>
CommitDate: Sun Oct 2 02:46:24 2022 +0300
[USER32_APITEST] Add tests for MapVirtualKeyW
For @julcar. See PR #4730 for details. CORE-17906
---
modules/rostests/apitests/user32/CMakeLists.txt | 1 +
modules/rostests/apitests/user32/VirtualKey.c | 63 +++++++++++++++++++++++++
modules/rostests/apitests/user32/testlist.c | 2 +
3 files changed, 66 insertions(+)
diff --git a/modules/rostests/apitests/user32/CMakeLists.txt
b/modules/rostests/apitests/user32/CMakeLists.txt
index bafd3571df5..c7eeefc5db5 100644
--- a/modules/rostests/apitests/user32/CMakeLists.txt
+++ b/modules/rostests/apitests/user32/CMakeLists.txt
@@ -48,6 +48,7 @@ list(APPEND SOURCE
SwitchToThisWindow.c
SystemParametersInfo.c
TrackMouseEvent.c
+ VirtualKey.c
WndProc.c
wsprintf.c)
diff --git a/modules/rostests/apitests/user32/VirtualKey.c
b/modules/rostests/apitests/user32/VirtualKey.c
new file mode 100644
index 00000000000..4e3219da6a6
--- /dev/null
+++ b/modules/rostests/apitests/user32/VirtualKey.c
@@ -0,0 +1,63 @@
+/*
+ * PROJECT: ReactOS API tests
+ * LICENSE: GPL-2.0-or-later (
https://spdx.org/licenses/GPL-2.0-or-later)
+ * PURPOSE: Tests for virtual keys
+ * COPYRIGHT: Copyright 2022 Stanislav Motylkov <x86corez(a)gmail.com>
+ */
+
+#include "precomp.h"
+
+UINT MapTypes[] = {
+ MAPVK_VK_TO_VSC,
+ MAPVK_VSC_TO_VK,
+ MAPVK_VK_TO_CHAR,
+ MAPVK_VSC_TO_VK_EX,
+#if (NTDDI_VERSION >= NTDDI_VISTA)
+ MAPVK_VK_TO_VSC_EX,
+#endif
+};
+
+struct
+{
+ UINT VirtKey;
+ UINT ScanToVirt;
+ UINT ScanCode;
+} TestCodes[] = {
+ {VK_TAB, 0, 15},
+ {VK_RETURN, 0, 28},
+ {VK_CONTROL, 0, 29},
+ {VK_LCONTROL, VK_CONTROL, 29},
+ {VK_RCONTROL, VK_CONTROL, 29},
+ {VK_MENU, 0, 56},
+ {VK_SPACE, 0, 57},
+};
+
+static void testMapVirtualKey()
+{
+ INT i;
+ UINT vCode, vExpect = 0;
+
+ /* Make sure MapVirtualKeyW returns 0 in all cases when uCode == 0 */
+ for (i = 0; i < _countof(MapTypes); i++)
+ {
+ vCode = MapVirtualKeyW(0, MapTypes[i]);
+ ok(vCode == vExpect, "[%d] Returned %u, expected %u\n", i, vCode,
vExpect);
+ }
+
+ /* Test matching between virtual keys and scan codes */
+ for (i = 0; i < _countof(TestCodes); i++)
+ {
+ vCode = MapVirtualKeyW(TestCodes[i].VirtKey, MAPVK_VK_TO_VSC);
+ vExpect = TestCodes[i].ScanCode;
+ ok(vCode == vExpect, "[%d] ScanCode = %u, expected %u\n", i, vCode,
vExpect);
+
+ vCode = MapVirtualKeyW(TestCodes[i].ScanCode, MAPVK_VSC_TO_VK);
+ vExpect = (TestCodes[i].ScanToVirt == 0 ? TestCodes[i].VirtKey :
TestCodes[i].ScanToVirt);
+ ok(vCode == vExpect, "[%d] VirtKey = %u, expected %u\n", i, vCode,
vExpect);
+ }
+}
+
+START_TEST(VirtualKey)
+{
+ testMapVirtualKey();
+}
diff --git a/modules/rostests/apitests/user32/testlist.c
b/modules/rostests/apitests/user32/testlist.c
index b372365501c..77a0f4fb343 100644
--- a/modules/rostests/apitests/user32/testlist.c
+++ b/modules/rostests/apitests/user32/testlist.c
@@ -50,6 +50,7 @@ extern void func_ShowWindow(void);
extern void func_SwitchToThisWindow(void);
extern void func_SystemParametersInfo(void);
extern void func_TrackMouseEvent(void);
+extern void func_VirtualKey(void);
extern void func_WndProc(void);
extern void func_wsprintf(void);
@@ -102,6 +103,7 @@ const struct test winetest_testlist[] =
{ "SwitchToThisWindow", func_SwitchToThisWindow },
{ "SystemParametersInfo", func_SystemParametersInfo },
{ "TrackMouseEvent", func_TrackMouseEvent },
+ { "VirtualKey", func_VirtualKey },
{ "WndProc", func_WndProc },
{ "wsprintfApi", func_wsprintf },
{ 0, 0 }