ReactOS  0.4.15-dev-5618-g8866b9d
VirtualKey.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS API tests
3  * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4  * PURPOSE: Tests for virtual keys
5  * COPYRIGHT: Copyright 2022 Stanislav Motylkov <x86corez@gmail.com>
6  */
7 
8 #include "precomp.h"
9 
15 #if (NTDDI_VERSION >= NTDDI_VISTA)
17 #endif
18 };
19 
20 struct
21 {
25 } TestCodes[] = {
26  {VK_TAB, 0, 15},
27  {VK_RETURN, 0, 28},
28  {VK_CONTROL, 0, 29},
29  {VK_LCONTROL, VK_CONTROL, 29},
30  {VK_RCONTROL, VK_CONTROL, 29},
31  {VK_MENU, 0, 56},
32  {VK_SPACE, 0, 57},
33 };
34 
35 static void testMapVirtualKey()
36 {
37  INT i;
38  UINT vCode, vExpect = 0;
39 
40  /* Make sure MapVirtualKeyW returns 0 in all cases when uCode == 0 */
41  for (i = 0; i < _countof(MapTypes); i++)
42  {
43  vCode = MapVirtualKeyW(0, MapTypes[i]);
44  ok(vCode == vExpect, "[%d] Returned %u, expected %u\n", i, vCode, vExpect);
45  }
46 
47  /* Test matching between virtual keys and scan codes */
48  for (i = 0; i < _countof(TestCodes); i++)
49  {
51  vExpect = TestCodes[i].ScanCode;
52  ok(vCode == vExpect, "[%d] ScanCode = %u, expected %u\n", i, vCode, vExpect);
53 
55  vExpect = (TestCodes[i].ScanToVirt == 0 ? TestCodes[i].VirtKey : TestCodes[i].ScanToVirt);
56  ok(vCode == vExpect, "[%d] VirtKey = %u, expected %u\n", i, vCode, vExpect);
57  }
58 }
59 
60 START_TEST(VirtualKey)
61 {
63 }
UINT ScanToVirt
Definition: VirtualKey.c:23
UINT ScanCode
Definition: VirtualKey.c:24
#define VK_TAB
Definition: winuser.h:2189
#define VK_MENU
Definition: winuser.h:2194
#define MAPVK_VSC_TO_VK_EX
Definition: winuser.h:2348
int32_t INT
Definition: typedefs.h:58
#define VK_RETURN
Definition: winuser.h:2191
UINT VirtKey
Definition: VirtualKey.c:22
UINT WINAPI MapVirtualKeyW(_In_ UINT, _In_ UINT)
#define MAPVK_VSC_TO_VK
Definition: winuser.h:2346
UINT MapTypes[]
Definition: VirtualKey.c:10
#define MAPVK_VK_TO_VSC
Definition: winuser.h:2345
#define _countof(array)
Definition: sndvol32.h:68
#define MAPVK_VK_TO_VSC_EX
Definition: winuser.h:2349
#define VK_RCONTROL
Definition: winuser.h:2275
START_TEST(VirtualKey)
Definition: VirtualKey.c:60
#define MAPVK_VK_TO_CHAR
Definition: winuser.h:2347
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define ok(value,...)
Definition: atltest.h:57
struct @1565 TestCodes[]
unsigned int UINT
Definition: ndis.h:50
#define VK_SPACE
Definition: winuser.h:2209
#define VK_CONTROL
Definition: winuser.h:2193
static void testMapVirtualKey()
Definition: VirtualKey.c:35
#define VK_LCONTROL
Definition: winuser.h:2274