2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for SetWindowExtEx
5 * PROGRAMMERS: Timo Kreuzer
10 void Test_SetWindowExtEx()
14 SIZE WindowExt
, ViewportExt
;
15 //PGDI_TABLE_ENTRY pEntry;
18 hDC
= CreateCompatibleDC(0);
19 ok(hDC
!= NULL
, "CreateCompatibleDC failed. Skipping tests.\n");
20 if (hDC
== NULL
) return;
23 ret
= SetWindowExtEx(0, 0, 0, NULL
);
24 ok_err(ERROR_INVALID_HANDLE
);
28 ret
= SetWindowExtEx((HDC
)0x1234, 0, 0, NULL
);
29 ok_err(ERROR_INVALID_HANDLE
);
33 ret
= SetWindowExtEx((HDC
)0x10000, 0, 0, NULL
);
34 ok_err(ERROR_INVALID_PARAMETER
);
38 ret
= SetWindowExtEx((HDC
)0x210000, 0, 0, NULL
); // GDILoObjType_LO_ALTDC_TYPE
39 ok_err(ERROR_INVALID_HANDLE
);
43 ret
= SetWindowExtEx((HDC
)0x260000, 0, 0, NULL
); // GDILoObjType_LO_METAFILE16_TYPE
44 ok_err(ERROR_INVALID_HANDLE
);
48 ret
= SetWindowExtEx((HDC
)0x460000, 0, 0, NULL
); // GDILoObjType_LO_METAFILE_TYPE
49 ok_err(ERROR_INVALID_HANDLE
);
53 ret
= SetWindowExtEx((HDC
)0x660000, 0, 0, NULL
); // GDILoObjType_LO_METADC16_TYPE
54 ok_err(ERROR_INVALID_HANDLE
);
58 ret
= SetWindowExtEx(hDC
, 0, 0, NULL
);
62 /* Test 16 bit handle */
64 ret
= SetWindowExtEx((HDC
)((ULONG_PTR
)hDC
& 0xffff), 0, 0, NULL
);
65 ok_err(ERROR_INVALID_HANDLE
);
71 ret
= SetWindowExtEx(0, 0, 0, &WindowExt
);
72 ok_err(ERROR_INVALID_HANDLE
);
74 TEST(WindowExt
.cx
== 1234);
75 TEST(WindowExt
.cy
== 6789);
79 /* Test with a deleted DC */
81 ret
= SetWindowExtEx(hDC
, 0, 0, NULL
);
82 ok_err(ERROR_INVALID_PARAMETER
);
85 hDC
= CreateCompatibleDC(0);
86 ok(hDC
!= NULL
, "CreateCompatibleDC failed. Skipping tests.\n");
87 if (hDC
== NULL
) return;
89 //pEntry = GdiHandleTable + GDI_HANDLE_GET_INDEX(hDC);
90 //pDC_Attr = pEntry->UserData;
93 /* Test setting 0 extents without changing the map mode (MM_TEXT) */
94 ret
= SetWindowExtEx(hDC
, 0, 0, &WindowExt
);
96 TEST(WindowExt
.cx
== 1);
97 TEST(WindowExt
.cy
== 1);
99 /* Test setting proper extents without changing the map mode (MM_TEXT) */
100 WindowExt
.cx
= WindowExt
.cy
= 0;
101 ret
= SetWindowExtEx(hDC
, 10, 20, &WindowExt
);
103 TEST(WindowExt
.cx
== 1);
104 TEST(WindowExt
.cy
== 1);
106 /* Values should not be changed */
107 WindowExt
.cx
= WindowExt
.cy
= 0;
108 ret
= SetWindowExtEx(hDC
, 40, 30, &WindowExt
);
110 TEST(WindowExt
.cx
== 1);
111 TEST(WindowExt
.cy
== 1);
113 /* Check the viewport */
114 GetViewportExtEx(hDC
, &ViewportExt
);
115 TEST(ViewportExt
.cx
== 1);
116 TEST(ViewportExt
.cy
== 1);
118 /* Test setting in isotropic mode with 0 extents */
119 SetMapMode(hDC
, MM_ISOTROPIC
);
120 WindowExt
.cx
= WindowExt
.cy
= 0;
121 ret
= SetWindowExtEx(hDC
, 0, 0, &WindowExt
);
123 //TEST(WindowExt.cx == 3600);
124 //TEST(WindowExt.cy == 2700);
125 ret
= SetWindowExtEx(hDC
, 100, 0, &WindowExt
);
127 ret
= SetWindowExtEx(hDC
, 0, 100, &WindowExt
);
130 /* Test setting in isotropic mode */
131 ret
= SetWindowExtEx(hDC
, 21224, 35114, &WindowExt
);
133 //TEST(WindowExt.cx == 3600);
134 //TEST(WindowExt.cy == 2700);
136 /* Values should be changed */
137 ret
= SetWindowExtEx(hDC
,
138 4 * GetDeviceCaps(GetDC(0), HORZRES
),
139 -4 * GetDeviceCaps(GetDC(0), VERTRES
),
142 TEST(WindowExt
.cx
== 21224);
143 TEST(WindowExt
.cy
== 35114);
145 /* Check the viewport, should be the same */
146 GetViewportExtEx(hDC
, &ViewportExt
);
147 TEST(ViewportExt
.cx
== GetDeviceCaps(GetDC(0), HORZRES
));
148 TEST(ViewportExt
.cy
== -GetDeviceCaps(GetDC(0), VERTRES
));
150 /* again isotropic mode with 1:1 res */
151 ret
= SetWindowExtEx(hDC
, 123, 123, &WindowExt
);
153 TEST(WindowExt
.cx
== 4 * GetDeviceCaps(GetDC(0), HORZRES
));
154 TEST(WindowExt
.cy
== -4 * GetDeviceCaps(GetDC(0), VERTRES
));
157 //TEST(pDC_Attr->flXform & PAGE_EXTENTS_CHANGED);
159 /* Check the viewport from the dcattr, without going through gdi */
160 //TEST(pDC_Attr->szlViewportExt.cx == GetDeviceCaps(GetDC(0), HORZRES));
161 //TEST(pDC_Attr->szlViewportExt.cy == -GetDeviceCaps(GetDC(0), VERTRES));
163 /* Check the viewport with gdi, should not be the same */
164 GetViewportExtEx(hDC
, &ViewportExt
);
165 TEST(ViewportExt
.cx
== GetDeviceCaps(GetDC(0), VERTRES
));
166 TEST(ViewportExt
.cy
== -GetDeviceCaps(GetDC(0), VERTRES
));
169 //TEST(pDC_Attr->flXform & PAGE_EXTENTS_CHANGED);
171 /* again isotropic mode with 3:1 res */
172 ret
= SetWindowExtEx(hDC
, 300, 100, &WindowExt
);
174 TEST(WindowExt
.cx
== 123);
175 TEST(WindowExt
.cy
== 123);
177 /* Check the viewport now, should not be the same */
178 GetViewportExtEx(hDC
, &ViewportExt
);
179 TEST(ViewportExt
.cx
== GetDeviceCaps(GetDC(0), VERTRES
));
180 TEST(ViewportExt
.cy
== -GetDeviceCaps(GetDC(0), VERTRES
) / 3);
182 /* again isotropic mode with 1:3 res */
183 SetViewportExtEx(hDC
, 6000, 3000, 0);
184 ret
= SetWindowExtEx(hDC
, 200, 600, &WindowExt
);
186 TEST(WindowExt
.cx
== 300);
187 TEST(WindowExt
.cy
== 100);
189 /* Check the viewport now, should not be the same */
190 GetViewportExtEx(hDC
, &ViewportExt
);
191 TEST(ViewportExt
.cx
== 1000);
192 TEST(ViewportExt
.cy
== 3000);
194 /* Test setting in anisotropic mode */
195 SetMapMode(hDC
, MM_ANISOTROPIC
);
196 ret
= SetWindowExtEx(hDC
, 80, 60, &WindowExt
);
198 TEST(WindowExt
.cx
== 200);
199 TEST(WindowExt
.cy
== 600);
201 /* Values should be changed */
202 ret
= SetWindowExtEx(hDC
, 500, 500, &WindowExt
);
204 TEST(WindowExt
.cx
== 80);
205 TEST(WindowExt
.cy
== 60);
207 /* Check the viewport */
208 GetViewportExtEx(hDC
, &ViewportExt
);
209 TEST(ViewportExt
.cx
== 1000);
210 TEST(ViewportExt
.cy
== 3000);
212 /* Test setting in low metric mode */
213 SetMapMode(hDC
, MM_LOMETRIC
);
214 ret
= SetWindowExtEx(hDC
, 120, 90, &WindowExt
);
216 //TEST(WindowExt.cx == 3600);
217 //TEST(WindowExt.cy == 2700);
219 /* Values should not be changed */
220 WindowExt
.cx
= WindowExt
.cy
= 0;
221 ret
= SetWindowExtEx(hDC
, 900, 700, &WindowExt
);
223 //TEST(WindowExt.cx == 3600);
224 //TEST(WindowExt.cy == 2700);
226 /* Check the viewport */
227 GetViewportExtEx(hDC
, &ViewportExt
);
228 TEST(ViewportExt
.cx
== GetDeviceCaps(GetDC(0), HORZRES
));
229 TEST(ViewportExt
.cy
== -GetDeviceCaps(GetDC(0), VERTRES
));
231 /* Test setting in high metric mode */
232 SetMapMode(hDC
, MM_HIMETRIC
);
233 ret
= SetWindowExtEx(hDC
, 120, 90, &WindowExt
);
235 //TEST(WindowExt.cx == 36000);
236 //TEST(WindowExt.cy == 27000);
238 /* Values should not be changed */
239 WindowExt
.cx
= WindowExt
.cy
= 0;
240 ret
= SetWindowExtEx(hDC
, 500, 300, &WindowExt
);
242 //TEST(WindowExt.cx == 36000);
243 //TEST(WindowExt.cy == 27000);
245 /* Check the viewport */
246 GetViewportExtEx(hDC
, &ViewportExt
);
247 TEST(ViewportExt
.cx
== GetDeviceCaps(GetDC(0), HORZRES
));
248 TEST(ViewportExt
.cy
== -GetDeviceCaps(GetDC(0), VERTRES
));
250 /* Test setting in low english mode */
251 SetMapMode(hDC
, MM_LOENGLISH
);
252 ret
= SetWindowExtEx(hDC
, 320, 290, &WindowExt
);
254 //TEST(WindowExt.cx == 1417);
255 //TEST(WindowExt.cy == 1063);
257 /* Values should not be changed */
258 WindowExt
.cx
= WindowExt
.cy
= 0;
259 ret
= SetWindowExtEx(hDC
, 560, 140, &WindowExt
);
261 //TEST(WindowExt.cx == 1417);
262 //TEST(WindowExt.cy == 1063);
264 /* Check the viewport */
265 GetViewportExtEx(hDC
, &ViewportExt
);
266 TEST(ViewportExt
.cx
== GetDeviceCaps(GetDC(0), HORZRES
));
267 TEST(ViewportExt
.cy
== -GetDeviceCaps(GetDC(0), VERTRES
));
269 /* Test setting in high english mode */
270 SetMapMode(hDC
, MM_HIENGLISH
);
271 ret
= SetWindowExtEx(hDC
, 320, 290, &WindowExt
);
273 //TEST(WindowExt.cx == 14173);
274 //TEST(WindowExt.cy == 10630);
276 /* Values should not be changed */
277 WindowExt
.cx
= WindowExt
.cy
= 0;
278 ret
= SetWindowExtEx(hDC
, 1560, 1140, &WindowExt
);
280 //TEST(WindowExt.cx == 14173);
281 //TEST(WindowExt.cy == 10630);
283 /* Check the viewport */
284 GetViewportExtEx(hDC
, &ViewportExt
);
285 TEST(ViewportExt
.cx
== GetDeviceCaps(GetDC(0), HORZRES
));
286 TEST(ViewportExt
.cy
== -GetDeviceCaps(GetDC(0), VERTRES
));
288 /* Test setting in twips mode */
289 SetMapMode(hDC
, MM_TWIPS
);
290 ret
= SetWindowExtEx(hDC
, 3320, 3290, &WindowExt
);
292 //TEST(WindowExt.cx == 20409);
293 //TEST(WindowExt.cy == 15307);
295 /* Values should not be changed */
296 WindowExt
.cx
= WindowExt
.cy
= 0;
297 ret
= SetWindowExtEx(hDC
, 4560, 4140, &WindowExt
);
299 //TEST(WindowExt.cx == 20409);
300 //TEST(WindowExt.cy == 15307);
302 /* Check the viewport */
303 GetViewportExtEx(hDC
, &ViewportExt
);
304 TEST(ViewportExt
.cx
== GetDeviceCaps(GetDC(0), HORZRES
));
305 TEST(ViewportExt
.cy
== -GetDeviceCaps(GetDC(0), VERTRES
));
307 /* test manually modifying the dcattr, should go to tests for GetViewportExtEx */
308 SetMapMode(hDC
, MM_ISOTROPIC
);
309 ret
= SetWindowExtEx(hDC
, 420, 4140, &WindowExt
);
310 //pDC_Attr->szlWindowExt.cx = 0;
311 GetViewportExtEx(hDC
, &ViewportExt
);
312 //TEST(pDC_Attr->szlWindowExt.cx == 0);
313 //TEST(ViewportExt.cx == 0);
318 START_TEST(SetWindowExtEx
)
320 Test_SetWindowExtEx();