1 /*
2  * PROJECT:         ReactOS api tests
3  * LICENSE:         GPL - See COPYING in the top level directory
4  * PURPOSE:         Test for NtGdiPolyPolyDraw
5  * PROGRAMMERS:
6  */
7 
8 #include "../win32nt.h"
9 
10 
11 static
12 void
13 Test_Params(void)
14 {
15     ULONG_PTR ret;
16     ULONG Count1[4] = {3, 2, 4, 3};
17     ULONG Count2[2] = {0, 3};
18     ULONG Count3[2] = {0, 0};
19     ULONG Count4[2] = {1, 3};
20     ULONG Count5[2] = {0x80000001, 0x80000001};
21     POINT Points[6] = {{0,0}, {1,1}, {3,-3}, {-2,2}, {4,2}, {2,4}};
22     HDC hDC;
23 
24     SetLastError(0);
25     ret = NtGdiPolyPolyDraw(NULL, NULL, NULL, 0, 0);
26     TEST(ret == 0);
27     TEST(GetLastError() == 0);
28 
29     SetLastError(0);
30     ret = NtGdiPolyPolyDraw(NULL, NULL, NULL, 0, 1);
31     TEST(ret == 0);
32     TEST(GetLastError() == 0);
33 
34     SetLastError(0);
35     ret = NtGdiPolyPolyDraw(NULL, NULL, NULL, 0, 2);
36     TEST(ret == 0);
37     TEST(GetLastError() == 0);
38 
39     SetLastError(0);
40     ret = NtGdiPolyPolyDraw(NULL, NULL, NULL, 0, 3);
41     TEST(ret == 0);
42     TEST(GetLastError() == 0);
43 
44     SetLastError(0);
45     ret = NtGdiPolyPolyDraw(NULL, NULL, NULL, 0, 4);
46     TEST(ret == 0);
47     TEST(GetLastError() == 0);
48 
49     SetLastError(0);
50     ret = NtGdiPolyPolyDraw(NULL, NULL, NULL, 0, 5);
51     TEST(ret == 0);
52     TEST(GetLastError() == 0);
53 
54     SetLastError(0);
55     ret = NtGdiPolyPolyDraw(NULL, NULL, NULL, 0, 6);
56     TEST(ret == 0);
57     TEST(GetLastError() == 0);
58 
59 ////////////////////////////////////////////////////////////////////////////////
60 
61     /* Test with an invalid DC */
62 
63     SetLastError(0);
64     ret = NtGdiPolyPolyDraw(0, Points, Count1, 2, 1);
65     TEST(ret == 0);
66     TEST(GetLastError() == ERROR_INVALID_HANDLE);
67 
68     hDC = (HDC)0x12345;
69 
70     SetLastError(0);
71     ret = NtGdiPolyPolyDraw(hDC, Points, Count1, 2, 0);
72     TEST(ret == 0);
73     TEST(GetLastError() == 0);
74 
75     SetLastError(0);
76     ret = NtGdiPolyPolyDraw(hDC, Points, Count1, 2, 1);
77     TEST(ret == 0);
78     TEST(GetLastError() == ERROR_INVALID_HANDLE);
79 
80     SetLastError(0);
81     ret = NtGdiPolyPolyDraw(hDC, Points, Count1, 2, 2);
82     TEST(ret == 0);
83     TEST(GetLastError() == ERROR_INVALID_HANDLE);
84 
85     SetLastError(0xdeadbeef);
86     ret = NtGdiPolyPolyDraw(hDC, Points, Count1, 2, 3);
87     TEST(ret == 0);
88     ok_long(GetLastError(), 0xdeadbeef);
89 
90     SetLastError(0xdeadbeef);
91     ret = NtGdiPolyPolyDraw(hDC, Points, Count1, 2, 4);
92     TEST(ret == 0);
93     ok_long(GetLastError(), 0xdeadbeef);
94 
95     SetLastError(0xdeadbeef);
96     ret = NtGdiPolyPolyDraw(hDC, Points, Count1, 2, 5);
97     TEST(ret == 0);
98     ok_long(GetLastError(), 0xdeadbeef);
99 
100     SetLastError(0);
101     ret = NtGdiPolyPolyDraw(hDC, Points, Count1, 2, 6);
102     TEST(ret == 0);
103     TEST(GetLastError() == 0);
104 
105     SetLastError(0);
106     ret = NtGdiPolyPolyDraw((HDC)1, Points, Count1, 1, 6);
107     TEST((ret & GDI_HANDLE_BASETYPE_MASK) == GDI_OBJECT_TYPE_REGION);
108     TEST(GetLastError() == 0);
109 
110     SetLastError(0);
111     ret = NtGdiPolyPolyDraw((HDC)0, Points, Count1, 1, 6);
112     TEST(ret == 0);
113     TEST(GetLastError() == 0);
114 
115     SetLastError(0);
116     ret = NtGdiPolyPolyDraw(hDC, Points, Count1, 0, 1);
117     TEST(ret == 0);
118     TEST(GetLastError() == 0);
119 
120     SetLastError(0);
121     ret = NtGdiPolyPolyDraw(hDC, Points, Count2, 2, 1);
122     TEST(ret == 0);
123     TEST(GetLastError() == ERROR_INVALID_HANDLE);
124 
125     SetLastError(0);
126     ret = NtGdiPolyPolyDraw(hDC, Points, NULL, 2, 1);
127     TEST(ret == 0);
128     TEST(GetLastError() == 0);
129 
130     SetLastError(0);
131     ret = NtGdiPolyPolyDraw(hDC, Points, (PVOID)(LONG_PTR)0x81000000, 2, 1);
132     TEST(ret == 0);
133     TEST(GetLastError() == 0);
134 
135     SetLastError(0);
136     ret = NtGdiPolyPolyDraw(hDC, NULL, Count1, 2, 1);
137     TEST(ret == 0);
138     TEST(GetLastError() == 0);
139 
140     SetLastError(0);
141     ret = NtGdiPolyPolyDraw(hDC, (PVOID)(LONG_PTR)0x81000000, Count1, 2, 1);
142     TEST(ret == 0);
143     TEST(GetLastError() == 0);
144 
145 
146 ////////////////////////////////////////////////////////////////////////////////
147 
148     /* Test with a valid DC */
149 
150     hDC = CreateCompatibleDC(NULL);
151     ASSERT(hDC);
152 
153     SetLastError(0);
154     ret = NtGdiPolyPolyDraw(hDC, Points, Count1, 2, 0);
155     TEST(ret == 0);
156     TEST(GetLastError() == 0);
157 
158     SetLastError(0);
159     ret = NtGdiPolyPolyDraw(hDC, Points, Count1, 2, 1);
160     TEST(ret == 1);
161     TEST(GetLastError() == 0);
162 
163     SetLastError(0);
164     ret = NtGdiPolyPolyDraw(hDC, Points, Count1, 2, 2);
165     TEST(ret == 1);
166     TEST(GetLastError() == 0);
167 
168 #if 0
169     SetLastError(0);
170     // better don't do this on win xp!!! (random crashes)
171 //    ret = NtGdiPolyPolyDraw(hDC, Points, Count1, 2, 3);
172     TEST(ret == 0);
173     TEST(GetLastError() == ERROR_INVALID_PARAMETER);
174 
175     SetLastError(0);
176     // better don't do this on win xp!!! (random crashes)
177 //    ret = NtGdiPolyPolyDraw(hDC, Points, Count1, 2, 4);
178     TEST(ret == 0);
179     TEST(GetLastError() == ERROR_INVALID_PARAMETER);
180 
181 #endif
182 
183     SetLastError(0);
184     ret = NtGdiPolyPolyDraw(hDC, Points, Count2, 2, 1);
185     TEST(ret == 0);
186     TEST(GetLastError() == ERROR_INVALID_PARAMETER);
187 
188     SetLastError(0);
189     ret = NtGdiPolyPolyDraw(hDC, Points, Count3, 2, 1);
190     TEST(ret == 0);
191     TEST(GetLastError() == 0);
192 
193     SetLastError(0);
194     ret = NtGdiPolyPolyDraw(hDC, Points, Count4, 2, 1);
195     TEST(ret == 0);
196     TEST(GetLastError() == ERROR_INVALID_PARAMETER);
197 
198     SetLastError(0);
199     ret = NtGdiPolyPolyDraw(hDC, Points, Count5, 2, 1);
200     TEST(ret == 0);
201     TEST(GetLastError() == 87);
202 
203 }
204 
205 
206 
207 START_TEST(NtGdiPolyPolyDraw)
208 {
209     Test_Params();
210 
211 }
212 
213