ReactOS 0.4.15-dev-8145-ga541a46
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
18typedef struct
19{
20 BOOL DlgProc; // true = DlgProg, false WndProc
24 int result;
27
28typedef struct
29{
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
56void 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
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 {
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 {
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;
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}
#define MSGLST_CMP_RES
Definition: CreateDialog.c:15
LRESULT CALLBACK Test_CreateDialogW_WNDPROC(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: CreateDialog.c:140
const tagMsgList t1msgList
Definition: CreateDialog.c:37
void Test_CreateDialogW()
Definition: CreateDialog.c:159
#define MSGLST_CMP_WP
Definition: CreateDialog.c:13
void DumpMsgList(const char *lstName, const tagMsgList *ml)
Definition: CreateDialog.c:56
BOOL CmpMsgList(const tagMsgList *recvd, const tagMsgList *expect)
Definition: CreateDialog.c:75
INT_PTR CALLBACK Test_CreateDialogW_DLGPROC(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: CreateDialog.c:124
static tagMsgList msglist
Definition: CreateDialog.c:34
#define MSGLST_CMP_ALL
Definition: CreateDialog.c:16
#define MSGLST_CMP_LP
Definition: CreateDialog.c:14
#define TEST_MAX_MSG
Definition: CreateDialog.c:10
#define expect(EXPECTED, GOT)
Definition: SystemMenu.c:483
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
#define msg(x)
Definition: auth_time.c:54
HWND hWnd
Definition: settings.c:17
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define CALLBACK
Definition: compat.h:35
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
#define printf
Definition: freeldr.h:97
GLuint res
Definition: glext.h:9613
unsigned int UINT
Definition: ndis.h:50
#define L(x)
Definition: ntvdm.h:50
LPCWSTR lpszClassName
Definition: winuser.h:3185
LPCWSTR lpszMenuName
Definition: winuser.h:3184
HBRUSH hbrBackground
Definition: winuser.h:3183
HICON hIcon
Definition: winuser.h:3181
HINSTANCE hInstance
Definition: winuser.h:3180
int cbClsExtra
Definition: winuser.h:3178
UINT style
Definition: winuser.h:3176
WNDPROC lpfnWndProc
Definition: winuser.h:3177
int cbWndExtra
Definition: winuser.h:3179
HCURSOR hCursor
Definition: winuser.h:3182
LPARAM lParam
Definition: CreateDialog.c:23
WPARAM wParam
Definition: CreateDialog.c:22
BOOL DlgProc
Definition: CreateDialog.c:20
tagMsgInfo msgList[TEST_MAX_MSG]
Definition: CreateDialog.c:31
int32_t INT_PTR
Definition: typedefs.h:64
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define GetModuleHandle
Definition: winbase.h:3827
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
UINT_PTR WPARAM
Definition: windef.h:207
#define DLGWINDOWEXTRA
Definition: winuser.h:2565
#define CS_VREDRAW
Definition: winuser.h:658
#define COLOR_WINDOW
Definition: winuser.h:918
LRESULT WINAPI DefDlgProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_CREATE
Definition: winuser.h:1608
#define WM_SIZE
Definition: winuser.h:1611
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
#define CS_HREDRAW
Definition: winuser.h:653
ATOM WINAPI RegisterClassW(_In_ CONST WNDCLASSW *)
#define IDC_ARROW
Definition: winuser.h:687
#define CreateDialog
Definition: winuser.h:5749
#define WM_INITDIALOG
Definition: winuser.h:1739
#define WM_NCCREATE
Definition: winuser.h:1683
#define IDI_APPLICATION
Definition: winuser.h:704
#define WM_SETFONT
Definition: winuser.h:1650
#define LoadIcon
Definition: winuser.h:5813
#define LoadCursor
Definition: winuser.h:5812
#define CreateDialogW(h, n, w, f)
Definition: winuser.h:4281
#define WM_MOVE
Definition: winuser.h:1610
#define WM_NCCALCSIZE
Definition: winuser.h:1685
#define GWL_EXSTYLE
Definition: winuser.h:851