ReactOS 0.4.15-dev-8417-gb6b82fe
KbdLayout.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 Keyboard Layouts DLL files
5 * COPYRIGHT: Copyright 2022 Stanislav Motylkov <x86corez@gmail.com>
6 */
7
8#include "precomp.h"
9#include <ndk/kbd.h>
10#include <strsafe.h>
11
13
14static void testLayout(
15 _In_ LPWSTR szFileName,
17{
19 PFN_KBDLAYERDESCRIPTOR pfnKbdLayerDescriptor;
20 PKBDTABLES pKbdTbl;
21 USHORT i, uTableSize;
22
23 trace("Testing '%ls'...\n", szFileName);
24
26 if (!hModule)
27 {
28 ok(FALSE, "LoadLibraryW failed with code %ld\n", GetLastError());
29 return;
30 }
31
32 pfnKbdLayerDescriptor = (PFN_KBDLAYERDESCRIPTOR)GetProcAddress(hModule, "KbdLayerDescriptor");
33 if (!pfnKbdLayerDescriptor)
34 {
35 ok(FALSE, "KbdLayerDescriptor not found!\n");
36 goto Cleanup;
37 }
38
39 pKbdTbl = pfnKbdLayerDescriptor();
40 if (!pKbdTbl)
41 {
42 ok(FALSE, "PKBDTABLES is NULL!\n");
43 goto Cleanup;
44 }
45
46 if (!pKbdTbl->pusVSCtoVK)
47 {
48 ok(FALSE, "pusVSCtoVK table is NULL!\n");
49 goto Cleanup;
50 }
51
52 if (wcscmp(szFileName, L"kbdnec.dll") == 0)
53 uTableSize = 128; /* Only NEC PC-9800 Japanese keyboard layout has 128 entries. */
54 else
55 uTableSize = 127;
56
57 /* Validate number of entries in pusVSCtoVK array. */
58 ok(pKbdTbl->bMaxVSCtoVK == uTableSize, "pKbdTbl->bMaxVSCtoVK = %u\n", pKbdTbl->bMaxVSCtoVK);
59
60 for (i = 0; i < pKbdTbl->bMaxVSCtoVK; ++i)
61 {
62 /* Make sure there are no Virtual Keys with zero value. */
63 if (pKbdTbl->pusVSCtoVK[i] == 0)
64 ok(FALSE, "Scan Code %u => Virtual Key %u\n", i, pKbdTbl->pusVSCtoVK[i]);
65 }
66
68 if (hModule)
70}
71
72static void testKeyboardLayouts(void)
73{
74 DWORD dwRet;
75 WCHAR szSysPath[MAX_PATH],
76 szPattern[MAX_PATH],
78 HANDLE hFindFile = INVALID_HANDLE_VALUE;
80 BOOL bFound = TRUE;
81
82 dwRet = GetSystemDirectoryW(szSysPath, ARRAYSIZE(szSysPath));
83 if (!dwRet)
84 {
85 skip("GetSystemDirectoryW failed with code %ld\n", GetLastError());
86 return;
87 }
88
89 StringCchCopyW(szPattern, ARRAYSIZE(szPattern), szSysPath);
90 StringCchCatW(szPattern, ARRAYSIZE(szPattern), L"\\kbd*.dll");
91
92 for (hFindFile = FindFirstFileW(szPattern, &wfd);
93 bFound && (hFindFile != INVALID_HANDLE_VALUE);
94 bFound = FindNextFileW(hFindFile, &wfd))
95 {
96 if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
97 continue;
98
102
103 testLayout(wfd.cFileName, szFilePath);
104 }
105
106 if (hFindFile != INVALID_HANDLE_VALUE)
107 FindClose(hFindFile);
108}
109
110START_TEST(KbdLayout)
111{
113}
PVOID(* PFN_KBDLAYERDESCRIPTOR)(VOID)
Definition: KbdLayout.c:12
static void testLayout(_In_ LPWSTR szFileName, _In_ LPWSTR szFilePath)
Definition: KbdLayout.c:14
static void testKeyboardLayouts(void)
Definition: KbdLayout.c:72
#define VOID
Definition: acefi.h:82
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define START_TEST(x)
Definition: atltest.h:75
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
HMODULE hModule
Definition: animate.c:44
#define GetProcAddress(x, y)
Definition: compat.h:753
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define FreeLibrary(x)
Definition: compat.h:748
#define MAX_PATH
Definition: compat.h:34
#define LoadLibraryW(x)
Definition: compat.h:747
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502
BOOL WINAPI FindNextFileW(IN HANDLE hFindFile, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:382
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2313
static const WCHAR Cleanup[]
Definition: register.c:80
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
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 _In_
Definition: ms_sal.h:308
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
#define L(x)
Definition: ntvdm.h:50
unsigned short USHORT
Definition: pedump.c:61
static WCHAR szFilePath[]
Definition: qotd.c:14
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:325
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
Definition: kbd.h:95
BYTE bMaxVSCtoVK
Definition: kbd.h:103
USHORT * pusVSCtoVK
Definition: kbd.h:102
void * PVOID
Definition: typedefs.h:50
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184