ReactOS  0.4.12-dev-918-g6c6e7b8
CreateDialog.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 CreateDialog
5  * PROGRAMMERS: Andreas Maier
6  */
7 
8 #include "precomp.h"
9 
10 #define TEST_MAX_MSG 50
11 
12 // cmpflag
13 #define MSGLST_CMP_WP 0x1
14 #define MSGLST_CMP_LP 0x2
15 #define MSGLST_CMP_RES 0x4
16 #define MSGLST_CMP_ALL (MSGLST_CMP_WP | MSGLST_CMP_LP | MSGLST_CMP_RES)
17 
18 typedef struct
19 {
20  BOOL DlgProc; // true = DlgProg, false WndProc
24  int result;
25  int cmpflag;
26 } tagMsgInfo;
27 
28 typedef struct
29 {
30  int msgCount;
32 } tagMsgList;
33 
35 
36 /* the expected message-list */
38 {
39  9,
40  {
41  // DlgProc, msg, wParam, lParam, result, cmpflag
45  { FALSE, WM_SIZE, 0, 0x145012c, 0, MSGLST_CMP_ALL }, // FIXME: size is 400x400 on Win7?
46  { FALSE, WM_MOVE, 0, 0x0160003, 0, MSGLST_CMP_ALL },
51  }
52 };
53 
54 void DumpMsgList(const char* lstName, const tagMsgList *ml)
55 {
56  const char *dlgProcName;
57  int i1;
58 
59  printf("%s\n", lstName);
60  for (i1 = 0; i1 < ml->msgCount; i1++)
61  {
62  dlgProcName = (ml->msgList[i1].DlgProc) ? "DlgProc" : "WndProc";
63  printf("#%.3d %s, msg 0x%x, wParam 0x%x, lParam 0x%Ix, result %d\n",
64  i1,
65  dlgProcName,
66  ml->msgList[i1].msg,
67  ml->msgList[i1].wParam,
68  ml->msgList[i1].lParam,
69  ml->msgList[i1].result);
70  }
71 }
72 
73 BOOL CmpMsgList(const tagMsgList *recvd,
74  const tagMsgList *expect)
75 {
76  int i1;
77  BOOL isOk;
78 
79  isOk = TRUE;
80  if (recvd->msgCount != expect->msgCount)
81  {
82  ok(FALSE, "%d messages expected, %d messages received!\n",
83  expect->msgCount, recvd->msgCount);
84  isOk = FALSE;
85  }
86  else
87  {
88  for (i1 = 0; i1 < recvd->msgCount; i1++)
89  {
90  if (expect->msgList[i1].DlgProc != recvd->msgList[i1].DlgProc)
91  isOk = FALSE;
92  if (expect->msgList[i1].msg != recvd->msgList[i1].msg)
93  isOk = FALSE;
94  if ((expect->msgList[i1].cmpflag & MSGLST_CMP_WP) &&
95  (expect->msgList[i1].wParam != recvd->msgList[i1].wParam))
96  isOk = FALSE;
97  if ((expect->msgList[i1].cmpflag & MSGLST_CMP_LP) &&
98  (expect->msgList[i1].lParam != recvd->msgList[i1].lParam))
99  isOk = FALSE;
100  if ((expect->msgList[i1].cmpflag & MSGLST_CMP_RES) &&
101  (expect->msgList[i1].result != recvd->msgList[i1].result))
102  isOk = FALSE;
103  if (!isOk)
104  {
105  ok(FALSE, "Message #%.3d not equal\n", i1);
106  break;
107  }
108  }
109  }
110 
111  if (!isOk)
112  {
113  DumpMsgList("RECEIVED", recvd);
114  DumpMsgList("EXPECTED", expect);
115  return FALSE;
116  }
117 
118  ok(TRUE, "\n");
119  return TRUE;
120 }
121 
123 {
125  {
131  msglist.msgCount++;
132  }
133  trace("DlgProc: msg 0x%x, wParam 0x%x, lParam 0x%Ix\n",
134  msg, wParam, lParam);
135  return FALSE;
136 }
137 
139 {
140  LRESULT res;
142 
144  {
150  msglist.msgCount++;
151  }
152  trace("WndProc: msg 0x%x, wParam 0x%x, lParam 0x%Ix, result %Id\n",
153  msg, wParam, lParam, res);
154  return res;
155 }
156 
158 {
159  HWND hWnd;
160  HMODULE hMod;
161  DWORD exstyle;
162  WNDCLASSW wc;
163 
164  hMod = GetModuleHandle(NULL);
165  ok(hMod != NULL, "\n");
166 
167  msglist.msgCount = 0;
168  wc.style = CS_HREDRAW | CS_VREDRAW;
170  wc.cbClsExtra = 0;
172  wc.hInstance = hMod;
175  wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
176  wc.lpszMenuName = NULL;
177  wc.lpszClassName = L"TestDialogClass";
178 
179  if (!RegisterClassW(&wc))
180  {
181  ok(FALSE, "Error registering Window-Class\n");
182  return;
183  }
184  hWnd = CreateDialogW(hMod, L"TESTDIALOG", 0, Test_CreateDialogW_DLGPROC);
185  ok(hWnd != NULL, "Error: %lu\n", GetLastError());
186  if (hWnd != NULL)
187  {
188  /* Check the exstyle */
189  exstyle = GetWindowLongW(hWnd, GWL_EXSTYLE);
190  ok(exstyle != 0x50010, "ExStyle wrong, got %#08lX, expected 0x50010.\n", exstyle);
191  /* Check the messages we received during creation */
193  }
194 }
195 
197 {
198  //Test_CreateDialogA();//TODO
200 }
const tagMsgList t1msgList
Definition: CreateDialog.c:37
#define trace(...)
Definition: kmt_test.h:217
#define TRUE
Definition: types.h:120
UINT style
Definition: winuser.h:3129
LPCWSTR lpszMenuName
Definition: winuser.h:3137
LRESULT CALLBACK Test_CreateDialogW_WNDPROC(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: CreateDialog.c:138
#define WM_NCCALCSIZE
Definition: winuser.h:1667
#define CALLBACK
Definition: compat.h:27
HWND hWnd
Definition: settings.c:17
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define CS_HREDRAW
Definition: winuser.h:648
#define WM_MOVE
Definition: winuser.h:1592
#define GWL_EXSTYLE
Definition: winuser.h:845
int cbClsExtra
Definition: winuser.h:3131
BOOL CmpMsgList(const tagMsgList *recvd, const tagMsgList *expect)
Definition: CreateDialog.c:73
#define IDI_APPLICATION
Definition: winuser.h:699
UINT_PTR WPARAM
Definition: windef.h:207
int32_t INT_PTR
Definition: typedefs.h:62
#define MSGLST_CMP_ALL
Definition: CreateDialog.c:16
#define WM_NCCREATE
Definition: winuser.h:1665
#define COLOR_WINDOW
Definition: winuser.h:908
tagMsgInfo msgList[TEST_MAX_MSG]
Definition: CreateDialog.c:31
WPARAM wParam
Definition: combotst.c:138
ATOM WINAPI RegisterClassW(_In_ CONST WNDCLASSW *)
void DumpMsgList(const char *lstName, const tagMsgList *ml)
Definition: CreateDialog.c:54
#define MSGLST_CMP_RES
Definition: CreateDialog.c:15
unsigned int BOOL
Definition: ntddk_ex.h:94
WNDPROC lpfnWndProc
Definition: winuser.h:3130
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
#define MSGLST_CMP_LP
Definition: CreateDialog.c:14
smooth NULL
Definition: ftsmooth.c:416
#define MSGLST_CMP_WP
Definition: CreateDialog.c:13
LPCWSTR lpszClassName
Definition: winuser.h:3138
LONG_PTR LPARAM
Definition: windef.h:208
#define ok(value,...)
Definition: CComObject.cpp:34
#define CS_VREDRAW
Definition: winuser.h:653
int cbWndExtra
Definition: winuser.h:3132
#define WM_SIZE
Definition: winuser.h:1593
unsigned long DWORD
Definition: ntddk_ex.h:95
HICON hIcon
Definition: winuser.h:3134
LRESULT WINAPI DefDlgProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static const WCHAR L[]
Definition: oid.c:1250
#define DLGWINDOWEXTRA
Definition: winuser.h:2519
#define CreateDialogW(h, n, w, f)
Definition: winuser.h:4150
#define LoadCursor
Definition: winuser.h:5678
#define TEST_MAX_MSG
Definition: CreateDialog.c:10
HCURSOR hCursor
Definition: winuser.h:3135
LPARAM lParam
Definition: CreateDialog.c:23
#define GetModuleHandle
Definition: winbase.h:3641
HBRUSH hbrBackground
Definition: winuser.h:3136
#define expect(expected, got)
Definition: combo.c:36
unsigned int UINT
Definition: ndis.h:50
void Test_CreateDialogW()
Definition: CreateDialog.c:157
#define WM_SETFONT
Definition: winuser.h:1632
HINSTANCE hInstance
Definition: winuser.h:3133
#define msg(x)
Definition: auth_time.c:54
#define IDC_ARROW
Definition: winuser.h:682
#define WM_CREATE
Definition: winuser.h:1590
GLuint res
Definition: glext.h:9613
START_TEST(CreateDialog)
Definition: CreateDialog.c:196
WPARAM wParam
Definition: CreateDialog.c:22
#define LoadIcon
Definition: winuser.h:5679
BOOL DlgProc
Definition: CreateDialog.c:20
tagMsgList msglist
Definition: CreateDialog.c:34
LONG_PTR LRESULT
Definition: windef.h:209
INT_PTR CALLBACK Test_CreateDialogW_DLGPROC(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: CreateDialog.c:122
#define WM_INITDIALOG
Definition: winuser.h:1715
LPARAM lParam
Definition: combotst.c:139
#define CreateDialog
Definition: winuser.h:5615
#define printf
Definition: config.h:203