2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for SetWindowExtEx
5 * PROGRAMMERS: Timo Kreuzer
12 #define TEST(x) ok(x, #x"\n")
13 #define RTEST(x) ok(x, #x"\n")
15 void Test_SetWindowExtEx()
19 SIZE WindowExt
, ViewportExt
;
20 //PGDI_TABLE_ENTRY pEntry;
23 hDC
= CreateCompatibleDC(0);
24 ok(hDC
!= NULL
, "CreateCompatibleDC failed. Skipping tests.\n");
25 if (hDC
== NULL
) return;
28 ret
= SetWindowExtEx(0, 0, 0, NULL
);
29 TEST(GetLastError() == ERROR_INVALID_HANDLE
);
33 ret
= SetWindowExtEx((HDC
)0x1234, 0, 0, NULL
);
34 TEST(GetLastError() == ERROR_INVALID_HANDLE
);
38 ret
= SetWindowExtEx(hDC
, 0, 0, NULL
);
39 TEST(GetLastError() == 0);
45 ret
= SetWindowExtEx(0, 0, 0, &WindowExt
);
46 TEST(GetLastError() == ERROR_INVALID_HANDLE
);
48 TEST(WindowExt
.cx
== 1234);
49 TEST(WindowExt
.cy
== 6789);
53 /* Test with a deleted DC */
55 ret
= SetWindowExtEx(hDC
, 0, 0, NULL
);
56 TEST(GetLastError() == ERROR_INVALID_PARAMETER
);
59 hDC
= CreateCompatibleDC(0);
60 ok(hDC
!= NULL
, "CreateCompatibleDC failed. Skipping tests.\n");
61 if (hDC
== NULL
) return;
63 //pEntry = GdiHandleTable + GDI_HANDLE_GET_INDEX(hDC);
64 //pDC_Attr = pEntry->UserData;
67 /* Test setting it without changing the map mode (MM_TEXT) */
68 ret
= SetWindowExtEx(hDC
, 10, 20, &WindowExt
);
70 TEST(WindowExt
.cx
== 1);
71 TEST(WindowExt
.cy
== 1);
73 /* Values should not be changed */
74 WindowExt
.cx
= WindowExt
.cy
= 0;
75 ret
= SetWindowExtEx(hDC
, 40, 30, &WindowExt
);
77 TEST(WindowExt
.cx
== 1);
78 TEST(WindowExt
.cy
== 1);
80 /* Check the viewport */
81 GetViewportExtEx(hDC
, &ViewportExt
);
82 TEST(ViewportExt
.cx
== 1);
83 TEST(ViewportExt
.cy
== 1);
85 /* Test setting in isotropic mode with 0 extents */
86 SetMapMode(hDC
, MM_ISOTROPIC
);
87 WindowExt
.cx
= WindowExt
.cy
= 0;
88 ret
= SetWindowExtEx(hDC
, 0, 0, &WindowExt
);
90 //TEST(WindowExt.cx == 3600);
91 //TEST(WindowExt.cy == 2700);
92 ret
= SetWindowExtEx(hDC
, 100, 0, &WindowExt
);
94 ret
= SetWindowExtEx(hDC
, 0, 100, &WindowExt
);
97 /* Test setting in isotropic mode */
98 ret
= SetWindowExtEx(hDC
, 21224, 35114, &WindowExt
);
100 //TEST(WindowExt.cx == 3600);
101 //TEST(WindowExt.cy == 2700);
103 /* Values should be changed */
104 ret
= SetWindowExtEx(hDC
,
105 4 * GetDeviceCaps(GetDC(0), HORZRES
),
106 -4 * GetDeviceCaps(GetDC(0), VERTRES
),
109 TEST(WindowExt
.cx
== 21224);
110 TEST(WindowExt
.cy
== 35114);
112 /* Check the viewport, should be the same */
113 GetViewportExtEx(hDC
, &ViewportExt
);
114 TEST(ViewportExt
.cx
== GetDeviceCaps(GetDC(0), HORZRES
));
115 TEST(ViewportExt
.cy
== -GetDeviceCaps(GetDC(0), VERTRES
));
117 /* again isotropic mode with 1:1 res */
118 ret
= SetWindowExtEx(hDC
, 123, 123, &WindowExt
);
120 TEST(WindowExt
.cx
== 4 * GetDeviceCaps(GetDC(0), HORZRES
));
121 TEST(WindowExt
.cy
== -4 * GetDeviceCaps(GetDC(0), VERTRES
));
124 //TEST(pDC_Attr->flXform & PAGE_EXTENTS_CHANGED);
126 /* Check the viewport from the dcattr, without going through gdi */
127 //TEST(pDC_Attr->szlViewportExt.cx == GetDeviceCaps(GetDC(0), HORZRES));
128 //TEST(pDC_Attr->szlViewportExt.cy == -GetDeviceCaps(GetDC(0), VERTRES));
130 /* Check the viewport with gdi, should not be the same */
131 GetViewportExtEx(hDC
, &ViewportExt
);
132 TEST(ViewportExt
.cx
== GetDeviceCaps(GetDC(0), VERTRES
));
133 TEST(ViewportExt
.cy
== -GetDeviceCaps(GetDC(0), VERTRES
));
136 //TEST(pDC_Attr->flXform & PAGE_EXTENTS_CHANGED);
138 /* again isotropic mode with 3:1 res */
139 ret
= SetWindowExtEx(hDC
, 300, 100, &WindowExt
);
141 TEST(WindowExt
.cx
== 123);
142 TEST(WindowExt
.cy
== 123);
144 /* Check the viewport now, should not be the same */
145 GetViewportExtEx(hDC
, &ViewportExt
);
146 TEST(ViewportExt
.cx
== GetDeviceCaps(GetDC(0), VERTRES
));
147 TEST(ViewportExt
.cy
== -GetDeviceCaps(GetDC(0), VERTRES
) / 3);
149 /* again isotropic mode with 1:3 res */
150 SetViewportExtEx(hDC
, 6000, 3000, 0);
151 ret
= SetWindowExtEx(hDC
, 200, 600, &WindowExt
);
153 TEST(WindowExt
.cx
== 300);
154 TEST(WindowExt
.cy
== 100);
156 /* Check the viewport now, should not be the same */
157 GetViewportExtEx(hDC
, &ViewportExt
);
158 TEST(ViewportExt
.cx
== 1000);
159 TEST(ViewportExt
.cy
== 3000);
161 /* Test setting in anisotropic mode */
162 SetMapMode(hDC
, MM_ANISOTROPIC
);
163 ret
= SetWindowExtEx(hDC
, 80, 60, &WindowExt
);
165 TEST(WindowExt
.cx
== 200);
166 TEST(WindowExt
.cy
== 600);
168 /* Values should be changed */
169 ret
= SetWindowExtEx(hDC
, 500, 500, &WindowExt
);
171 TEST(WindowExt
.cx
== 80);
172 TEST(WindowExt
.cy
== 60);
174 /* Check the viewport */
175 GetViewportExtEx(hDC
, &ViewportExt
);
176 TEST(ViewportExt
.cx
== 1000);
177 TEST(ViewportExt
.cy
== 3000);
179 /* Test setting in low metric mode */
180 SetMapMode(hDC
, MM_LOMETRIC
);
181 ret
= SetWindowExtEx(hDC
, 120, 90, &WindowExt
);
183 //TEST(WindowExt.cx == 3600);
184 //TEST(WindowExt.cy == 2700);
186 /* Values should not be changed */
187 WindowExt
.cx
= WindowExt
.cy
= 0;
188 ret
= SetWindowExtEx(hDC
, 900, 700, &WindowExt
);
190 //TEST(WindowExt.cx == 3600);
191 //TEST(WindowExt.cy == 2700);
193 /* Check the viewport */
194 GetViewportExtEx(hDC
, &ViewportExt
);
195 TEST(ViewportExt
.cx
== GetDeviceCaps(GetDC(0), HORZRES
));
196 TEST(ViewportExt
.cy
== -GetDeviceCaps(GetDC(0), VERTRES
));
198 /* Test setting in high metric mode */
199 SetMapMode(hDC
, MM_HIMETRIC
);
200 ret
= SetWindowExtEx(hDC
, 120, 90, &WindowExt
);
202 //TEST(WindowExt.cx == 36000);
203 //TEST(WindowExt.cy == 27000);
205 /* Values should not be changed */
206 WindowExt
.cx
= WindowExt
.cy
= 0;
207 ret
= SetWindowExtEx(hDC
, 500, 300, &WindowExt
);
209 //TEST(WindowExt.cx == 36000);
210 //TEST(WindowExt.cy == 27000);
212 /* Check the viewport */
213 GetViewportExtEx(hDC
, &ViewportExt
);
214 TEST(ViewportExt
.cx
== GetDeviceCaps(GetDC(0), HORZRES
));
215 TEST(ViewportExt
.cy
== -GetDeviceCaps(GetDC(0), VERTRES
));
217 /* Test setting in low english mode */
218 SetMapMode(hDC
, MM_LOENGLISH
);
219 ret
= SetWindowExtEx(hDC
, 320, 290, &WindowExt
);
221 //TEST(WindowExt.cx == 1417);
222 //TEST(WindowExt.cy == 1063);
224 /* Values should not be changed */
225 WindowExt
.cx
= WindowExt
.cy
= 0;
226 ret
= SetWindowExtEx(hDC
, 560, 140, &WindowExt
);
228 //TEST(WindowExt.cx == 1417);
229 //TEST(WindowExt.cy == 1063);
231 /* Check the viewport */
232 GetViewportExtEx(hDC
, &ViewportExt
);
233 TEST(ViewportExt
.cx
== GetDeviceCaps(GetDC(0), HORZRES
));
234 TEST(ViewportExt
.cy
== -GetDeviceCaps(GetDC(0), VERTRES
));
236 /* Test setting in high english mode */
237 SetMapMode(hDC
, MM_HIENGLISH
);
238 ret
= SetWindowExtEx(hDC
, 320, 290, &WindowExt
);
240 //TEST(WindowExt.cx == 14173);
241 //TEST(WindowExt.cy == 10630);
243 /* Values should not be changed */
244 WindowExt
.cx
= WindowExt
.cy
= 0;
245 ret
= SetWindowExtEx(hDC
, 1560, 1140, &WindowExt
);
247 //TEST(WindowExt.cx == 14173);
248 //TEST(WindowExt.cy == 10630);
250 /* Check the viewport */
251 GetViewportExtEx(hDC
, &ViewportExt
);
252 TEST(ViewportExt
.cx
== GetDeviceCaps(GetDC(0), HORZRES
));
253 TEST(ViewportExt
.cy
== -GetDeviceCaps(GetDC(0), VERTRES
));
255 /* Test setting in twips mode */
256 SetMapMode(hDC
, MM_TWIPS
);
257 ret
= SetWindowExtEx(hDC
, 3320, 3290, &WindowExt
);
259 //TEST(WindowExt.cx == 20409);
260 //TEST(WindowExt.cy == 15307);
262 /* Values should not be changed */
263 WindowExt
.cx
= WindowExt
.cy
= 0;
264 ret
= SetWindowExtEx(hDC
, 4560, 4140, &WindowExt
);
266 //TEST(WindowExt.cx == 20409);
267 //TEST(WindowExt.cy == 15307);
269 /* Check the viewport */
270 GetViewportExtEx(hDC
, &ViewportExt
);
271 TEST(ViewportExt
.cx
== GetDeviceCaps(GetDC(0), HORZRES
));
272 TEST(ViewportExt
.cy
== -GetDeviceCaps(GetDC(0), VERTRES
));
274 /* test manually modifying the dcattr, should go to tests for GetViewportExtEx */
275 SetMapMode(hDC
, MM_ISOTROPIC
);
276 ret
= SetWindowExtEx(hDC
, 420, 4140, &WindowExt
);
277 //pDC_Attr->szlWindowExt.cx = 0;
278 GetViewportExtEx(hDC
, &ViewportExt
);
279 //TEST(pDC_Attr->szlWindowExt.cx == 0);
280 //TEST(ViewportExt.cx == 0);
285 START_TEST(SetWindowExtEx
)
287 Test_SetWindowExtEx();