2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for RealGetWindowClass
5 * PROGRAMMERS: Gregor Gullwi
10 static PWSTR ControlsList
[] =
24 L
"DDEMLUnicodeClient\0",
26 L
"DDEMLUnicodeServer\0",
28 L
"\0",//L"Ghost\0", // Vista+, Ghost is registered after "Message" in XP/W2k3 Win32k.sys.
31 typedef struct _TestData
33 BOOL OverrideWndProc
; /* TRUE if lpfnWndProc should be overridden */
34 LPCSTR ClassName
; /* Name of the new class to register */
35 DWORD WndExtra
; /* Remove these WNDCLASS::cbWndExtra flags */
36 BOOL ExpectsHwnd
; /* TRUE if a HWND should be created to run tests on */
37 LPCSTR ExpectedClassNameBefore
; /* Expected class name before any dialog function is called */
38 LPCSTR ExpectedClassNameAfter
; /* Expected class name after any dialog function is called */
41 static TestData RealClassTestData
[] =
45 "OverrideWndProc_with_DLGWINDOWEXTRA_TRUE",
48 "OverrideWndProc_with_DLGWINDOWEXTRA_TRUE",
53 "OverrideWndProc_without_DLGWINDOWEXTRA_TRUE",
56 "OverrideWndProc_without_DLGWINDOWEXTRA_TRUE",
57 "OverrideWndProc_without_DLGWINDOWEXTRA_TRUE",
61 "DefaultWndProc_with_DLGWINDOWEXTRA_FALSE",
69 "DefaultWndProc_without_DLGWINDOWEXTRA_FALSE",
78 // The Control Class Atoms are consecitively issued.
81 void Test_ClassAtoms()
87 // Initialize starting Atom number.
88 atom
= GetClassInfoW(NULL
, ControlsList
[0], &cls
);
91 skip( "No reference Atom\n" );
95 trace("First Control Class Atom 0x%x\n",atom
);
97 for (i
= 0; i
< 17; atom
++ ,i
++)
99 if (lstrcmpW(ControlsList
[i
],L
"\0"))
101 ATOM test_atom
= GetClassInfoW(NULL
, ControlsList
[i
], &cls
);
102 // Skip unregistered Classes.
105 ok(test_atom
== atom
, "%S class atom did not match %x:%x\n",ControlsList
[i
],test_atom
,atom
);
106 ok(!lstrcmpW(cls
.lpszClassName
,ControlsList
[i
]),"GetClassName returned incorrect name\n");
112 void Test_RealGetWindowClass()
118 Result
= RealGetWindowClass( NULL
, Buffer
, ARRAY_SIZE(Buffer
) );
119 ok(Result
== 0, "Result = %d\n", Result
);
120 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
, "GetLastError() = %ld\n", GetLastError());
122 for (testNo
= 0; testNo
< ARRAY_SIZE(RealClassTestData
); testNo
++)
128 /* Register classes, "derived" from built-in dialog, with and without the DLGWINDOWEXTRA flag set */
129 GetClassInfoA(0, "#32770", &cls
);
130 if (RealClassTestData
[testNo
].OverrideWndProc
)
131 cls
.lpfnWndProc
= DefWindowProcA
;
132 cls
.lpszClassName
= RealClassTestData
[testNo
].ClassName
;
133 cls
.cbWndExtra
&= ~RealClassTestData
[testNo
].WndExtra
;
134 atom
= RegisterClassA (&cls
);
135 if (atom
== 0) return;
137 /* Create a window */
138 hWnd
= CreateWindowEx( WS_EX_LEFT
| WS_EX_LTRREADING
| WS_EX_RIGHTSCROLLBAR
|
139 WS_EX_DLGMODALFRAME
| WS_EX_WINDOWEDGE
| WS_EX_CONTROLPARENT
| WS_EX_APPWINDOW
,
140 RealClassTestData
[testNo
].ClassName
,
141 RealClassTestData
[testNo
].ClassName
,
142 WS_POPUPWINDOW
| WS_CLIPSIBLINGS
| WS_DLGFRAME
| WS_OVERLAPPED
|
143 WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
| DS_3DLOOK
| DS_SETFONT
| DS_MODALFRAME
,
144 CW_USEDEFAULT
, CW_USEDEFAULT
, 100, 100,
147 /* Do we expect a HWND at all? */
148 if (RealClassTestData
[testNo
].ExpectsHwnd
)
150 ok(hWnd
!= NULL
, "\n");
154 /* Get the "real" class name */
155 Result
= RealGetWindowClass( hWnd
, Buffer
, ARRAY_SIZE(Buffer
) );
156 printf("Buffer: %s\nExpectedClassNameBefore(%d): %s\n", Buffer
, testNo
, RealClassTestData
[testNo
].ExpectedClassNameBefore
);
157 ok( Result
!= 0, "\n" );
158 ok( strcmp( Buffer
, RealClassTestData
[testNo
].ExpectedClassNameBefore
) == 0, "\n" );
160 /* Call a function that requires a dialog window */
161 DefDlgProcA( hWnd
, DM_SETDEFID
, IDCANCEL
, 0 );
163 /* Get the "real" class name again */
164 Result
= RealGetWindowClass( hWnd
, Buffer
, ARRAY_SIZE(Buffer
) );
165 printf("Buffer: %s\nExpectedClassNameAfter(%d): %s\n", Buffer
, testNo
, RealClassTestData
[testNo
].ExpectedClassNameAfter
);
166 ok( Result
!= 0, "\n" );
167 ok( strcmp( Buffer
, RealClassTestData
[testNo
].ExpectedClassNameAfter
) == 0, "\n" );
172 ok(hWnd
== NULL
, "\n");
177 UnregisterClass(RealClassTestData
[testNo
].ClassName
, 0);
182 START_TEST(RealGetWindowClass
)
185 Test_RealGetWindowClass();