1 /*
2  * PROJECT:     ReactOS api tests
3  * LICENSE:     LGPL-2.0-or-later (https://spdx.org/licenses/LGPL-2.0-or-later)
4  * PURPOSE:     Test for NtGdiTransformPoints
5  * COPYRIGHT:   Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
6  */
7 
8 #include <win32nt.h>
9 
10 START_TEST(NtGdiTransformPoints)
11 {
12     HDC hDC;
13     POINT apt1[3], apt2[3];
14     BOOL ret;
15     SIZE siz;
16 
17     /* NULL HDC */
18 
19     SetLastError(0xDEADBEEF);
20     ret = NtGdiTransformPoints(NULL, NULL, NULL, 0, GdiDpToLp);
21     ok_int(ret, TRUE);
22     ok_err(0xDEADBEEF);
23 
24     SetLastError(0xDEADBEEF);
25     ret = NtGdiTransformPoints(NULL, NULL, NULL, 1, GdiDpToLp);
26     ok_int(ret, FALSE);
27     ok_err(0xDEADBEEF);
28 
29     SetLastError(0xDEADBEEF);
30     ret = NtGdiTransformPoints(NULL, apt1, NULL, 1, GdiDpToLp);
31     ok_int(ret, FALSE);
32     ok_err(0xDEADBEEF);
33 
34     SetLastError(0xDEADBEEF);
35     ret = NtGdiTransformPoints(NULL, NULL, apt2, 1, GdiDpToLp);
36     ok_int(ret, FALSE);
37     ok_err(0xDEADBEEF);
38 
39     SetLastError(0xDEADBEEF);
40     ret = NtGdiTransformPoints(NULL, apt1, apt1, 0, GdiDpToLp);
41     ok_int(ret, TRUE);
42     ok_err(0xDEADBEEF);
43 
44     SetLastError(0xDEADBEEF);
45     ret = NtGdiTransformPoints(NULL, apt1, apt2, 0, GdiDpToLp);
46     ok_int(ret, TRUE);
47     ok_err(0xDEADBEEF);
48 
49     SetLastError(0xDEADBEEF);
50     ret = NtGdiTransformPoints(NULL, apt1, apt2, 1, GdiDpToLp);
51     ok_int(ret, FALSE);
52     ok_err(0xDEADBEEF);
53 
54     /* (HDC)1 */
55 
56     SetLastError(0xDEADBEEF);
57     ret = NtGdiTransformPoints((HDC)1, NULL, NULL, 0, GdiDpToLp);
58     ok_int(ret, TRUE);
59     ok_err(0xDEADBEEF);
60 
61     SetLastError(0xDEADBEEF);
62     ret = NtGdiTransformPoints((HDC)1, NULL, NULL, 1, GdiDpToLp);
63     ok_int(ret, FALSE);
64     ok_err(0xDEADBEEF);
65 
66     SetLastError(0xDEADBEEF);
67     ret = NtGdiTransformPoints((HDC)1, apt1, NULL, 1, GdiDpToLp);
68     ok_int(ret, FALSE);
69     ok_err(0xDEADBEEF);
70 
71     SetLastError(0xDEADBEEF);
72     ret = NtGdiTransformPoints((HDC)1, NULL, apt2, 1, GdiDpToLp);
73     ok_int(ret, FALSE);
74     ok_err(0xDEADBEEF);
75 
76     SetLastError(0xDEADBEEF);
77     ret = NtGdiTransformPoints((HDC)1, apt1, apt1, 0, GdiDpToLp);
78     ok_int(ret, TRUE);
79     ok_err(0xDEADBEEF);
80 
81     SetLastError(0xDEADBEEF);
82     ret = NtGdiTransformPoints((HDC)1, apt1, apt2, 0, GdiDpToLp);
83     ok_int(ret, TRUE);
84     ok_err(0xDEADBEEF);
85 
86     SetLastError(0xDEADBEEF);
87     ret = NtGdiTransformPoints((HDC)1, apt1, apt2, 1, GdiDpToLp);
88     ok_int(ret, FALSE);
89     ok_err(0xDEADBEEF);
90 
91     /* hDC */
92 
93     hDC = CreateCompatibleDC(NULL);
94     ok(hDC != NULL, "hDC was NULL\n");
95 
96     SetMapMode(hDC, MM_TEXT);
97 
98     SetLastError(0xDEADBEEF);
99     ret = NtGdiTransformPoints(hDC, NULL, NULL, 0, GdiDpToLp);
100     ok_int(ret, TRUE);
101     ok_err(0xDEADBEEF);
102 
103     SetLastError(0xDEADBEEF);
104     ret = NtGdiTransformPoints(hDC, NULL, NULL, 1, GdiDpToLp);
105     ok_int(ret, FALSE);
106     ok_err(0xDEADBEEF);
107 
108     SetLastError(0xDEADBEEF);
109     ret = NtGdiTransformPoints(hDC, apt1, NULL, 1, GdiDpToLp);
110     ok_int(ret, FALSE);
111     ok_err(0xDEADBEEF);
112 
113     SetLastError(0xDEADBEEF);
114     ret = NtGdiTransformPoints(hDC, NULL, apt2, 1, GdiDpToLp);
115     ok_int(ret, FALSE);
116     ok_err(0xDEADBEEF);
117 
118     SetLastError(0xDEADBEEF);
119     ret = NtGdiTransformPoints(hDC, apt1, apt1, 0, GdiDpToLp);
120     ok_int(ret, TRUE);
121     ok_err(0xDEADBEEF);
122 
123     SetLastError(0xDEADBEEF);
124     ret = NtGdiTransformPoints(hDC, apt1, apt2, 0, GdiDpToLp);
125     ok_int(ret, TRUE);
126     ok_err(0xDEADBEEF);
127 
128     SetLastError(0xDEADBEEF);
129     apt1[0].x = apt1[0].y = 256;
130     ret = NtGdiTransformPoints(hDC, apt1, apt1, 1, GdiDpToLp);
131     ok_int(ret, TRUE);
132     ok_err(0xDEADBEEF);
133     ok_long(apt1[0].x, 256);
134     ok_long(apt1[0].y, 256);
135 
136     SetLastError(0xDEADBEEF);
137     apt1[0].x = apt1[0].y = 256;
138     apt2[0].x = apt2[0].y = 0xBEEFDEAD;
139     ret = NtGdiTransformPoints(hDC, apt1, apt2, 0, GdiDpToLp);
140     ok_int(ret, TRUE);
141     ok_err(0xDEADBEEF);
142     ok_long(apt1[0].x, 256);
143     ok_long(apt1[0].y, 256);
144     ok_long(apt2[0].x, 0xBEEFDEAD);
145     ok_long(apt2[0].x, 0xBEEFDEAD);
146 
147     SetLastError(0xDEADBEEF);
148     apt1[0].x = apt1[0].y = 256;
149     apt2[0].x = apt2[0].y = 0xBEEFDEAD;
150     ret = NtGdiTransformPoints(hDC, apt1, apt2, 1, GdiDpToLp);
151     ok_int(ret, TRUE);
152     ok_err(0xDEADBEEF);
153     ok_long(apt1[0].x, 256);
154     ok_long(apt1[0].y, 256);
155     ok_long(apt2[0].x, 256);
156     ok_long(apt2[0].x, 256);
157 
158     /* MM_ISOTROPIC */
159 
160     SetMapMode(hDC, MM_ISOTROPIC);
161     ok_int(SetWindowExtEx(hDC, 10, 10, NULL), TRUE);
162     ok_int(GetWindowExtEx(hDC, &siz), TRUE);
163     ok_long(siz.cx, 10);
164     ok_long(siz.cy, 10);
165     ok_int(SetViewportExtEx(hDC, 100, 100, NULL), TRUE);
166     ok_int(GetViewportExtEx(hDC, &siz), TRUE);
167     ok_long(siz.cx, 100);
168     ok_long(siz.cy, 100);
169     SetLastError(0xDEADBEEF);
170     apt1[0].x = apt1[0].y = 256;
171     apt2[0].x = apt2[0].y = 0xBEEFDEAD;
172     ret = NtGdiTransformPoints(hDC, apt1, apt2, 1, GdiDpToLp);
173     ok_int(ret, TRUE);
174     ok_err(0xDEADBEEF);
175     ok_long(apt1[0].x, 256);
176     ok_long(apt1[0].y, 256);
177     ok_long(apt2[0].x, 26);
178     ok_long(apt2[0].x, 26);
179 
180     SetMapMode(hDC, MM_ISOTROPIC);
181     ok_int(SetWindowExtEx(hDC, 10, 10, NULL), TRUE);
182     ok_int(GetWindowExtEx(hDC, &siz), TRUE);
183     ok_long(siz.cx, 10);
184     ok_long(siz.cy, 10);
185     ok_int(SetViewportExtEx(hDC, 20, 100, NULL), TRUE);
186     ok_int(GetViewportExtEx(hDC, &siz), TRUE);
187     ok_long(siz.cx, 20);
188     ok_long(siz.cy, 20);
189     SetLastError(0xDEADBEEF);
190     apt1[0].x = apt1[0].y = 256;
191     apt2[0].x = apt2[0].y = 0xBEEFDEAD;
192     ret = NtGdiTransformPoints(hDC, apt1, apt2, 1, GdiDpToLp);
193     ok_int(ret, TRUE);
194     ok_err(0xDEADBEEF);
195     ok_long(apt1[0].x, 256);
196     ok_long(apt1[0].y, 256);
197     ok_long(apt2[0].x, 128);
198     ok_long(apt2[0].x, 128);
199 
200     SetMapMode(hDC, MM_ISOTROPIC);
201     ok_int(SetWindowExtEx(hDC, 10, 10, NULL), TRUE);
202     ok_int(GetWindowExtEx(hDC, &siz), TRUE);
203     ok_long(siz.cx, 10);
204     ok_long(siz.cy, 10);
205     ok_int(SetViewportExtEx(hDC, 100, 0, NULL), TRUE);
206     ok_int(GetViewportExtEx(hDC, &siz), TRUE);
207     ok_long(siz.cx, 20);
208     ok_long(siz.cy, 20);
209     SetLastError(0xDEADBEEF);
210     apt1[0].x = apt1[0].y = 256;
211     apt2[0].x = apt2[0].y = 0xBEEFDEAD;
212     ret = NtGdiTransformPoints(hDC, apt1, apt2, 1, GdiDpToLp);
213     ok_int(ret, TRUE);
214     ok_err(0xDEADBEEF);
215     ok_long(apt1[0].x, 256);
216     ok_long(apt1[0].y, 256);
217     ok_long(apt2[0].x, 128);
218     ok_long(apt2[0].x, 128);
219 
220     SetMapMode(hDC, MM_ISOTROPIC);
221     ok_int(SetWindowExtEx(hDC, 10, 10, NULL), TRUE);
222     ok_int(GetWindowExtEx(hDC, &siz), TRUE);
223     ok_long(siz.cx, 10);
224     ok_long(siz.cy, 10);
225     ok_int(SetViewportExtEx(hDC, 0, 100, NULL), TRUE);
226     ok_int(GetViewportExtEx(hDC, &siz), TRUE);
227     ok_long(siz.cx, 20);
228     ok_long(siz.cy, 20);
229     SetLastError(0xDEADBEEF);
230     apt1[0].x = apt1[0].y = 256;
231     apt2[0].x = apt2[0].y = 0xBEEFDEAD;
232     ret = NtGdiTransformPoints(hDC, apt1, apt2, 1, GdiDpToLp);
233     ok_int(ret, TRUE);
234     ok_err(0xDEADBEEF);
235     ok_long(apt1[0].x, 256);
236     ok_long(apt1[0].y, 256);
237     ok_long(apt2[0].x, 128);
238     ok_long(apt2[0].x, 128);
239 
240     SetMapMode(hDC, MM_ISOTROPIC);
241     ok_int(SetWindowExtEx(hDC, 10, 10, NULL), TRUE);
242     ok_int(GetWindowExtEx(hDC, &siz), TRUE);
243     ok_long(siz.cx, 10);
244     ok_long(siz.cy, 10);
245     ok_int(SetViewportExtEx(hDC, 0, 0, NULL), TRUE);
246     ok_int(GetViewportExtEx(hDC, &siz), TRUE);
247     ok_long(siz.cx, 20);
248     ok_long(siz.cy, 20);
249     SetLastError(0xDEADBEEF);
250     apt1[0].x = apt1[0].y = 256;
251     apt2[0].x = apt2[0].y = 0xBEEFDEAD;
252     ret = NtGdiTransformPoints(hDC, apt1, apt2, 1, GdiDpToLp);
253     ok_int(ret, TRUE);
254     ok_err(0xDEADBEEF);
255     ok_long(apt1[0].x, 256);
256     ok_long(apt1[0].y, 256);
257     ok_long(apt2[0].x, 128);
258     ok_long(apt2[0].x, 128);
259 
260     /* MM_ANISOTROPIC */
261 
262     SetMapMode(hDC, MM_ANISOTROPIC);
263     ok_int(SetWindowExtEx(hDC, 10, 10, NULL), TRUE);
264     ok_int(GetWindowExtEx(hDC, &siz), TRUE);
265     ok_long(siz.cx, 10);
266     ok_long(siz.cy, 10);
267     ok_int(SetViewportExtEx(hDC, 100, 100, NULL), TRUE);
268     ok_int(GetViewportExtEx(hDC, &siz), TRUE);
269     ok_long(siz.cx, 100);
270     ok_long(siz.cy, 100);
271     SetLastError(0xDEADBEEF);
272     apt1[0].x = apt1[0].y = 256;
273     apt2[0].x = apt2[0].y = 0xBEEFDEAD;
274     ret = NtGdiTransformPoints(hDC, apt1, apt2, 1, GdiDpToLp);
275     ok_int(ret, TRUE);
276     ok_err(0xDEADBEEF);
277     ok_long(apt1[0].x, 256);
278     ok_long(apt1[0].y, 256);
279     ok_long(apt2[0].x, 26);
280     ok_long(apt2[0].x, 26);
281 
282     SetMapMode(hDC, MM_ANISOTROPIC);
283     ok_int(SetWindowExtEx(hDC, 10, 10, NULL), TRUE);
284     ok_int(GetWindowExtEx(hDC, &siz), TRUE);
285     ok_long(siz.cx, 10);
286     ok_long(siz.cy, 10);
287     ok_int(SetViewportExtEx(hDC, 20, 100, NULL), TRUE);
288     ok_int(GetViewportExtEx(hDC, &siz), TRUE);
289     ok_long(siz.cx, 20);
290     ok_long(siz.cy, 100);
291     SetLastError(0xDEADBEEF);
292     apt1[0].x = apt1[0].y = 256;
293     apt2[0].x = apt2[0].y = 0xBEEFDEAD;
294     ret = NtGdiTransformPoints(hDC, apt1, apt2, 1, GdiDpToLp);
295     ok_int(ret, TRUE);
296     ok_err(0xDEADBEEF);
297     ok_long(apt1[0].x, 256);
298     ok_long(apt1[0].y, 256);
299     ok_long(apt2[0].x, 128);
300     ok_long(apt2[0].x, 128);
301 
302     SetMapMode(hDC, MM_ANISOTROPIC);
303     ok_int(SetWindowExtEx(hDC, 10, 10, NULL), TRUE);
304     ok_int(GetWindowExtEx(hDC, &siz), TRUE);
305     ok_long(siz.cx, 10);
306     ok_long(siz.cy, 10);
307     ok_int(SetViewportExtEx(hDC, 100, 0, NULL), TRUE);
308     ok_int(GetViewportExtEx(hDC, &siz), TRUE);
309     ok_long(siz.cx, 20);
310     ok_long(siz.cy, 100);
311     SetLastError(0xDEADBEEF);
312     apt1[0].x = apt1[0].y = 256;
313     apt2[0].x = apt2[0].y = 0xBEEFDEAD;
314     ret = NtGdiTransformPoints(hDC, apt1, apt2, 1, GdiDpToLp);
315     ok_int(ret, TRUE);
316     ok_err(0xDEADBEEF);
317     ok_long(apt1[0].x, 256);
318     ok_long(apt1[0].y, 256);
319     ok_long(apt2[0].x, 128);
320     ok_long(apt2[0].x, 128);
321 
322     SetMapMode(hDC, MM_ANISOTROPIC);
323     ok_int(SetWindowExtEx(hDC, 10, 10, NULL), TRUE);
324     ok_int(GetWindowExtEx(hDC, &siz), TRUE);
325     ok_long(siz.cx, 10);
326     ok_long(siz.cy, 10);
327     ok_int(SetViewportExtEx(hDC, 0, 100, NULL), TRUE);
328     ok_int(GetViewportExtEx(hDC, &siz), TRUE);
329     ok_long(siz.cx, 20);
330     ok_long(siz.cy, 100);
331     SetLastError(0xDEADBEEF);
332     apt1[0].x = apt1[0].y = 256;
333     apt2[0].x = apt2[0].y = 0xBEEFDEAD;
334     ret = NtGdiTransformPoints(hDC, apt1, apt2, 1, GdiDpToLp);
335     ok_int(ret, TRUE);
336     ok_err(0xDEADBEEF);
337     ok_long(apt1[0].x, 256);
338     ok_long(apt1[0].y, 256);
339     ok_long(apt2[0].x, 128);
340     ok_long(apt2[0].x, 128);
341 
342     SetMapMode(hDC, MM_ANISOTROPIC);
343     ok_int(SetWindowExtEx(hDC, 10, 10, NULL), TRUE);
344     ok_int(GetWindowExtEx(hDC, &siz), TRUE);
345     ok_long(siz.cx, 10);
346     ok_long(siz.cy, 10);
347     ok_int(SetViewportExtEx(hDC, 0, 0, NULL), TRUE);
348     ok_int(GetViewportExtEx(hDC, &siz), TRUE);
349     ok_long(siz.cx, 20);
350     ok_long(siz.cy, 100);
351     SetLastError(0xDEADBEEF);
352     apt1[0].x = apt1[0].y = 256;
353     apt2[0].x = apt2[0].y = 0xBEEFDEAD;
354     ret = NtGdiTransformPoints(hDC, apt1, apt2, 1, GdiDpToLp);
355     ok_int(ret, TRUE);
356     ok_err(0xDEADBEEF);
357     ok_long(apt1[0].x, 256);
358     ok_long(apt1[0].y, 256);
359     ok_long(apt2[0].x, 128);
360     ok_long(apt2[0].x, 128);
361 
362     ret = DeleteDC(hDC);
363     ok_int(ret, TRUE);
364 }
365