ReactOS  0.4.15-dev-2528-g5506091
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  11,
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_WP | MSGLST_CMP_RES }, // FIXME: LPARAM doesn't match on win 10
51  { TRUE, WM_CHANGEUISTATE, 3, 0, 0, MSGLST_CMP_LP | MSGLST_CMP_RES },
52  { FALSE, WM_CHANGEUISTATE, 3, 0, 0, MSGLST_CMP_LP | MSGLST_CMP_RES },
53  }
54 };
55 
56 void DumpMsgList(const char* lstName, const tagMsgList *ml)
57 {
58  const char *dlgProcName;
59  int i1;
60 
61  printf("%s\n", lstName);
62  for (i1 = 0; i1 < ml->msgCount; i1++)
63  {
64  dlgProcName = (ml->msgList[i1].DlgProc) ? "DlgProc" : "WndProc";
65  printf("#%.3d %s, msg 0x%x, wParam 0x%Ix, lParam 0x%Ix, result %d\n",
66  i1,
67  dlgProcName,
68  ml->msgList[i1].msg,
69  ml->msgList[i1].wParam,
70  ml->msgList[i1].lParam,
71  ml->msgList[i1].result);
72  }
73 }
74 
75 BOOL CmpMsgList(const tagMsgList *recvd,
76  const tagMsgList *expect)
77 {
78  int i1;
79  BOOL isOk;
80 
81  isOk = TRUE;
82  if (recvd->msgCount != expect->msgCount)
83  {
84  ok(FALSE, "%d messages expected, %d messages received!\n",
85  expect->msgCount, recvd->msgCount);
86  isOk = FALSE;
87  }
88  else
89  {
90  for (i1 = 0; i1 < recvd->msgCount; i1++)
91  {
92  if (expect->msgList[i1].DlgProc != recvd->msgList[i1].DlgProc)
93  isOk = FALSE;
94  if (expect->msgList[i1].msg != recvd->msgList[i1].msg)
95  isOk = FALSE;
96  if ((expect->msgList[i1].cmpflag & MSGLST_CMP_WP) &&
97  (expect->msgList[i1].wParam != recvd->msgList[i1].wParam))
98  isOk = FALSE;
99  if ((expect->msgList[i1].cmpflag & MSGLST_CMP_LP) &&
100  (expect->msgList[i1].lParam != recvd->msgList[i1].lParam))
101  isOk = FALSE;
102  if ((expect->msgList[i1].cmpflag & MSGLST_CMP_RES) &&
103  (expect->msgList[i1].result != recvd->msgList[i1].result))
104  isOk = FALSE;
105  if (!isOk)
106  {
107  ok(FALSE, "Message #%.3d not equal\n", i1);
108  break;
109  }
110  }
111  }
112 
113  if (!isOk)
114  {
115  DumpMsgList("RECEIVED", recvd);
116  DumpMsgList("EXPECTED", expect);
117  return FALSE;
118  }
119 
120  ok(TRUE, "\n");
121  return TRUE;
122 }
123 
125 {
127  {
133  msglist.msgCount++;
134  }
135  trace("DlgProc: msg 0x%x, wParam 0x%x, lParam 0x%Ix\n",
136  msg, wParam, lParam);
137  return FALSE;
138 }
139 
141 {
142  LRESULT res;
144 
146  {
152  msglist.msgCount++;
153  }
154  trace("WndProc: msg 0x%x, wParam 0x%x, lParam 0x%Ix, result %Id\n",
155  msg, wParam, lParam, res);
156  return res;
157 }
158 
160 {
161  HWND hWnd;
162  HMODULE hMod;
163  DWORD exstyle;
164  WNDCLASSW wc;
165 
166  hMod = GetModuleHandle(NULL);
167  ok(hMod != NULL, "\n");
168 
169  msglist.msgCount = 0;
170  wc.style = CS_HREDRAW | CS_VREDRAW;
172  wc.cbClsExtra = 0;
174  wc.hInstance = hMod;
177  wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
178  wc.lpszMenuName = NULL;
179  wc.lpszClassName = L"TestDialogClass";
180 
181  if (!RegisterClassW(&wc))
182  {
183  ok(FALSE, "Error registering Window-Class\n");
184  return;
185  }
186  hWnd = CreateDialogW(hMod, L"TESTDIALOG", 0, Test_CreateDialogW_DLGPROC);
187  ok(hWnd != NULL, "Error: %lu\n", GetLastError());
188  if (hWnd != NULL)
189  {
190  /* Check the exstyle */
191  exstyle = GetWindowLongW(hWnd, GWL_EXSTYLE);
192  ok(exstyle != 0x50010, "ExStyle wrong, got %#08lX, expected 0x50010.\n", exstyle);
193  /* Check the messages we received during creation */
195  }
196 }
197 
199 {
200  //Test_CreateDialogA();//TODO
202 }
const tagMsgList t1msgList
Definition: CreateDialog.c:37
UINT style
Definition: winuser.h:3151
LPCWSTR lpszMenuName
Definition: winuser.h:3159
LRESULT CALLBACK Test_CreateDialogW_WNDPROC(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: CreateDialog.c:140
#define TRUE
Definition: types.h:120
#define WM_NCCALCSIZE
Definition: winuser.h:1667
#define CALLBACK
Definition: compat.h:35
HWND hWnd
Definition: settings.c:17
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#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:3153
BOOL CmpMsgList(const tagMsgList *recvd, const tagMsgList *expect)
Definition: CreateDialog.c:75
#define IDI_APPLICATION
Definition: winuser.h:699
UINT_PTR WPARAM
Definition: windef.h:207
int32_t INT_PTR
Definition: typedefs.h:64
#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:56
#define MSGLST_CMP_RES
Definition: CreateDialog.c:15
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
WNDPROC lpfnWndProc
Definition: winuser.h:3152
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
#define MSGLST_CMP_LP
Definition: CreateDialog.c:14
#define MSGLST_CMP_WP
Definition: CreateDialog.c:13
LPCWSTR lpszClassName
Definition: winuser.h:3160
LONG_PTR LPARAM
Definition: windef.h:208
#define CS_VREDRAW
Definition: winuser.h:653
#define trace
Definition: atltest.h:70
int cbWndExtra
Definition: winuser.h:3154
#define WM_SIZE
Definition: winuser.h:1593
unsigned long DWORD
Definition: ntddk_ex.h:95
HICON hIcon
Definition: winuser.h:3156
LRESULT WINAPI DefDlgProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static const WCHAR L[]
Definition: oid.c:1250
#define DLGWINDOWEXTRA
Definition: winuser.h:2540
#define CreateDialogW(h, n, w, f)
Definition: winuser.h:4256
#define LoadCursor
Definition: winuser.h:5787
#define TEST_MAX_MSG
Definition: CreateDialog.c:10
HCURSOR hCursor
Definition: winuser.h:3157
LPARAM lParam
Definition: CreateDialog.c:23
#define GetModuleHandle
Definition: winbase.h:3683
HBRUSH hbrBackground
Definition: winuser.h:3158
#define ok(value,...)
Definition: atltest.h:57
#define expect(expected, got)
Definition: combo.c:36
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
void Test_CreateDialogW()
Definition: CreateDialog.c:159
#define WM_SETFONT
Definition: winuser.h:1632
HINSTANCE hInstance
Definition: winuser.h:3155
#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:198
WPARAM wParam
Definition: CreateDialog.c:22
#define LoadIcon
Definition: winuser.h:5788
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:124
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
#define CreateDialog
Definition: winuser.h:5724
#define printf
Definition: config.h:203