2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for RealGetWindowClass
5 * PROGRAMMERS: Gregor Gullwi
13 #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
15 static PWSTR ControlsList
[] =
29 L
"DDEMLUnicodeClient\0",
31 L
"DDEMLUnicodeServer\0",
33 L
"\0",//L"Ghost\0", // Vista+, Ghost is registered after "Message" in XP/W2k3 Win32k.sys.
36 typedef struct _TestData
38 BOOL OverrideWndProc
; /* TRUE if lpfnWndProc should be overridden */
39 LPCSTR ClassName
; /* Name of the new class to register */
40 DWORD WndExtra
; /* Remove these WNDCLASS::cbWndExtra flags */
41 BOOL ExpectsHwnd
; /* TRUE if a HWND should be created to run tests on */
42 LPCSTR ExpectedClassNameBefore
; /* Expected class name before any dialog function is called */
43 LPCSTR ExpectedClassNameAfter
; /* Expected class name after any dialog function is called */
46 static TestData RealClassTestData
[] =
50 "OverrideWndProc_with_DLGWINDOWEXTRA_TRUE",
53 "OverrideWndProc_with_DLGWINDOWEXTRA_TRUE",
58 "OverrideWndProc_without_DLGWINDOWEXTRA_TRUE",
61 "OverrideWndProc_without_DLGWINDOWEXTRA_TRUE",
62 "OverrideWndProc_without_DLGWINDOWEXTRA_TRUE",
66 "DefaultWndProc_with_DLGWINDOWEXTRA_FALSE",
74 "DefaultWndProc_without_DLGWINDOWEXTRA_FALSE",
83 // The Control Class Atoms are consecitively issued.
86 void Test_ClassAtoms()
92 // Initialize starting Atom number.
93 atom
= GetClassInfoW(NULL
, ControlsList
[0], &cls
);
96 skip( "No reference Atom\n" );
100 trace("First Control Class Atom 0x%x\n",atom
);
102 for (i
= 0; i
< 17; atom
++ ,i
++)
104 if (lstrcmpW(ControlsList
[i
],L
"\0"))
106 ATOM test_atom
= GetClassInfoW(NULL
, ControlsList
[i
], &cls
);
107 // Skip unregistered Classes.
110 ok(test_atom
== atom
, "%S class atom did not match %x:%x\n",ControlsList
[i
],test_atom
,atom
);
111 ok(!lstrcmpW(cls
.lpszClassName
,ControlsList
[i
]),"GetClassName returned incorrect name\n");
117 void Test_RealGetWindowClass()
123 Result
= RealGetWindowClass( NULL
, Buffer
, ARRAY_SIZE(Buffer
) );
124 ok(Result
== 0, "Result = %d\n", Result
);
125 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
, "GetLastError() = %ld\n", GetLastError());
127 for (testNo
= 0; testNo
< ARRAY_SIZE(RealClassTestData
); testNo
++)
133 /* Register classes, "derived" from built-in dialog, with and without the DLGWINDOWEXTRA flag set */
134 GetClassInfoA(0, "#32770", &cls
);
135 if (RealClassTestData
[testNo
].OverrideWndProc
)
136 cls
.lpfnWndProc
= DefWindowProcA
;
137 cls
.lpszClassName
= RealClassTestData
[testNo
].ClassName
;
138 cls
.cbWndExtra
&= ~RealClassTestData
[testNo
].WndExtra
;
139 atom
= RegisterClassA (&cls
);
140 if (atom
== 0) return;
142 /* Create a window */
143 hWnd
= CreateWindowEx( WS_EX_LEFT
| WS_EX_LTRREADING
| WS_EX_RIGHTSCROLLBAR
|
144 WS_EX_DLGMODALFRAME
| WS_EX_WINDOWEDGE
| WS_EX_CONTROLPARENT
| WS_EX_APPWINDOW
,
145 RealClassTestData
[testNo
].ClassName
,
146 RealClassTestData
[testNo
].ClassName
,
147 WS_POPUPWINDOW
| WS_CLIPSIBLINGS
| WS_DLGFRAME
| WS_OVERLAPPED
|
148 WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
| DS_3DLOOK
| DS_SETFONT
| DS_MODALFRAME
,
149 CW_USEDEFAULT
, CW_USEDEFAULT
, 100, 100,
152 /* Do we expect a HWND at all? */
153 if (RealClassTestData
[testNo
].ExpectsHwnd
)
155 ok(hWnd
!= NULL
, "\n");
159 /* Get the "real" class name */
160 Result
= RealGetWindowClass( hWnd
, Buffer
, ARRAY_SIZE(Buffer
) );
161 printf("Buffer: %s\nExpectedClassNameBefore(%d): %s\n", Buffer
, testNo
, RealClassTestData
[testNo
].ExpectedClassNameBefore
);
162 ok( Result
!= 0, "\n" );
163 ok( strcmp( Buffer
, RealClassTestData
[testNo
].ExpectedClassNameBefore
) == 0, "\n" );
165 /* Call a function that requires a dialog window */
166 DefDlgProcA( hWnd
, DM_SETDEFID
, IDCANCEL
, 0 );
168 /* Get the "real" class name again */
169 Result
= RealGetWindowClass( hWnd
, Buffer
, ARRAY_SIZE(Buffer
) );
170 printf("Buffer: %s\nExpectedClassNameAfter(%d): %s\n", Buffer
, testNo
, RealClassTestData
[testNo
].ExpectedClassNameAfter
);
171 ok( Result
!= 0, "\n" );
172 ok( strcmp( Buffer
, RealClassTestData
[testNo
].ExpectedClassNameAfter
) == 0, "\n" );
177 ok(hWnd
== NULL
, "\n");
182 UnregisterClass(RealClassTestData
[testNo
].ClassName
, 0);
187 START_TEST(RealGetWindowClass
)
190 Test_RealGetWindowClass();