ReactOS  0.4.12-dev-918-g6c6e7b8
RealGetWindowClass.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS api tests
3  * LICENSE: GPL - See COPYING in the top level directory
4  * PURPOSE: Test for RealGetWindowClass
5  * PROGRAMMERS: Gregor Gullwi
6  */
7 
8 #include "precomp.h"
9 
10 static PWSTR ControlsList[] =
11 {
12  L"Button\0",
13  L"Edit\0",
14  L"Static\0",
15  L"ListBox\0",
16  L"ScrollBar\0",
17  L"ComboBox\0",
18  L"MDIClient\0",
19  L"ComboLBox\0",
20  L"DDEMLEvent\0",
21  L"DDEMLMom\0",
22  L"DMGClass\0",
23  L"DDEMLAnsiClient\0",
24  L"DDEMLUnicodeClient\0",
25  L"DDEMLAnsiServer\0",
26  L"DDEMLUnicodeServer\0",
27  L"IME\0",
28  L"\0",//L"Ghost\0", // Vista+, Ghost is registered after "Message" in XP/W2k3 Win32k.sys.
29 };
30 
31 typedef struct _TestData
32 {
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 */
39 } TestData;
40 
42 {
43  {
44  TRUE,
45  "OverrideWndProc_with_DLGWINDOWEXTRA_TRUE",
46  0,
47  TRUE,
48  "OverrideWndProc_with_DLGWINDOWEXTRA_TRUE",
49  "#32770",
50  },
51  {
52  TRUE,
53  "OverrideWndProc_without_DLGWINDOWEXTRA_TRUE",
55  TRUE,
56  "OverrideWndProc_without_DLGWINDOWEXTRA_TRUE",
57  "OverrideWndProc_without_DLGWINDOWEXTRA_TRUE",
58  },
59  {
60  FALSE,
61  "DefaultWndProc_with_DLGWINDOWEXTRA_FALSE",
62  0,
63  TRUE,
64  "#32770",
65  "#32770",
66  },
67  {
68  FALSE,
69  "DefaultWndProc_without_DLGWINDOWEXTRA_FALSE",
71  FALSE,
72  "N/A",
73  "N/A",
74  },
75 };
76 
77 //
78 // The Control Class Atoms are consecitively issued.
79 //
80 
82 {
83  ATOM atom;
84  int i;
85  WNDCLASSW cls;
86 
87  // Initialize starting Atom number.
88  atom = GetClassInfoW(NULL, ControlsList[0], &cls);
89  if (!atom)
90  {
91  skip( "No reference Atom\n" );
92  return;
93  }
94 
95  trace("First Control Class Atom 0x%x\n",atom);
96 
97  for (i = 0; i < 17; atom++ ,i++)
98  {
99  if (lstrcmpW(ControlsList[i],L"\0"))
100  {
101  ATOM test_atom = GetClassInfoW(NULL, ControlsList[i], &cls);
102  // Skip unregistered Classes.
103  if (test_atom)
104  {
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");
107  }
108  }
109  }
110 }
111 
113 {
114  int testNo;
115  UINT Result;
116  CHAR Buffer[1024];
117 
119  ok(Result == 0, "Result = %d\n", Result);
120  ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "GetLastError() = %ld\n", GetLastError());
121 
122  for (testNo = 0; testNo < ARRAY_SIZE(RealClassTestData); testNo++)
123  {
124  ATOM atom;
125  WNDCLASSA cls;
126  HWND hWnd;
127 
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)
132  cls.lpszClassName = RealClassTestData[testNo].ClassName;
133  cls.cbWndExtra &= ~RealClassTestData[testNo].WndExtra;
134  atom = RegisterClassA (&cls);
135  if (atom == 0) return;
136 
137  /* Create a window */
140  RealClassTestData[testNo].ClassName,
141  RealClassTestData[testNo].ClassName,
144  CW_USEDEFAULT, CW_USEDEFAULT, 100, 100,
145  NULL, NULL, 0, 0);
146 
147  /* Do we expect a HWND at all? */
148  if (RealClassTestData[testNo].ExpectsHwnd)
149  {
150  ok(hWnd != NULL, "\n");
151 
152  if (hWnd != NULL)
153  {
154  /* Get the "real" class name */
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" );
159 
160  /* Call a function that requires a dialog window */
162 
163  /* Get the "real" class name again */
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" );
168  }
169  }
170  else
171  {
172  ok(hWnd == NULL, "\n");
173  }
174 
175  /* Cleanup */
177  UnregisterClass(RealClassTestData[testNo].ClassName, 0);
178  }
179 
180 }
181 
183 {
184  Test_ClassAtoms();
186 }
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define WS_POPUPWINDOW
Definition: pedump.c:638
#define WS_EX_WINDOWEDGE
Definition: winuser.h:407
#define trace(...)
Definition: kmt_test.h:217
#define TRUE
Definition: types.h:120
WORD ATOM
Definition: dimm.idl:113
#define WS_EX_LTRREADING
Definition: winuser.h:393
uint16_t * PWSTR
Definition: typedefs.h:54
LRESULT WINAPI DefDlgProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
LPCSTR ExpectedClassNameBefore
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
char CHAR
Definition: xmlstorage.h:175
HWND hWnd
Definition: settings.c:17
#define WS_DLGFRAME
Definition: pedump.c:626
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define DM_SETDEFID
Definition: winuser.h:2060
BOOL WINAPI DestroyWindow(_In_ HWND)
#define DS_MODALFRAME
Definition: winuser.h:375
int cbWndExtra
Definition: winuser.h:3119
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 WS_EX_CONTROLPARENT
Definition: winuser.h:387
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI GetClassInfoA(_In_opt_ HINSTANCE, _In_ LPCSTR, _Out_ LPWNDCLASSA)
#define CreateWindowEx
Definition: winuser.h:5621
#define CW_USEDEFAULT
Definition: winuser.h:225
START_TEST(RealGetWindowClass)
smooth NULL
Definition: ftsmooth.c:416
#define WS_EX_DLGMODALFRAME
Definition: pedump.c:645
BOOL WINAPI GetClassInfoW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _Out_ LPWNDCLASSW)
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
LPCWSTR lpszClassName
Definition: winuser.h:3138
Definition: bufpool.h:45
const char * LPCSTR
Definition: xmlstorage.h:183
#define WS_EX_LEFT
Definition: winuser.h:391
#define WS_MAXIMIZEBOX
Definition: pedump.c:632
#define ok(value,...)
Definition: CComObject.cpp:34
void Test_ClassAtoms()
#define ERROR_INVALID_WINDOW_HANDLE
Definition: winerror.h:881
#define WS_OVERLAPPED
Definition: pedump.c:615
struct _TestData TestData
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
#define DLGWINDOWEXTRA
Definition: winuser.h:2519
#define DS_SETFONT
Definition: winuser.h:378
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
LPCSTR lpszClassName
Definition: winuser.h:3125
static TestData RealClassTestData[]
#define WS_EX_RIGHTSCROLLBAR
Definition: winuser.h:401
#define DS_3DLOOK
Definition: winuser.h:367
#define WS_MINIMIZEBOX
Definition: pedump.c:631
#define ARRAY_SIZE(a)
Definition: main.h:24
#define skip(...)
Definition: CString.cpp:57
LPCSTR ExpectedClassNameAfter
unsigned int UINT
Definition: ndis.h:50
void Test_RealGetWindowClass()
#define RealGetWindowClass
Definition: winuser.h:5701
WNDPROC lpfnWndProc
Definition: winuser.h:3117
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define WS_EX_APPWINDOW
Definition: winuser.h:383
static PWSTR ControlsList[]
#define IDCANCEL
Definition: winuser.h:825
#define UnregisterClass
Definition: winuser.h:5727
ATOM WINAPI RegisterClassA(_In_ CONST WNDCLASSA *)
#define printf
Definition: config.h:203