1 /*
2  * PROJECT:         ReactOS api tests
3  * LICENSE:         GPL - See COPYING in the top level directory
4  * PURPOSE:         Test for GetSystemMetrics
5  * PROGRAMMERS:     Timo Kreuzer
6  */
7 
8 #include "precomp.h"
9 
Test_GetSystemMetrics()10 void Test_GetSystemMetrics()
11 {
12     INT ret;
13     HDC hDC;
14     BOOL BoolVal;
15     UINT UintVal;
16     RECT rect;
17 
18     SetLastError(0);
19     hDC = GetDC(0);
20 
21     ret = GetSystemMetrics(0);
22     ok(ret > 0, "ret = %d\n", ret);
23 
24     ret = GetSystemMetrics(64);
25     ok(ret == 0, "ret = %d\n", ret);
26     ret = GetSystemMetrics(65);
27     ok(ret == 0, "ret = %d\n", ret);
28     ret = GetSystemMetrics(66);
29     ok(ret == 0, "ret = %d\n", ret);
30 
31 
32     ret = GetSystemMetrics(SM_CXSCREEN);
33     ok(ret == GetDeviceCaps(hDC, HORZRES), "ret = %d\n", ret);
34     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
35 
36     ret = GetSystemMetrics(SM_CYSCREEN);
37     ok(ret == GetDeviceCaps(hDC, VERTRES), "ret = %d\n", ret);
38     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
39 
40     ret = GetSystemMetrics(SM_CXVSCROLL);
41 //    TEST(ret == 0);
42     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
43 
44     ret = GetSystemMetrics(SM_CYHSCROLL);
45 //    TEST(ret == 0);
46     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
47 
48     ret = GetSystemMetrics(SM_CYCAPTION);
49 //    TEST(ret == 0);
50     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
51 
52     ret = GetSystemMetrics(SM_CXBORDER);
53     SystemParametersInfoW(SPI_GETFOCUSBORDERWIDTH, 0, &UintVal, 0);
54     ok(ret == UintVal, "ret = %d\n", ret);
55     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
56 
57     ret = GetSystemMetrics(SM_CYBORDER);
58     SystemParametersInfoW(SPI_GETFOCUSBORDERHEIGHT, 0, &UintVal, 0);
59     ok(ret == UintVal, "ret = %d\n", ret);
60     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
61 
62     ret = GetSystemMetrics(SM_CXDLGFRAME);
63 //    TEST(ret == 0);
64     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
65 
66     ret = GetSystemMetrics(SM_CYDLGFRAME);
67 //    TEST(ret == 0);
68     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
69 
70     ret = GetSystemMetrics(SM_CYVTHUMB);
71 //    TEST(ret == 0);
72     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
73 
74     ret = GetSystemMetrics(SM_CXHTHUMB);
75 //    TEST(ret == 0);
76     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
77 
78     ret = GetSystemMetrics(SM_CXICON);
79 //    TEST(ret == 0);
80     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
81 
82     ret = GetSystemMetrics(SM_CYICON);
83 //    TEST(ret == 0);
84     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
85 
86     ret = GetSystemMetrics(SM_CXCURSOR);
87 //    TEST(ret == 0);
88     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
89 
90     ret = GetSystemMetrics(SM_CYCURSOR);
91 //    TEST(ret == 0);
92     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
93 
94     ret = GetSystemMetrics(SM_CYMENU);
95 //    TEST(ret == 0);
96     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
97 
98     SystemParametersInfoW(SPI_GETWORKAREA, 0, &rect, 0);
99     ret = GetSystemMetrics(SM_CXFULLSCREEN);
100     ok(ret == rect.right, "ret = %d\n", ret);
101     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
102 
103     ret = GetSystemMetrics(SM_CYFULLSCREEN);
104     ok(ret == rect.bottom - rect.top - GetSystemMetrics(SM_CYCAPTION), "ret = %d\n", ret);
105     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
106 
107     ret = GetSystemMetrics(SM_CYKANJIWINDOW);
108 //    TEST(ret == 0);
109     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
110 
111     ret = GetSystemMetrics(SM_MOUSEPRESENT);
112     ok(ret == 1, "ret = %d", ret);
113     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
114 
115     ret = GetSystemMetrics(SM_CYVSCROLL);
116 //    TEST(ret == 0);
117     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
118 
119     ret = GetSystemMetrics(SM_CXHSCROLL);
120 //    TEST(ret == 0);
121     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
122 
123     ret = GetSystemMetrics(SM_DEBUG);
124 //    TEST(ret == 0);
125     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
126 
127     ret = GetSystemMetrics(SM_SWAPBUTTON);
128 //    TEST(ret == 0);
129     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
130 
131     ret = GetSystemMetrics(SM_RESERVED1);
132 //    TEST(ret == 0);
133     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
134 
135     ret = GetSystemMetrics(SM_RESERVED2);
136 //    TEST(ret == 0);
137     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
138 
139     ret = GetSystemMetrics(SM_RESERVED3);
140 //    TEST(ret == 0);
141     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
142 
143     ret = GetSystemMetrics(SM_RESERVED4);
144 //    TEST(ret == 0);
145     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
146 
147     ret = GetSystemMetrics(SM_CXMIN);
148 //    TEST(ret == 0);
149     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
150 
151     ret = GetSystemMetrics(SM_CYMIN);
152 //    TEST(ret == 0);
153     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
154 
155     ret = GetSystemMetrics(SM_CXSIZE);
156 //    TEST(ret == 0);
157     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
158 
159     ret = GetSystemMetrics(SM_CYSIZE);
160 //    TEST(ret == 0);
161     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
162 
163     ret = GetSystemMetrics(SM_CXFRAME);
164 //    TEST(ret == 0);
165     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
166 
167     ret = GetSystemMetrics(SM_CYFRAME);
168 //    TEST(ret == 0);
169     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
170 
171     ret = GetSystemMetrics(SM_CXMINTRACK);
172 //    TEST(ret == 0);
173     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
174 
175     ret = GetSystemMetrics(SM_CYMINTRACK);
176 //    TEST(ret == 0);
177     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
178 
179     ret = GetSystemMetrics(SM_CXDOUBLECLK);
180 //    TEST(ret == 0);
181     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
182 
183     ret = GetSystemMetrics(SM_CYDOUBLECLK);
184 //    TEST(ret == 0);
185     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
186 
187     ret = GetSystemMetrics(SM_CXICONSPACING);
188 //    TEST(ret == 0);
189     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
190 
191     ret = GetSystemMetrics(SM_CYICONSPACING);
192 //    TEST(ret == 0);
193     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
194 
195     ret = GetSystemMetrics(SM_MENUDROPALIGNMENT);
196 //    TEST(ret == 0);
197     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
198 
199     ret = GetSystemMetrics(SM_PENWINDOWS);
200 //    TEST(ret == 0);
201     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
202 
203     ret = GetSystemMetrics(SM_DBCSENABLED);
204 //    TEST(ret == 0);
205     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
206 
207     ret = GetSystemMetrics(SM_CMOUSEBUTTONS);
208 //    TEST(ret == 0);
209     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
210 
211 #if(WINVER >= 0x0400)
212     ret = GetSystemMetrics(SM_SECURE);
213 //    TEST(ret == 0);
214     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
215 
216     ret = GetSystemMetrics(SM_CXEDGE);
217 //    TEST(ret == 0);
218     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
219 
220     ret = GetSystemMetrics(SM_CYEDGE);
221 //    TEST(ret == 0);
222     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
223 
224     ret = GetSystemMetrics(SM_CXMINSPACING);
225 //    TEST(ret == 0);
226     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
227 
228     ret = GetSystemMetrics(SM_CYMINSPACING);
229 //    TEST(ret == 0);
230     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
231 
232     ret = GetSystemMetrics(SM_CXSMICON);
233 //    TEST(ret == 0);
234     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
235 
236     ret = GetSystemMetrics(SM_CYSMICON);
237 //    TEST(ret == 0);
238     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
239 
240     ret = GetSystemMetrics(SM_CYSMCAPTION);
241 //    TEST(ret == 0);
242     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
243 
244     ret = GetSystemMetrics(SM_CXSMSIZE);
245 //    TEST(ret == 0);
246     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
247 
248     ret = GetSystemMetrics(SM_CYSMSIZE);
249 //    TEST(ret == 0);
250     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
251 
252     ret = GetSystemMetrics(SM_CXMENUSIZE);
253 //    TEST(ret == 0);
254     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
255 
256     ret = GetSystemMetrics(SM_CYMENUSIZE);
257 //    TEST(ret == 0);
258     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
259 
260     ret = GetSystemMetrics(SM_ARRANGE);
261 //    TEST(ret == 0);
262     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
263 
264     ret = GetSystemMetrics(SM_CXMINIMIZED);
265 //    TEST(ret == 0);
266     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
267 
268     ret = GetSystemMetrics(SM_CYMINIMIZED);
269 //    TEST(ret == 0);
270     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
271 
272     ret = GetSystemMetrics(SM_CXMAXTRACK);
273 //    TEST(ret == 0);
274     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
275 
276     ret = GetSystemMetrics(SM_CYMAXTRACK);
277 //    TEST(ret == 0);
278     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
279 
280     ret = GetSystemMetrics(SM_CXMAXIMIZED);
281 //    TEST(ret == 0);
282     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
283 
284     ret = GetSystemMetrics(SM_CYMAXIMIZED);
285 //    TEST(ret == 0);
286     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
287 
288     ret = GetSystemMetrics(SM_NETWORK);
289 //    TEST(ret == 0);
290     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
291 
292     ret = GetSystemMetrics(SM_CLEANBOOT);
293 //    TEST(ret == 0);
294     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
295 
296     ret = GetSystemMetrics(SM_CXDRAG);
297 //    TEST(ret == 0);
298     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
299 
300     ret = GetSystemMetrics(SM_CYDRAG);
301 //    TEST(ret == 0);
302     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
303 
304     ret = GetSystemMetrics(SM_SHOWSOUNDS);
305     SystemParametersInfoW(SPI_GETSHOWSOUNDS, 0, &BoolVal, 0);
306     ok(ret == BoolVal, "ret = %d\n", ret);
307     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
308 
309     ret = GetSystemMetrics(SM_CXMENUCHECK);
310 //    TEST(ret == 0);
311     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
312 
313     ret = GetSystemMetrics(SM_CYMENUCHECK);
314 //    TEST(ret == 0);
315     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
316 
317     ret = GetSystemMetrics(SM_SLOWMACHINE);
318 //    TEST(ret == 0);
319     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
320 
321     ret = GetSystemMetrics(SM_MIDEASTENABLED);
322 //    TEST(ret == 0);
323     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
324 #endif
325 
326 #if (WINVER >= 0x0500) || (_WIN32_WINNT >= 0x0400)
327     ret = GetSystemMetrics(SM_MOUSEWHEELPRESENT);
328 //    TEST(ret == 0);
329     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
330 #endif
331 
332 #if(WINVER >= 0x0500)
333     ret = GetSystemMetrics(SM_XVIRTUALSCREEN);
334 //    TEST(ret == 0);
335     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
336 
337     ret = GetSystemMetrics(SM_YVIRTUALSCREEN);
338 //    TEST(ret == 0);
339     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
340 
341     ret = GetSystemMetrics(SM_CXVIRTUALSCREEN);
342 //    TEST(ret == 0);
343     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
344 
345     ret = GetSystemMetrics(SM_CYVIRTUALSCREEN);
346 //    TEST(ret == 0);
347     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
348 
349     ret = GetSystemMetrics(SM_CMONITORS);
350 //    TEST(ret == 0);
351     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
352 
353     ret = GetSystemMetrics(SM_SAMEDISPLAYFORMAT);
354 //    TEST(ret == 0);
355     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
356 #endif
357 
358 #if(_WIN32_WINNT >= 0x0500)
359     ret = GetSystemMetrics(SM_IMMENABLED);
360     ok(ret == 0 || ret == 1, "ret = %d\n", ret);
361     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
362 #endif
363 
364 #if(_WIN32_WINNT >= 0x0501)
365     ret = GetSystemMetrics(SM_CXFOCUSBORDER);
366     SystemParametersInfoW(SPI_GETFOCUSBORDERWIDTH, 0, &UintVal, 0);
367     ok(ret == UintVal, "ret = %d\n", ret);
368     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
369 
370     ret = GetSystemMetrics(SM_CYFOCUSBORDER);
371     SystemParametersInfoW(SPI_GETFOCUSBORDERHEIGHT, 0, &UintVal, 0);
372     ok(ret == UintVal, "ret = %d\n", ret);
373     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
374 
375     ret = GetSystemMetrics(SM_TABLETPC);
376 //    TEST(ret == 0);
377     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
378 
379     ret = GetSystemMetrics(SM_MEDIACENTER);
380 //    TEST(ret == 0);
381     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
382 
383     ret = GetSystemMetrics(SM_STARTER);
384 //    TEST(ret == 0);
385     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
386 
387     ret = GetSystemMetrics(SM_SERVERR2);
388 //    TEST(ret == 0);
389     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
390 #endif
391 
392 #if(_WIN32_WINNT >= 0x0600)
393     ret = GetSystemMetrics(SM_MOUSEHORIZONTALWHEELPRESENT);
394 //    TEST(ret == 0);
395     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
396 
397     ret = GetSystemMetrics(SM_CXPADDEDBORDER);
398 //    TEST(ret == 0);
399     ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError());
400 #endif
401 
402 }
403 
START_TEST(GetSystemMetrics)404 START_TEST(GetSystemMetrics)
405 {
406     Test_GetSystemMetrics();
407 }
408