2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for SetWindowExtEx
5 * PROGRAMMERS: Timo Kreuzer
11 void Test_SetWindowExtEx()
15 SIZE WindowExt
, ViewportExt
;
16 //PGDI_TABLE_ENTRY pEntry;
19 hDC
= CreateCompatibleDC(0);
20 ok(hDC
!= NULL
, "CreateCompatibleDC failed. Skipping tests.\n");
21 if (hDC
== NULL
) return;
24 ret
= SetWindowExtEx(0, 0, 0, NULL
);
25 ok_err(ERROR_INVALID_HANDLE
);
29 ret
= SetWindowExtEx((HDC
)0x1234, 0, 0, NULL
);
30 ok_err(ERROR_INVALID_HANDLE
);
34 ret
= SetWindowExtEx((HDC
)0x10000, 0, 0, NULL
);
35 ok_err(ERROR_INVALID_PARAMETER
);
39 ret
= SetWindowExtEx((HDC
)0x210000, 0, 0, NULL
); // GDILoObjType_LO_ALTDC_TYPE
40 ok_err(ERROR_INVALID_HANDLE
);
44 ret
= SetWindowExtEx((HDC
)0x260000, 0, 0, NULL
); // GDILoObjType_LO_METAFILE16_TYPE
45 ok_err(ERROR_INVALID_HANDLE
);
49 ret
= SetWindowExtEx((HDC
)0x460000, 0, 0, NULL
); // GDILoObjType_LO_METAFILE_TYPE
50 ok_err(ERROR_INVALID_HANDLE
);
54 ret
= SetWindowExtEx((HDC
)0x660000, 0, 0, NULL
); // GDILoObjType_LO_METADC16_TYPE
55 ok_err(ERROR_INVALID_HANDLE
);
59 ret
= SetWindowExtEx(hDC
, 0, 0, NULL
);
63 /* Test 16 bit handle */
65 ret
= SetWindowExtEx((HDC
)((ULONG_PTR
)hDC
& 0xffff), 0, 0, NULL
);
66 ok_err(ERROR_INVALID_HANDLE
);
72 ret
= SetWindowExtEx(0, 0, 0, &WindowExt
);
73 ok_err(ERROR_INVALID_HANDLE
);
75 ok_long(WindowExt
.cx
, 1234);
76 ok_long(WindowExt
.cy
, 6789);
80 /* Test with a deleted DC */
82 ret
= SetWindowExtEx(hDC
, 0, 0, NULL
);
83 ok_err(ERROR_INVALID_PARAMETER
);
86 hDC
= CreateCompatibleDC(0);
87 ok(hDC
!= NULL
, "CreateCompatibleDC failed. Skipping tests.\n");
88 if (hDC
== NULL
) return;
90 //pEntry = GdiHandleTable + GDI_HANDLE_GET_INDEX(hDC);
91 //pDC_Attr = pEntry->UserData;
94 /* Test setting 0 extents without changing the map mode (MM_TEXT) */
95 ret
= SetWindowExtEx(hDC
, 0, 0, &WindowExt
);
97 ok_long(WindowExt
.cx
, 1);
98 ok_long(WindowExt
.cy
, 1);
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
);
104 ok_long(WindowExt
.cx
, 1);
105 ok_long(WindowExt
.cy
, 1);
107 /* Values should not be changed */
108 WindowExt
.cx
= WindowExt
.cy
= 0;
109 ret
= SetWindowExtEx(hDC
, 40, 30, &WindowExt
);
111 ok_long(WindowExt
.cx
, 1);
112 ok_long(WindowExt
.cy
, 1);
114 /* Check the viewport */
115 GetViewportExtEx(hDC
, &ViewportExt
);
116 ok_long(ViewportExt
.cx
, 1);
117 ok_long(ViewportExt
.cy
, 1);
119 /* Test setting in isotropic mode with 0 extents */
120 SetMapMode(hDC
, MM_ISOTROPIC
);
121 WindowExt
.cx
= WindowExt
.cy
= 0;
122 ret
= SetWindowExtEx(hDC
, 0, 0, &WindowExt
);
124 //ok_long(WindowExt.cx, 3600);
125 //ok_long(WindowExt.cy, 2700);
126 ret
= SetWindowExtEx(hDC
, 100, 0, &WindowExt
);
128 ret
= SetWindowExtEx(hDC
, 0, 100, &WindowExt
);
131 /* Test setting in isotropic mode */
132 ret
= SetWindowExtEx(hDC
, 21224, 35114, &WindowExt
);
134 //ok_long(WindowExt.cx, 3600);
135 //ok_long(WindowExt.cy, 2700);
137 /* Values should be changed */
138 ret
= SetWindowExtEx(hDC
,
139 4 * GetDeviceCaps(GetDC(0), HORZRES
),
140 -4 * GetDeviceCaps(GetDC(0), VERTRES
),
143 ok_long(WindowExt
.cx
, 21224);
144 ok_long(WindowExt
.cy
, 35114);
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
));
151 /* again isotropic mode with 1:1 res */
152 ret
= SetWindowExtEx(hDC
, 123, 123, &WindowExt
);
154 ok_long(WindowExt
.cx
, 4 * GetDeviceCaps(GetDC(0), HORZRES
));
155 ok_long(WindowExt
.cy
, -4 * GetDeviceCaps(GetDC(0), VERTRES
));
158 //TEST(pDC_Attr->flXform & PAGE_EXTENTS_CHANGED);
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));
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
));
170 //TEST(pDC_Attr->flXform & PAGE_EXTENTS_CHANGED);
172 /* again isotropic mode with 3:1 res */
173 ret
= SetWindowExtEx(hDC
, 300, 100, &WindowExt
);
175 ok_long(WindowExt
.cx
, 123);
176 ok_long(WindowExt
.cy
, 123);
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);
183 /* again isotropic mode with 1:3 res */
184 SetViewportExtEx(hDC
, 6000, 3000, 0);
185 ret
= SetWindowExtEx(hDC
, 200, 600, &WindowExt
);
187 ok_long(WindowExt
.cx
, 300);
188 ok_long(WindowExt
.cy
, 100);
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);
195 /* Test setting in anisotropic mode */
196 SetMapMode(hDC
, MM_ANISOTROPIC
);
197 ret
= SetWindowExtEx(hDC
, 80, 60, &WindowExt
);
199 ok_long(WindowExt
.cx
, 200);
200 ok_long(WindowExt
.cy
, 600);
202 /* Values should be changed */
203 ret
= SetWindowExtEx(hDC
, 500, 500, &WindowExt
);
205 ok_long(WindowExt
.cx
, 80);
206 ok_long(WindowExt
.cy
, 60);
208 /* Check the viewport */
209 GetViewportExtEx(hDC
, &ViewportExt
);
210 ok_long(ViewportExt
.cx
, 1000);
211 ok_long(ViewportExt
.cy
, 3000);
213 /* Test setting in low metric mode */
214 SetMapMode(hDC
, MM_LOMETRIC
);
215 ret
= SetWindowExtEx(hDC
, 120, 90, &WindowExt
);
217 //ok_long(WindowExt.cx, 3600);
218 //ok_long(WindowExt.cy, 2700);
220 /* Values should not be changed */
221 WindowExt
.cx
= WindowExt
.cy
= 0;
222 ret
= SetWindowExtEx(hDC
, 900, 700, &WindowExt
);
224 //ok_long(WindowExt.cx, 3600);
225 //ok_long(WindowExt.cy, 2700);
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
));
232 /* Test setting in high metric mode */
233 SetMapMode(hDC
, MM_HIMETRIC
);
234 ret
= SetWindowExtEx(hDC
, 120, 90, &WindowExt
);
236 //ok_long(WindowExt.cx, 36000);
237 //ok_long(WindowExt.cy, 27000);
239 /* Values should not be changed */
240 WindowExt
.cx
= WindowExt
.cy
= 0;
241 ret
= SetWindowExtEx(hDC
, 500, 300, &WindowExt
);
243 //ok_long(WindowExt.cx, 36000);
244 //ok_long(WindowExt.cy, 27000);
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
));
251 /* Test setting in low english mode */
252 SetMapMode(hDC
, MM_LOENGLISH
);
253 ret
= SetWindowExtEx(hDC
, 320, 290, &WindowExt
);
255 //ok_long(WindowExt.cx, 1417);
256 //ok_long(WindowExt.cy, 1063);
258 /* Values should not be changed */
259 WindowExt
.cx
= WindowExt
.cy
= 0;
260 ret
= SetWindowExtEx(hDC
, 560, 140, &WindowExt
);
262 //ok_long(WindowExt.cx, 1417);
263 //ok_long(WindowExt.cy, 1063);
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
));
270 /* Test setting in high english mode */
271 SetMapMode(hDC
, MM_HIENGLISH
);
272 ret
= SetWindowExtEx(hDC
, 320, 290, &WindowExt
);
274 //ok_long(WindowExt.cx, 14173);
275 //ok_long(WindowExt.cy, 10630);
277 /* Values should not be changed */
278 WindowExt
.cx
= WindowExt
.cy
= 0;
279 ret
= SetWindowExtEx(hDC
, 1560, 1140, &WindowExt
);
281 //ok_long(WindowExt.cx, 14173);
282 //ok_long(WindowExt.cy, 10630);
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
));
289 /* Test setting in twips mode */
290 SetMapMode(hDC
, MM_TWIPS
);
291 ret
= SetWindowExtEx(hDC
, 3320, 3290, &WindowExt
);
293 //ok_long(WindowExt.cx, 20409);
294 //ok_long(WindowExt.cy, 15307);
296 /* Values should not be changed */
297 WindowExt
.cx
= WindowExt
.cy
= 0;
298 ret
= SetWindowExtEx(hDC
, 4560, 4140, &WindowExt
);
300 //ok_long(WindowExt.cx, 20409);
301 //ok_long(WindowExt.cy, 15307);
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
));
308 /* test manually modifying the dcattr, should go to tests for GetViewportExtEx */
309 SetMapMode(hDC
, MM_ISOTROPIC
);
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);
319 START_TEST(SetWindowExtEx
)
321 Test_SetWindowExtEx();