ReactOS 0.4.16-dev-258-g81860b4
SetWindowExtEx.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 SetWindowExtEx
5 * PROGRAMMERS: Timo Kreuzer
6 * Katayama Hirofumi MZ
7 */
8
9#include "precomp.h"
10
12{
13 HDC hDC;
14 BOOL ret;
15 SIZE WindowExt, ViewportExt;
16 //PGDI_TABLE_ENTRY pEntry;
17 //DC_ATTR* pDC_Attr;
18
20 ok(hDC != NULL, "CreateCompatibleDC failed. Skipping tests.\n");
21 if (hDC == NULL) return;
22
23 SetLastError(0);
24 ret = SetWindowExtEx(0, 0, 0, NULL);
26 ok_int(ret, 0);
27
28 SetLastError(0);
29 ret = SetWindowExtEx((HDC)0x1234, 0, 0, NULL);
31 ok_int(ret, 0);
32
33 SetLastError(0);
34 ret = SetWindowExtEx((HDC)0x10000, 0, 0, NULL);
36 ok_int(ret, 0);
37
38 SetLastError(0);
39 ret = SetWindowExtEx((HDC)0x210000, 0, 0, NULL); // GDILoObjType_LO_ALTDC_TYPE
41 ok_int(ret, 0);
42
43 SetLastError(0);
44 ret = SetWindowExtEx((HDC)0x260000, 0, 0, NULL); // GDILoObjType_LO_METAFILE16_TYPE
46 ok_int(ret, 0);
47
48 SetLastError(0);
49 ret = SetWindowExtEx((HDC)0x460000, 0, 0, NULL); // GDILoObjType_LO_METAFILE_TYPE
51 ok_int(ret, 0);
52
53 SetLastError(0);
54 ret = SetWindowExtEx((HDC)0x660000, 0, 0, NULL); // GDILoObjType_LO_METADC16_TYPE
56 ok_int(ret, 0);
57
58 SetLastError(0);
59 ret = SetWindowExtEx(hDC, 0, 0, NULL);
60 ok_err(0);
61 ok_int(ret, 1);
62
63 /* Test 16 bit handle */
64 SetLastError(0);
65 ret = SetWindowExtEx((HDC)((ULONG_PTR)hDC & 0xffff), 0, 0, NULL);
67 ok_int(ret, 0);
68
69 WindowExt.cx = 1234;
70 WindowExt.cy = 6789;
71 SetLastError(0);
72 ret = SetWindowExtEx(0, 0, 0, &WindowExt);
74 ok_int(ret, 0);
75 ok_long(WindowExt.cx, 1234);
76 ok_long(WindowExt.cy, 6789);
77
79
80 /* Test with a deleted DC */
81 SetLastError(0);
82 ret = SetWindowExtEx(hDC, 0, 0, NULL);
84 ok_int(ret, 0);
85
87 ok(hDC != NULL, "CreateCompatibleDC failed. Skipping tests.\n");
88 if (hDC == NULL) return;
89
90 //pEntry = GdiHandleTable + GDI_HANDLE_GET_INDEX(hDC);
91 //pDC_Attr = pEntry->UserData;
92 //ASSERT(pDC_Attr);
93
94 /* Test setting 0 extents without changing the map mode (MM_TEXT) */
95 ret = SetWindowExtEx(hDC, 0, 0, &WindowExt);
96 ok_int(ret, 1);
97 ok_long(WindowExt.cx, 1);
98 ok_long(WindowExt.cy, 1);
99
100 /* Test setting proper extents without changing the map mode (MM_TEXT) */
101 WindowExt.cx = WindowExt.cy = 0;
102 ret = SetWindowExtEx(hDC, 10, 20, &WindowExt);
103 ok_int(ret, 1);
104 ok_long(WindowExt.cx, 1);
105 ok_long(WindowExt.cy, 1);
106
107 /* Values should not be changed */
108 WindowExt.cx = WindowExt.cy = 0;
109 ret = SetWindowExtEx(hDC, 40, 30, &WindowExt);
110 ok_int(ret, 1);
111 ok_long(WindowExt.cx, 1);
112 ok_long(WindowExt.cy, 1);
113
114 /* Check the viewport */
115 GetViewportExtEx(hDC, &ViewportExt);
116 ok_long(ViewportExt.cx, 1);
117 ok_long(ViewportExt.cy, 1);
118
119 /* Test setting in isotropic mode with 0 extents */
121 WindowExt.cx = WindowExt.cy = 0;
122 ret = SetWindowExtEx(hDC, 0, 0, &WindowExt);
123 ok_int(ret, 0);
124 //ok_long(WindowExt.cx, 3600);
125 //ok_long(WindowExt.cy, 2700);
126 ret = SetWindowExtEx(hDC, 100, 0, &WindowExt);
127 ok_int(ret, 0);
128 ret = SetWindowExtEx(hDC, 0, 100, &WindowExt);
129 ok_int(ret, 0);
130
131 /* Test setting in isotropic mode */
132 ret = SetWindowExtEx(hDC, 21224, 35114, &WindowExt);
133 ok_int(ret, 1);
134 //ok_long(WindowExt.cx, 3600);
135 //ok_long(WindowExt.cy, 2700);
136
137 /* Values should be changed */
139 4 * GetDeviceCaps(GetDC(0), HORZRES),
140 -4 * GetDeviceCaps(GetDC(0), VERTRES),
141 &WindowExt);
142 ok_int(ret, 1);
143 ok_long(WindowExt.cx, 21224);
144 ok_long(WindowExt.cy, 35114);
145
146 /* Check the viewport, should be the same */
147 GetViewportExtEx(hDC, &ViewportExt);
148 ok_long(ViewportExt.cx, GetDeviceCaps(GetDC(0), HORZRES));
149 ok_long(ViewportExt.cy, -GetDeviceCaps(GetDC(0), VERTRES));
150
151 /* again isotropic mode with 1:1 res */
152 ret = SetWindowExtEx(hDC, 123, 123, &WindowExt);
153 ok_int(ret, 1);
154 ok_long(WindowExt.cx, 4 * GetDeviceCaps(GetDC(0), HORZRES));
155 ok_long(WindowExt.cy, -4 * GetDeviceCaps(GetDC(0), VERTRES));
156
157 /* Test flXform */
158 //TEST(pDC_Attr->flXform & PAGE_EXTENTS_CHANGED);
159
160 /* Check the viewport from the dcattr, without going through gdi */
161 //ok_long(pDC_Attr->szlViewportExt.cx, GetDeviceCaps(GetDC(0), HORZRES));
162 //ok_long(pDC_Attr->szlViewportExt.cy, -GetDeviceCaps(GetDC(0), VERTRES));
163
164 /* Check the viewport with gdi, should not be the same */
165 GetViewportExtEx(hDC, &ViewportExt);
166 ok_long(ViewportExt.cx, GetDeviceCaps(GetDC(0), VERTRES));
167 ok_long(ViewportExt.cy, -GetDeviceCaps(GetDC(0), VERTRES));
168
169 /* Test flXform */
170 //TEST(pDC_Attr->flXform & PAGE_EXTENTS_CHANGED);
171
172 /* again isotropic mode with 3:1 res */
173 ret = SetWindowExtEx(hDC, 300, 100, &WindowExt);
174 ok_int(ret, 1);
175 ok_long(WindowExt.cx, 123);
176 ok_long(WindowExt.cy, 123);
177
178 /* Check the viewport now, should not be the same */
179 GetViewportExtEx(hDC, &ViewportExt);
180 ok_long(ViewportExt.cx, GetDeviceCaps(GetDC(0), VERTRES));
181 ok_long(ViewportExt.cy, -GetDeviceCaps(GetDC(0), VERTRES) / 3);
182
183 /* again isotropic mode with 1:3 res */
184 SetViewportExtEx(hDC, 6000, 3000, 0);
185 ret = SetWindowExtEx(hDC, 200, 600, &WindowExt);
186 ok_int(ret, 1);
187 ok_long(WindowExt.cx, 300);
188 ok_long(WindowExt.cy, 100);
189
190 /* Check the viewport now, should not be the same */
191 GetViewportExtEx(hDC, &ViewportExt);
192 ok_long(ViewportExt.cx, 1000);
193 ok_long(ViewportExt.cy, 3000);
194
195 /* Test setting in anisotropic mode */
197 ret = SetWindowExtEx(hDC, 80, 60, &WindowExt);
198 ok_int(ret, 1);
199 ok_long(WindowExt.cx, 200);
200 ok_long(WindowExt.cy, 600);
201
202 /* Values should be changed */
203 ret = SetWindowExtEx(hDC, 500, 500, &WindowExt);
204 ok_int(ret, 1);
205 ok_long(WindowExt.cx, 80);
206 ok_long(WindowExt.cy, 60);
207
208 /* Check the viewport */
209 GetViewportExtEx(hDC, &ViewportExt);
210 ok_long(ViewportExt.cx, 1000);
211 ok_long(ViewportExt.cy, 3000);
212
213 /* Test setting in low metric mode */
215 ret = SetWindowExtEx(hDC, 120, 90, &WindowExt);
216 ok_int(ret, 1);
217 //ok_long(WindowExt.cx, 3600);
218 //ok_long(WindowExt.cy, 2700);
219
220 /* Values should not be changed */
221 WindowExt.cx = WindowExt.cy = 0;
222 ret = SetWindowExtEx(hDC, 900, 700, &WindowExt);
223 ok_int(ret, 1);
224 //ok_long(WindowExt.cx, 3600);
225 //ok_long(WindowExt.cy, 2700);
226
227 /* Check the viewport */
228 GetViewportExtEx(hDC, &ViewportExt);
229 ok_long(ViewportExt.cx, GetDeviceCaps(GetDC(0), HORZRES));
230 ok_long(ViewportExt.cy, -GetDeviceCaps(GetDC(0), VERTRES));
231
232 /* Test setting in high metric mode */
234 ret = SetWindowExtEx(hDC, 120, 90, &WindowExt);
235 ok_int(ret, 1);
236 //ok_long(WindowExt.cx, 36000);
237 //ok_long(WindowExt.cy, 27000);
238
239 /* Values should not be changed */
240 WindowExt.cx = WindowExt.cy = 0;
241 ret = SetWindowExtEx(hDC, 500, 300, &WindowExt);
242 ok_int(ret, 1);
243 //ok_long(WindowExt.cx, 36000);
244 //ok_long(WindowExt.cy, 27000);
245
246 /* Check the viewport */
247 GetViewportExtEx(hDC, &ViewportExt);
248 ok_long(ViewportExt.cx, GetDeviceCaps(GetDC(0), HORZRES));
249 ok_long(ViewportExt.cy, -GetDeviceCaps(GetDC(0), VERTRES));
250
251 /* Test setting in low english mode */
253 ret = SetWindowExtEx(hDC, 320, 290, &WindowExt);
254 ok_int(ret, 1);
255 //ok_long(WindowExt.cx, 1417);
256 //ok_long(WindowExt.cy, 1063);
257
258 /* Values should not be changed */
259 WindowExt.cx = WindowExt.cy = 0;
260 ret = SetWindowExtEx(hDC, 560, 140, &WindowExt);
261 ok_int(ret, 1);
262 //ok_long(WindowExt.cx, 1417);
263 //ok_long(WindowExt.cy, 1063);
264
265 /* Check the viewport */
266 GetViewportExtEx(hDC, &ViewportExt);
267 ok_long(ViewportExt.cx, GetDeviceCaps(GetDC(0), HORZRES));
268 ok_long(ViewportExt.cy, -GetDeviceCaps(GetDC(0), VERTRES));
269
270 /* Test setting in high english mode */
272 ret = SetWindowExtEx(hDC, 320, 290, &WindowExt);
273 ok_int(ret, 1);
274 //ok_long(WindowExt.cx, 14173);
275 //ok_long(WindowExt.cy, 10630);
276
277 /* Values should not be changed */
278 WindowExt.cx = WindowExt.cy = 0;
279 ret = SetWindowExtEx(hDC, 1560, 1140, &WindowExt);
280 ok_int(ret, 1);
281 //ok_long(WindowExt.cx, 14173);
282 //ok_long(WindowExt.cy, 10630);
283
284 /* Check the viewport */
285 GetViewportExtEx(hDC, &ViewportExt);
286 ok_long(ViewportExt.cx, GetDeviceCaps(GetDC(0), HORZRES));
287 ok_long(ViewportExt.cy, -GetDeviceCaps(GetDC(0), VERTRES));
288
289 /* Test setting in twips mode */
291 ret = SetWindowExtEx(hDC, 3320, 3290, &WindowExt);
292 ok_int(ret, 1);
293 //ok_long(WindowExt.cx, 20409);
294 //ok_long(WindowExt.cy, 15307);
295
296 /* Values should not be changed */
297 WindowExt.cx = WindowExt.cy = 0;
298 ret = SetWindowExtEx(hDC, 4560, 4140, &WindowExt);
299 ok_int(ret, 1);
300 //ok_long(WindowExt.cx, 20409);
301 //ok_long(WindowExt.cy, 15307);
302
303 /* Check the viewport */
304 GetViewportExtEx(hDC, &ViewportExt);
305 ok_long(ViewportExt.cx, GetDeviceCaps(GetDC(0), HORZRES));
306 ok_long(ViewportExt.cy, -GetDeviceCaps(GetDC(0), VERTRES));
307
308 /* test manually modifying the dcattr, should go to tests for GetViewportExtEx */
310 ret = SetWindowExtEx(hDC, 420, 4140, &WindowExt);
311 //pDC_Attr->szlWindowExt.cx = 0;
312 GetViewportExtEx(hDC, &ViewportExt);
313 //ok_long(pDC_Attr->szlWindowExt.cx, 0);
314 //ok_long(ViewportExt.cx, 0);
315
316 DeleteDC(hDC);
317}
318
320{
322}
323
static HDC hDC
Definition: 3dtext.c:33
void Test_SetWindowExtEx()
#define ok_long(expression, result)
Definition: atltest.h:133
#define ok(value,...)
Definition: atltest.h:57
#define ok_err(error)
Definition: atltest.h:124
#define START_TEST(x)
Definition: atltest.h:75
#define ok_int(expression, result)
Definition: atltest.h:134
#define NULL
Definition: types.h:112
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
unsigned int BOOL
Definition: ntddk_ex.h:94
static HDC
Definition: imagelist.c:88
LONG cx
Definition: kdterminal.h:27
LONG cy
Definition: kdterminal.h:28
uint32_t ULONG_PTR
Definition: typedefs.h:65
int ret
int WINAPI SetMapMode(_In_ HDC, _In_ int)
#define HORZRES
Definition: wingdi.h:716
#define MM_HIENGLISH
Definition: wingdi.h:868
#define MM_LOENGLISH
Definition: wingdi.h:871
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
#define MM_HIMETRIC
Definition: wingdi.h:869
BOOL WINAPI SetViewportExtEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPSIZE)
Definition: coord.c:465
#define MM_ANISOTROPIC
Definition: wingdi.h:867
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
BOOL WINAPI SetWindowExtEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPSIZE)
#define VERTRES
Definition: wingdi.h:717
#define MM_TWIPS
Definition: wingdi.h:874
#define MM_LOMETRIC
Definition: wingdi.h:872
#define MM_ISOTROPIC
Definition: wingdi.h:870
BOOL WINAPI DeleteDC(_In_ HDC)
BOOL WINAPI GetViewportExtEx(_In_ HDC, _Out_ LPSIZE)
Definition: coord.c:351
HDC WINAPI GetDC(_In_opt_ HWND)