https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c7fd9983cbeb8a172f427…
commit c7fd9983cbeb8a172f427cec87c72cb138c9d4cb
Author: Timo Kreuzer <timo.kreuzer(a)reactos.org>
AuthorDate: Fri May 12 22:28:54 2023 +0300
Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org>
CommitDate: Tue May 16 21:59:19 2023 +0300
[USER32_APITEST] Add tests for GetClassInfo
---
modules/rostests/apitests/user32/CMakeLists.txt | 1 +
modules/rostests/apitests/user32/GetClassInfo.c | 170 +++++++++++++++++++++
modules/rostests/apitests/user32/testlist.c | 2 +
.../apitests/win32nt/ntuser/NtUserGetClassInfo.c | 5 +
4 files changed, 178 insertions(+)
diff --git a/modules/rostests/apitests/user32/CMakeLists.txt
b/modules/rostests/apitests/user32/CMakeLists.txt
index 2ee5e76b815..4ab323f327c 100644
--- a/modules/rostests/apitests/user32/CMakeLists.txt
+++ b/modules/rostests/apitests/user32/CMakeLists.txt
@@ -15,6 +15,7 @@ list(APPEND SOURCE
desktop.c
EmptyClipboard.c
EnumDisplaySettings.c
+ GetClassInfo.c
GetDCEx.c
GetIconInfo.c
GetKeyState.c
diff --git a/modules/rostests/apitests/user32/GetClassInfo.c
b/modules/rostests/apitests/user32/GetClassInfo.c
new file mode 100644
index 00000000000..37862c5d1db
--- /dev/null
+++ b/modules/rostests/apitests/user32/GetClassInfo.c
@@ -0,0 +1,170 @@
+/*
+ * PROJECT: ReactOS api tests
+ * LICENSE: GPL-2.0+ (
https://spdx.org/licenses/GPL-2.0+)
+ * PURPOSE: Tests for GetClassInfo
+ * COPYRIGHT: Copyright 2023 Timo Kreuzer <timo.kreuzer(a)reactos.org>
+ */
+
+#include "precomp.h"
+
+static USHORT GetWinVersion(VOID)
+{
+ return ((GetVersion() & 0xFF) << 8) |
+ ((GetVersion() >> 8) & 0xFF);
+}
+
+VOID Test_Desktop(VOID)
+{
+ WNDCLASSEXW wcex;
+ BOOL result;
+
+ memset(&wcex, 0xab, sizeof(wcex));
+
+ result = GetClassInfoExW(GetModuleHandle(NULL), (LPCWSTR)WC_DESKTOP, &wcex);
+ ok_int(result, (ULONG_PTR)WC_DESKTOP);
+
+ ok_hex(wcex.cbSize, 0xabababab);
+ ok_hex(wcex.style, 0x8);
+ ok(wcex.lpfnWndProc != NULL, "lpfnWndProc shound't be NULL\n");
+ ok_int(wcex.cbClsExtra, 0);
+ ok_int(wcex.cbWndExtra, GetWinVersion() <= 0x502 ? 8 : 0);
+ ok_ptr(wcex.hInstance, GetModuleHandle(NULL));
+ ok_ptr(wcex.hIcon, NULL);
+ ok(wcex.hCursor != NULL, "hCursor shound't be NULL\n");
+ if (GetWinVersion() > 0x502)
+ ok_ptr(wcex.hbrBackground, (HBRUSH)(ULONG_PTR)2);
+ else
+ ok(wcex.hbrBackground != NULL, "hbrBackground shound't be
NULL\n");
+ ok_ptr(wcex.lpszMenuName, NULL);
+ ok_ptr(wcex.lpszClassName, (LPCWSTR)WC_DESKTOP);
+ ok_ptr(wcex.hIconSm, NULL);
+}
+
+VOID Test_Dialog(VOID)
+{
+ WNDCLASSEXW wcex;
+ BOOL result;
+
+ memset(&wcex, 0xab, sizeof(wcex));
+
+ result = GetClassInfoExW(GetModuleHandle(NULL), (LPCWSTR)(ULONG_PTR)WC_DIALOG,
&wcex);
+ ok_int(result, (ULONG_PTR)WC_DIALOG);
+
+ ok_hex(wcex.cbSize, 0xabababab);
+ ok_hex(wcex.style, 0x808);
+ ok(wcex.lpfnWndProc != NULL, "lpfnWndProc shound't be NULL\n");
+ ok_int(wcex.cbClsExtra, 0);
+ ok_int(wcex.cbWndExtra, 30); // DLGWINDOWEXTRA
+ ok_ptr(wcex.hInstance, GetModuleHandle(NULL));
+ ok_ptr(wcex.hIcon, NULL);
+ ok(wcex.hCursor != NULL, "hCursor shound't be NULL\n");
+ ok_ptr(wcex.hbrBackground, NULL);
+ ok_ptr(wcex.lpszMenuName, NULL);
+ ok_ptr(wcex.lpszClassName, (LPCWSTR)(ULONG_PTR)WC_DIALOG);
+ ok_ptr(wcex.hIconSm, NULL);
+}
+
+VOID Test_Menu(VOID)
+{
+ WNDCLASSEXW wcex;
+ BOOL result;
+
+ memset(&wcex, 0xab, sizeof(wcex));
+
+ result = GetClassInfoExW(GetModuleHandle(NULL), (LPCWSTR)(ULONG_PTR)WC_MENU,
&wcex);
+ ok_int(result, (ULONG_PTR)WC_MENU);
+
+ ok_hex(wcex.cbSize, 0xabababab);
+ ok_hex(wcex.style, 0x803);
+ ok_ptr(wcex.lpfnWndProc, NULL);
+ ok_int(wcex.cbClsExtra, 0);
+ ok_int(wcex.cbWndExtra, 16);
+ ok_ptr(wcex.hInstance, GetModuleHandle(NULL));
+ ok_ptr(wcex.hIcon, NULL);
+ ok(wcex.hCursor != NULL, "hCursor shound't be NULL\n");
+ ok_ptr(wcex.hbrBackground, NULL);
+ ok_ptr(wcex.lpszMenuName, NULL);
+ ok_ptr(wcex.lpszClassName, (LPCWSTR)(ULONG_PTR)WC_MENU);
+ ok_ptr(wcex.hIconSm, NULL);
+}
+
+
+VOID Test_SwitchWnd(VOID)
+{
+ WNDCLASSEXW wcex;
+ BOOL result;
+
+ memset(&wcex, 0xab, sizeof(wcex));
+
+ result = GetClassInfoExW(GetModuleHandle(NULL), (LPCWSTR)(ULONG_PTR)WC_SWITCH,
&wcex);
+ ok_int(result, (ULONG_PTR)WC_SWITCH);
+
+ ok_hex(wcex.cbSize, 0xabababab);
+ ok_hex(wcex.style, 0x803);
+ ok_ptr(wcex.lpfnWndProc, NULL);
+ ok_int(wcex.cbClsExtra, 0);
+ ok_int(wcex.cbWndExtra, GetWinVersion() <= 0x502 ? sizeof(ULONG_PTR) : 16);
+ ok_ptr(wcex.hInstance, GetModuleHandle(NULL));
+ ok_ptr(wcex.hIcon, NULL);
+ ok(wcex.hCursor != NULL, "hCursor shound't be NULL\n");
+ ok_ptr(wcex.hbrBackground, NULL);
+ ok_ptr(wcex.lpszMenuName, NULL);
+ ok_ptr(wcex.lpszClassName, (LPCWSTR)(ULONG_PTR)WC_SWITCH);
+ ok_ptr(wcex.hIconSm, NULL);
+}
+
+VOID Test_Custom(VOID)
+{
+ WNDCLASSEXW wcex;
+ ATOM atom;
+ BOOL result;
+
+ memset(&wcex, 0, sizeof(wcex));
+
+ wcex.cbSize = sizeof(WNDCLASSEXW);
+ wcex.style = 0x1;
+ wcex.lpfnWndProc = DefWindowProcW;
+ wcex.cbClsExtra = 1;
+ wcex.cbWndExtra = 5;
+ wcex.hInstance = GetModuleHandle(NULL);
+ wcex.hIcon = NULL;
+ wcex.hCursor = NULL;
+ wcex.hbrBackground = NULL;
+ wcex.lpszMenuName = NULL;
+ wcex.lpszClassName = L"ProTestClass1";
+ wcex.hIconSm = 0;
+
+ atom = RegisterClassExW(&wcex);
+ ok(atom != 0, "Failed to register class!\n");
+ if (atom == 0)
+ {
+ skip("Failed to register class!");
+ return;
+ }
+
+ memset(&wcex, 0xab, sizeof(wcex));
+
+ result = GetClassInfoExW(GetModuleHandle(NULL), (LPCWSTR)(ULONG_PTR)atom,
&wcex);
+ ok_int(result, atom);
+
+ ok_hex(wcex.cbSize, 0xabababab);
+ ok_hex(wcex.style, 0x1);
+ ok_ptr(wcex.lpfnWndProc, DefWindowProcW);
+ ok_int(wcex.cbClsExtra, 1);
+ ok_int(wcex.cbWndExtra, 5);
+ ok_ptr(wcex.hInstance, GetModuleHandle(NULL));
+ ok_ptr(wcex.hIcon, NULL);
+ ok_ptr(wcex.hIcon, NULL);
+ ok_ptr(wcex.hbrBackground, NULL);
+ ok_ptr(wcex.lpszMenuName, NULL);
+ ok_ptr(wcex.lpszClassName, (LPCWSTR)(ULONG_PTR)atom);
+ ok_ptr(wcex.hIconSm, NULL);
+}
+
+START_TEST(GetClassInfo)
+{
+ Test_Desktop();
+ Test_Dialog();
+ Test_SwitchWnd();
+ Test_Custom();
+}
diff --git a/modules/rostests/apitests/user32/testlist.c
b/modules/rostests/apitests/user32/testlist.c
index 9b351182afb..ee6f6970d76 100644
--- a/modules/rostests/apitests/user32/testlist.c
+++ b/modules/rostests/apitests/user32/testlist.c
@@ -17,6 +17,7 @@ extern void func_DrawText(void);
extern void func_desktop(void);
extern void func_EmptyClipboard(void);
extern void func_EnumDisplaySettings(void);
+extern void func_GetClassInfo(void);
extern void func_GetDCEx(void);
extern void func_GetIconInfo(void);
extern void func_GetKeyState(void);
@@ -73,6 +74,7 @@ const struct test winetest_testlist[] =
{ "desktop", func_desktop },
{ "EmptyClipboard", func_EmptyClipboard },
{ "EnumDisplaySettings", func_EnumDisplaySettings },
+ { "GetClassInfo", func_GetClassInfo },
{ "GetDCEx", func_GetDCEx },
{ "GetIconInfo", func_GetIconInfo },
{ "GetKeyState", func_GetKeyState },
diff --git a/modules/rostests/apitests/win32nt/ntuser/NtUserGetClassInfo.c
b/modules/rostests/apitests/win32nt/ntuser/NtUserGetClassInfo.c
index 1e2a8a79265..65002ced27a 100644
--- a/modules/rostests/apitests/win32nt/ntuser/NtUserGetClassInfo.c
+++ b/modules/rostests/apitests/win32nt/ntuser/NtUserGetClassInfo.c
@@ -14,6 +14,11 @@ START_TEST(NtUserGetClassInfo)
UNICODE_STRING us;
PWSTR pwstr = NULL;
+#ifdef _M_AMD64
+ skip("Test is broken on x64.\n");
+ return;
+#endif
+
us.Length = 8;
us.MaximumLength = 8;
us.Buffer = L"test";