mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 09:34:43 +00:00
[USER32_APITEST] Add tests for Keyboard Layouts
CORE-17906
This commit is contained in:
parent
badd97043f
commit
6aacfa93c0
3 changed files with 116 additions and 0 deletions
|
@ -23,6 +23,7 @@ list(APPEND SOURCE
|
|||
GetUserObjectInformation.c
|
||||
GetWindowPlacement.c
|
||||
InitializeLpkHooks.c
|
||||
KbdLayout.c
|
||||
keybd_event.c
|
||||
LoadImage.c
|
||||
LookupIconIdFromDirectoryEx.c
|
||||
|
|
113
modules/rostests/apitests/user32/KbdLayout.c
Normal file
113
modules/rostests/apitests/user32/KbdLayout.c
Normal file
|
@ -0,0 +1,113 @@
|
|||
/*
|
||||
* PROJECT: ReactOS API tests
|
||||
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
|
||||
* PURPOSE: Tests for Keyboard Layouts DLL files
|
||||
* COPYRIGHT: Copyright 2022 Stanislav Motylkov <x86corez@gmail.com>
|
||||
*/
|
||||
|
||||
#include "precomp.h"
|
||||
#include <ndk/kbd.h>
|
||||
#include <strsafe.h>
|
||||
|
||||
typedef PVOID (*PFN_KBDLAYERDESCRIPTOR)(VOID);
|
||||
|
||||
static void testLayout(
|
||||
_In_ LPWSTR szFileName,
|
||||
_In_ LPWSTR szFilePath)
|
||||
{
|
||||
HMODULE hModule;
|
||||
PFN_KBDLAYERDESCRIPTOR pfnKbdLayerDescriptor;
|
||||
PKBDTABLES pKbdTbl;
|
||||
USHORT i, uTableSize;
|
||||
|
||||
trace("Testing '%ls'...\n", szFileName);
|
||||
|
||||
hModule = LoadLibraryW(szFilePath);
|
||||
if (!hModule)
|
||||
{
|
||||
ok(FALSE, "LoadLibraryW failed with code %ld\n", GetLastError());
|
||||
return;
|
||||
}
|
||||
|
||||
pfnKbdLayerDescriptor = (PFN_KBDLAYERDESCRIPTOR)GetProcAddress(hModule, "KbdLayerDescriptor");
|
||||
if (!pfnKbdLayerDescriptor)
|
||||
{
|
||||
ok(FALSE, "KbdLayerDescriptor not found!\n");
|
||||
goto Cleanup;
|
||||
}
|
||||
|
||||
pKbdTbl = pfnKbdLayerDescriptor();
|
||||
if (!pKbdTbl)
|
||||
{
|
||||
ok(FALSE, "PKBDTABLES is NULL!\n");
|
||||
goto Cleanup;
|
||||
}
|
||||
|
||||
if (!pKbdTbl->pusVSCtoVK)
|
||||
{
|
||||
ok(FALSE, "pusVSCtoVK table is NULL!\n");
|
||||
goto Cleanup;
|
||||
}
|
||||
|
||||
if (wcscmp(szFileName, L"kbdnec.dll") == 0)
|
||||
uTableSize = 128; /* Only NEC PC-9800 Japanese keyboard layout has 128 entries. */
|
||||
else
|
||||
uTableSize = 127;
|
||||
|
||||
/* Validate number of entries in pusVSCtoVK array. */
|
||||
ok(pKbdTbl->bMaxVSCtoVK == uTableSize, "pKbdTbl->bMaxVSCtoVK = %u\n", pKbdTbl->bMaxVSCtoVK);
|
||||
|
||||
for (i = 0; i < pKbdTbl->bMaxVSCtoVK; ++i)
|
||||
{
|
||||
/* Make sure there are no Virtual Keys with zero value. */
|
||||
if (pKbdTbl->pusVSCtoVK[i] == 0)
|
||||
ok(FALSE, "Scan Code %u => Virtual Key %u\n", i, pKbdTbl->pusVSCtoVK[i]);
|
||||
}
|
||||
|
||||
Cleanup:
|
||||
if (hModule)
|
||||
FreeLibrary(hModule);
|
||||
}
|
||||
|
||||
static void testKeyboardLayouts(void)
|
||||
{
|
||||
DWORD dwRet;
|
||||
WCHAR szSysPath[MAX_PATH],
|
||||
szPattern[MAX_PATH],
|
||||
szFilePath[MAX_PATH];
|
||||
HANDLE hFindFile = INVALID_HANDLE_VALUE;
|
||||
WIN32_FIND_DATAW wfd;
|
||||
BOOL bFound = TRUE;
|
||||
|
||||
dwRet = GetSystemDirectoryW(szSysPath, ARRAYSIZE(szSysPath));
|
||||
if (!dwRet)
|
||||
{
|
||||
skip("GetSystemDirectoryW failed with code %ld\n", GetLastError());
|
||||
return;
|
||||
}
|
||||
|
||||
StringCchCopyW(szPattern, ARRAYSIZE(szPattern), szSysPath);
|
||||
StringCchCatW(szPattern, ARRAYSIZE(szPattern), L"\\kbd*.dll");
|
||||
|
||||
for (hFindFile = FindFirstFileW(szPattern, &wfd);
|
||||
bFound && (hFindFile != INVALID_HANDLE_VALUE);
|
||||
bFound = FindNextFileW(hFindFile, &wfd))
|
||||
{
|
||||
if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
continue;
|
||||
|
||||
StringCchCopyW(szFilePath, ARRAYSIZE(szFilePath), szSysPath);
|
||||
StringCchCatW(szFilePath, ARRAYSIZE(szFilePath), L"\\");
|
||||
StringCchCatW(szFilePath, ARRAYSIZE(szFilePath), wfd.cFileName);
|
||||
|
||||
testLayout(wfd.cFileName, szFilePath);
|
||||
}
|
||||
|
||||
if (hFindFile != INVALID_HANDLE_VALUE)
|
||||
FindClose(hFindFile);
|
||||
}
|
||||
|
||||
START_TEST(KbdLayout)
|
||||
{
|
||||
testKeyboardLayouts();
|
||||
}
|
|
@ -25,6 +25,7 @@ extern void func_GetSystemMetrics(void);
|
|||
extern void func_GetUserObjectInformation(void);
|
||||
extern void func_GetWindowPlacement(void);
|
||||
extern void func_InitializeLpkHooks(void);
|
||||
extern void func_KbdLayout(void);
|
||||
extern void func_keybd_event(void);
|
||||
extern void func_LoadImage(void);
|
||||
extern void func_LookupIconIdFromDirectoryEx(void);
|
||||
|
@ -78,6 +79,7 @@ const struct test winetest_testlist[] =
|
|||
{ "GetUserObjectInformation", func_GetUserObjectInformation },
|
||||
{ "GetWindowPlacement", func_GetWindowPlacement },
|
||||
{ "InitializeLpkHooks", func_InitializeLpkHooks },
|
||||
{ "KbdLayout", func_KbdLayout },
|
||||
{ "keybd_event", func_keybd_event },
|
||||
{ "LoadImage", func_LoadImage },
|
||||
{ "LookupIconIdFromDirectoryEx", func_LookupIconIdFromDirectoryEx },
|
||||
|
|
Loading…
Reference in a new issue