[WIN32KNT_APITEST]
[reactos.git] / rostests / apitests / win32nt / ntuser / NtUserSystemParametersInfo.c
1 /*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for NtUserSystemParametersInfo
5 * PROGRAMMERS:
6 */
7
8 #include <win32nt.h>
9
10 static const WCHAR* KEY_MOUSE = L"Control Panel\\Mouse";
11 //static const WCHAR* VAL_MOUSE1 = L"MouseThreshold1";
12 //static const WCHAR* VAL_MOUSE2 = L"MouseThreshold2";
13 //static const WCHAR* VAL_MOUSE3 = L"MouseSpeed";
14 //static const WCHAR* VAL_DBLCLKWIDTH = L"DoubleClickWidth";
15 //static const WCHAR* VAL_DBLCLKHEIGHT = L"DoubleClickHeight";
16 //static const WCHAR* VAL_DBLCLKTIME = L"DoubleClickSpeed";
17 static const WCHAR* VAL_SWAP = L"SwapMouseButtons";
18
19 static const WCHAR* KEY_DESKTOP = L"Control Panel\\Desktop";
20 //static const WCHAR* VAL_SCRTO = L"ScreenSaveTimeOut";
21 //static const WCHAR* VAL_SCRACT = L"ScreenSaveActive";
22 //static const WCHAR* VAL_GRID = L"GridGranularity";
23 //static const WCHAR* VAL_DRAG = L"DragFullWindows";
24 //static const WCHAR* VAL_DRAGHEIGHT = L"DragHeight";
25 //static const WCHAR* VAL_DRAGWIDTH = L"DragWidth";
26 //static const WCHAR* VAL_FNTSMOOTH = L"FontSmoothing";
27 static const WCHAR* VAL_PREFMASK = L"UserPreferencesMask";
28
29 enum
30 {
31 UPM_ACTIVEWINDOWTRACKING = 0x01,
32 UPM_MENUANIMATION = 0x02,
33 UPM_COMBOBOXANIMATION = 0x04,
34 UPM_LISTBOXSMOOTHSCROLLING = 0x08,
35 UPM_GRADIENTCAPTIONS = 0x10,
36 UPM_KEYBOARDCUES = 0x20,
37 UPM_ACTIVEWNDTRKZORDER = 0x40,
38 UPM_HOTTRACKING = 0x80,
39 UPM_RESERVED = 0x100,
40 UPM_MENUFADE = 0x200,
41 UPM_SELECTIONFADE = 0x400,
42 UPM_TOOLTIPANIMATION = 0x800,
43 UPM_TOOLTIPFADE = 0x1000,
44 UPM_CURSORSHADOW = 0x2000,
45 UPM_CLICKLOCK = 0x8000,
46 // room for more
47 UPM_UIEFFECTS = 0x80000000,
48 UPM_DEFAULT = 0x80003E9E
49 } USERPREFMASKS;
50
51
52 //static const WCHAR* KEY_MDALIGN = L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows";
53 //static const WCHAR* VAL_MDALIGN = L"MenuDropAlignment";
54
55 static const WCHAR* KEY_METRIC = L"Control Panel\\Desktop\\WindowMetrics";
56 //static const WCHAR* VAL_BORDER = L"BorderWidth";
57 //static const WCHAR* VAL_ICONSPC = L"IconSpacing";
58 //static const WCHAR* VAL_ICONVSPC = L"IconVerticalspacing";
59 //static const WCHAR* VAL_ITWRAP = L"IconTitleWrap";
60
61 static const WCHAR* KEY_SOUND = L"Control Panel\\Sound";
62 static const WCHAR* VAL_BEEP = L"Beep";
63
64 //static const WCHAR* KEY_KBD = L"Control Panel\\Keyboard";
65 //static const WCHAR* VAL_KBDSPD = L"KeyboardSpeed";
66 //static const WCHAR* VAL_KBDDELAY = L"KeyboardDelay";
67
68 //static const WCHAR* KEY_SHOWSNDS = L"Control Panel\\Accessibility\\ShowSounds";
69 //static const WCHAR* KEY_KDBPREF = L"Control Panel\\Accessibility\\Keyboard Preference";
70 //static const WCHAR* KEY_SCRREAD = L"Control Panel\\Accessibility\\Blind Access";
71 //static const WCHAR* VAL_ON = L"On";
72
73 LONG
74 QueryUserRegValueW(PCWSTR pszSubKey, PCWSTR pszValueName, PVOID pData, LPDWORD cbSize, LPDWORD pType)
75 {
76 HKEY hKey;
77 LONG ret;
78
79 RegOpenKeyExW(HKEY_CURRENT_USER, pszSubKey, 0, KEY_QUERY_VALUE, &hKey);
80 ret = RegQueryValueExW(hKey, pszValueName, NULL, pType, (LPBYTE)pData, cbSize);
81 RegCloseKey(hKey);
82 return ret;
83 }
84
85
86 HWND
87 CreateTestWindow()
88 {
89 HINSTANCE hinst = GetModuleHandle(NULL);
90 WNDCLASSA wc;
91
92 wc.style = 0;
93 wc.lpfnWndProc = DefWindowProcA;
94 wc.cbClsExtra = 0;
95 wc.cbWndExtra = 0;
96 wc.hInstance = hinst;
97 wc.hIcon = NULL;
98 wc.hCursor = NULL;
99 wc.hbrBackground = NULL;
100 wc.lpszMenuName = NULL;
101 wc.lpszClassName = "testclass";
102
103 RegisterClassA(&wc);
104 return CreateWindowA("testclass",
105 "testwnd",
106 WS_VISIBLE,
107 0,
108 0,
109 50,
110 30,
111 NULL,
112 NULL,
113 hinst,
114 0);
115 }
116
117 void
118 Test_NtUserSystemParametersInfo_Params(void)
119 {
120 // UINT uint;
121 DWORD data[1000];
122 UINT i, uint;
123 ACCESSTIMEOUT ato;
124 /* Test normal */
125 SetLastError(ERROR_SUCCESS);
126 TEST(NtUserSystemParametersInfo(SPI_GETFOCUSBORDERHEIGHT, 0, &uint, 0) == TRUE);
127 TEST(GetLastError() == ERROR_SUCCESS);
128
129 /* Test invalid SPI code */
130 SetLastError(ERROR_SUCCESS);
131 TEST(NtUserSystemParametersInfo(7, 0, &data, 0) == FALSE);
132 TEST(GetLastError() == ERROR_INVALID_PARAMETER);
133
134 /* Test wrong cbSize member */
135 ato.cbSize = 1;
136 SetLastError(0xdeadbeef);
137 TEST(NtUserSystemParametersInfo(SPI_GETACCESSTIMEOUT, 0, &ato, 0) == FALSE);
138 TEST(GetLastError() == 0xdeadbeef);
139 #if 0
140 /* Test undocumented, but valid SPI codes */
141 for(i = 0; i < 1000; i++) data[i] = 0xdeadbeef;
142 SetLastError(ERROR_SUCCESS);
143 TEST(NtUserSystemParametersInfo(0x1010, 0, &data, 0) == TRUE);
144 TEST(GetLastError() == ERROR_SUCCESS);
145 TEST(data[0] <= 1);
146 TEST(data[1] == 0xdeadbeef);
147
148 for(i = 0; i < 1000; i++) data[i] = 0xbeefdead;
149 SetLastError(ERROR_SUCCESS);
150 TEST(NtUserSystemParametersInfo(0x1011, 0, &data, 0) == TRUE);
151 TEST(GetLastError() == ERROR_SUCCESS);
152 TEST(data[0] == 0xbeefdead);
153 TEST(data[1] == 0xbeefdead);
154 data[0] = 0;
155 NtUserSystemParametersInfo(0x1010, 0, &data, 0);
156 TEST(data[0] == 1);
157
158 for(i = 0; i < 1000; i++) data[i] = 0xdeadbeef;
159 SetLastError(ERROR_SUCCESS);
160 TEST(NtUserSystemParametersInfo(0x1028, 0, &data, 0) == TRUE);
161 TEST(GetLastError() == ERROR_SUCCESS);
162 TEST(data[0] != 0xdeadbeef);
163 TEST(data[1] == 0xdeadbeef);
164
165 for(i = 0; i < 1000; i++) data[i] = 0xbeefdead;
166 SetLastError(ERROR_SUCCESS);
167 TEST(NtUserSystemParametersInfo(0x1029, 0, &data, 0) == TRUE);
168 TEST(GetLastError() == ERROR_SUCCESS);
169 TEST(data[0] == 0xbeefdead);
170 TEST(data[1] == 0xbeefdead);
171
172 for(i = 0; i < 1000; i++) data[i] = 0xdeadbeef;
173 SetLastError(ERROR_SUCCESS);
174 TEST(NtUserSystemParametersInfo(0x102A, 0, &data, 0) == TRUE);
175 TEST(GetLastError() == ERROR_SUCCESS);
176 TEST(data[0] != 0xdeadbeef);
177 TEST(data[1] == 0xdeadbeef);
178
179 for(i = 0; i < 1000; i++) data[i] = 0xbeefdead;
180 SetLastError(ERROR_SUCCESS);
181 TEST(NtUserSystemParametersInfo(4139, 0, &data, 0) == TRUE);
182 TEST(GetLastError() == ERROR_SUCCESS);
183 TEST(data[0] == 0xbeefdead);
184 TEST(data[1] == 0xbeefdead);
185
186 for(i = 0; i < 1000; i++) data[i] = 0xdeadbeef;
187 SetLastError(ERROR_SUCCESS);
188 TEST(NtUserSystemParametersInfo(4140, 0, &data, 0) == TRUE);
189 TEST(GetLastError() == ERROR_SUCCESS);
190 TEST(data[0] != 0xdeadbeef);
191 TEST(data[1] == 0xdeadbeef);
192
193 for(i = 0; i < 1000; i++) data[i] = 0xbeefdead;
194 SetLastError(ERROR_SUCCESS);
195 TEST(NtUserSystemParametersInfo(4141, 0, &data, 0) == TRUE);
196 TEST(GetLastError() == ERROR_SUCCESS);
197 TEST(data[0] == 0xbeefdead);
198 TEST(data[1] == 0xbeefdead);
199
200 for(i = 0; i < 1000; i++) data[i] = 0xdeadbeef;
201 SetLastError(ERROR_SUCCESS);
202 TEST(NtUserSystemParametersInfo(4142, 0, &data, 0) == TRUE);
203 TEST(GetLastError() == ERROR_SUCCESS);
204 TEST(data[0] != 0xdeadbeef);
205 TEST(data[1] == 0xdeadbeef);
206
207 for(i = 0; i < 1000; i++) data[i] = 0xbeefdead;
208 SetLastError(ERROR_SUCCESS);
209 TEST(NtUserSystemParametersInfo(4143, 0, &data, 0) == TRUE);
210 TEST(GetLastError() == ERROR_SUCCESS);
211 TEST(data[0] == 0xbeefdead);
212 TEST(data[1] == 0xbeefdead);
213
214 for(i = 0; i < 1000; i++) data[i] = 0xdeadbeef;
215 SetLastError(ERROR_SUCCESS);
216 TEST(NtUserSystemParametersInfo(4144, 0, &data, 0) == TRUE);
217 TEST(GetLastError() == ERROR_SUCCESS);
218 TEST(data[0] != 0xdeadbeef);
219 TEST(data[1] == 0xdeadbeef);
220
221 for(i = 0; i < 1000; i++) data[i] = 0xbeefdead;
222 SetLastError(ERROR_SUCCESS);
223 TEST(NtUserSystemParametersInfo(4145, 0, &data, 0) == TRUE);
224 TEST(GetLastError() == ERROR_SUCCESS);
225 TEST(data[0] == 0xbeefdead);
226 TEST(data[1] == 0xbeefdead);
227
228 for(i = 0; i < 1000; i++) data[i] = 0xdeadbeef;
229 SetLastError(ERROR_SUCCESS);
230 TEST(NtUserSystemParametersInfo(4146, 0, &data, 0) == TRUE);
231 TEST(GetLastError() == ERROR_SUCCESS);
232 TEST(data[0] != 0xdeadbeef);
233 TEST(data[1] == 0xdeadbeef);
234
235 for(i = 0; i < 1000; i++) data[i] = 0xbeefdead;
236 SetLastError(ERROR_SUCCESS);
237 TEST(NtUserSystemParametersInfo(4147, 0, &data, 0) == TRUE);
238 TEST(GetLastError() == ERROR_SUCCESS);
239 TEST(data[0] == 0xbeefdead);
240 TEST(data[1] == 0xbeefdead);
241
242 for(i = 0; i < 1000; i++) data[i] = 0xdeadbeef;
243 SetLastError(ERROR_SUCCESS);
244 TEST(NtUserSystemParametersInfo(4148, 0, &data, 0) == TRUE);
245 TEST(GetLastError() == ERROR_SUCCESS);
246 TEST(data[0] != 0xdeadbeef);
247 TEST(data[1] == 0xdeadbeef);
248
249 for(i = 0; i < 1000; i++) data[i] = 0xbeefdead;
250 SetLastError(ERROR_SUCCESS);
251 TEST(NtUserSystemParametersInfo(4149, 0, &data, 0) == TRUE);
252 TEST(GetLastError() == ERROR_SUCCESS);
253 TEST(data[0] == 0xbeefdead);
254 TEST(data[1] == 0xbeefdead);
255
256 for(i = 0; i < 1000; i++) data[i] = 0xdeadbeef;
257 SetLastError(ERROR_SUCCESS);
258 TEST(NtUserSystemParametersInfo(4150, 0, &data, 0) == TRUE);
259 TEST(GetLastError() == ERROR_SUCCESS);
260 TEST(data[0] != 0xdeadbeef);
261 TEST(data[1] == 0xdeadbeef);
262
263 for(i = 0; i < 1000; i++) data[i] = 0xbeefdead;
264 SetLastError(ERROR_SUCCESS);
265 TEST(NtUserSystemParametersInfo(4151, 0, &data, 0) == TRUE);
266 TEST(GetLastError() == ERROR_SUCCESS);
267 TEST(data[0] == 0xbeefdead);
268 TEST(data[1] == 0xbeefdead);
269
270 for(i = 0; i < 1000; i++) data[i] = 0xdeadbeef;
271 SetLastError(ERROR_SUCCESS);
272 TEST(NtUserSystemParametersInfo(4152, 0, &data, 0) == TRUE);
273 TEST(GetLastError() == ERROR_SUCCESS);
274 TEST(data[0] != 0xdeadbeef);
275 TEST(data[1] == 0xdeadbeef);
276
277 for(i = 0; i < 1000; i++) data[i] = 0xbeefdead;
278 SetLastError(ERROR_SUCCESS);
279 TEST(NtUserSystemParametersInfo(4153, 0, &data, 0) == TRUE);
280 TEST(GetLastError() == ERROR_SUCCESS);
281 TEST(data[0] == 0xbeefdead);
282 TEST(data[1] == 0xbeefdead);
283
284 for(i = 0; i < 1000; i++) data[i] = 0xdeadbeef;
285 SetLastError(ERROR_SUCCESS);
286 TEST(NtUserSystemParametersInfo(4154, 0, &data, 0) == TRUE);
287 TEST(GetLastError() == ERROR_SUCCESS);
288 TEST(data[0] != 0xdeadbeef);
289 TEST(data[1] == 0xdeadbeef);
290
291 for(i = 0; i < 1000; i++) data[i] = 0xbeefdead;
292 SetLastError(ERROR_SUCCESS);
293 TEST(NtUserSystemParametersInfo(4155, 0, &data, 0) == TRUE);
294 TEST(GetLastError() == ERROR_SUCCESS);
295 TEST(data[0] == 0xbeefdead);
296 TEST(data[1] == 0xbeefdead);
297
298 for(i = 0; i < 1000; i++) data[i] = 0xdeadbeef;
299 SetLastError(ERROR_SUCCESS);
300 TEST(NtUserSystemParametersInfo(4156, 0, &data, 0) == TRUE);
301 TEST(GetLastError() == ERROR_SUCCESS);
302 TEST(data[0] != 0xdeadbeef);
303 TEST(data[1] == 0xdeadbeef);
304
305 for(i = 0; i < 1000; i++) data[i] = 0xbeefdead;
306 SetLastError(ERROR_SUCCESS);
307 TEST(NtUserSystemParametersInfo(4157, 0, &data, 0) == TRUE);
308 TEST(GetLastError() == ERROR_SUCCESS);
309 TEST(data[0] == 0xbeefdead);
310 TEST(data[1] == 0xbeefdead);
311 #endif
312 /* Test invalid pointer */
313 SetLastError(ERROR_SUCCESS);
314 TEST(NtUserSystemParametersInfo(SPI_GETFOCUSBORDERHEIGHT, 0, (PVOID)0x80000000, 0) == FALSE);
315 TEST(GetLastError() == ERROR_NOACCESS);
316 for(i = 0; i < 1000; i++) data[i] = 0xdeadbeef;
317
318 /* test wrong bools */
319 }
320
321 void
322 Test_NtUserSystemParametersInfo_Winsta(void)
323 {
324 HWINSTA hwinsta, hwinstaOld;
325 INT ai[20];
326 BOOL bRet;
327 // INT i;
328
329 hwinstaOld = GetProcessWindowStation();
330 hwinsta = CreateWindowStation(NULL, 0, READ_CONTROL, NULL);
331 SetProcessWindowStation(hwinsta);
332 printf("hwinstaOld=%p, hwinsta=%p\n", hwinstaOld, hwinsta);
333
334 #if 1 // currently Winsta stuff is broken in ros
335 TEST(SystemParametersInfoA(SPI_GETBEEP, 0, ai, 0) == 0);
336 TEST(GetLastError() == ERROR_ACCESS_DENIED);
337 TEST(SystemParametersInfoA(SPI_SETBEEP, 0, ai, 0) == 0);
338 TEST(GetLastError() == ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION);
339 TEST(SystemParametersInfoA(SPI_GETMOUSE, 0, ai, 0) == 0);
340 TEST(GetLastError() == ERROR_ACCESS_DENIED);
341 TEST(SystemParametersInfoA(SPI_SETMOUSE, 0, ai, 0) == 0);
342 TEST(GetLastError() == ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION);
343 TEST(SystemParametersInfoA(SPI_GETBORDER, 0, ai, 0) == 0);
344 TEST(GetLastError() == ERROR_ACCESS_DENIED);
345 TEST(SystemParametersInfoA(SPI_SETBORDER, 0, ai, 0) == 0);
346 TEST(GetLastError() == ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION);
347 TEST(SystemParametersInfoA(SPI_GETKEYBOARDSPEED, 0, ai, 0) == 0);
348 TEST(GetLastError() == ERROR_ACCESS_DENIED);
349 TEST(SystemParametersInfoA(SPI_SETKEYBOARDSPEED, 0, ai, 0) == 0);
350 TEST(GetLastError() == ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION);
351 TEST(SystemParametersInfoA(SPI_ICONHORIZONTALSPACING, 0, ai, 0) == 0);
352 TEST(GetLastError() == ERROR_ACCESS_DENIED);
353 TEST(SystemParametersInfoA(SPI_ICONHORIZONTALSPACING, 32, 0, 0) == 0);
354 TEST(GetLastError() == ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION);
355 TEST(SystemParametersInfoA(SPI_GETSCREENSAVETIMEOUT, 0, ai, 0) == 0);
356 TEST(GetLastError() == ERROR_ACCESS_DENIED);
357 TEST(SystemParametersInfoA(SPI_SETSCREENSAVETIMEOUT, 0, ai, 0) == 0);
358 TEST(GetLastError() == ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION);
359 TEST(SystemParametersInfoA(SPI_GETKEYBOARDCUES, 0, &bRet, 0) == 0);
360 TEST(GetLastError() == ERROR_ACCESS_DENIED);
361 TEST(SystemParametersInfoA(SPI_SETKEYBOARDCUES, 0, (PVOID)1, 0) == 0);
362 TEST(GetLastError() == ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION);
363 #endif
364
365 SetProcessWindowStation(hwinstaOld);
366 }
367
368 void
369 Test_NtUserSystemParametersInfo_fWinIni(void)
370 {
371 ACCESSTIMEOUT ato;
372 // UINT uFocusBorderHeight;
373 WCHAR Buffer[6];
374 DWORD cbSize;
375
376 ato.cbSize = sizeof(ato);
377 NtUserSystemParametersInfo(SPI_GETACCESSTIMEOUT, 0, &ato, 0);
378 ato.iTimeOutMSec++;
379 NtUserSystemParametersInfo(SPI_SETACCESSTIMEOUT, 0, &ato, 0);
380 ato.iTimeOutMSec--;
381
382 // NtUserSystemParametersInfo(SPI_GETFOCUSBORDERHEIGHT, 0, &uFocusBorderHeight, 0);
383 // NtUserSystemParametersInfo(SPI_SETFOCUSBORDERHEIGHT, 0, &uFocusBorderHeight, SPIF_UPDATEINIFILE);
384
385 NtUserSystemParametersInfo(SPI_SETACCESSTIMEOUT, 0, &ato, 0);
386
387 cbSize = 6;
388 QueryUserRegValueW(L"Control Panel\\Accessibility\\TimeOut", L"TimeToWait", &Buffer, &cbSize, NULL);
389
390 }
391
392 void
393 Test_MetricKey(PCWSTR pwszVal, INT iVal)
394 {
395 WCHAR szReg[10];
396 DWORD cbSize;
397
398 cbSize = sizeof(szReg);
399 TESTX(QueryUserRegValueW(KEY_METRIC, pwszVal, &szReg, &cbSize, NULL) == ERROR_SUCCESS, "Value=%S\n", pwszVal);
400 TESTX(_wcsicmp(szReg, L"1") == 0, "Value=%S\n", pwszVal);
401
402 }
403
404 void
405 Test_UserPref(UINT uiGet, UINT uiSet, DWORD dwPrefMask)
406 {
407 BOOL bOrig, bTemp = 0;
408 DWORD dwUserPref, dwUserPrefOrg;
409 DWORD cbSize;
410
411 /* Get original values */
412 NtUserSystemParametersInfo(uiGet, 0, &bOrig, 0);
413 cbSize = sizeof(dwUserPrefOrg);
414 QueryUserRegValueW(KEY_DESKTOP, VAL_PREFMASK, &dwUserPrefOrg, &cbSize, NULL);
415
416 /* Value 0 */
417 NtUserSystemParametersInfo(uiSet, 0, NULL, SPIF_UPDATEINIFILE);
418 NtUserSystemParametersInfo(uiGet, 0, &bTemp, 0);
419 TEST(bTemp == 0);
420 cbSize = sizeof(dwUserPref);
421 TEST(QueryUserRegValueW(KEY_DESKTOP, VAL_PREFMASK, &dwUserPref, &cbSize, NULL) == ERROR_SUCCESS);
422 TEST((dwUserPref & dwPrefMask) == 0);
423 TEST((dwUserPref & (~dwPrefMask)) == (dwUserPrefOrg & (~dwPrefMask)));
424
425 /* Value 1 without Registry */
426 NtUserSystemParametersInfo(uiSet, 0, (PVOID)1, 0);
427 NtUserSystemParametersInfo(uiGet, 0, &bTemp, 0);
428 TEST(bTemp == 1);
429 cbSize = sizeof(dwUserPref);
430 TEST(QueryUserRegValueW(KEY_DESKTOP, VAL_PREFMASK, &dwUserPref, &cbSize, NULL) == ERROR_SUCCESS);
431 TEST((dwUserPref & dwPrefMask) == 0);
432 TEST((dwUserPref & (~dwPrefMask)) == (dwUserPrefOrg & (~dwPrefMask)));
433
434 /* Value 2 without Registry */
435 NtUserSystemParametersInfo(uiSet, 0, (PVOID)2, 0);
436 NtUserSystemParametersInfo(uiGet, 0, &bTemp, 0);
437 TEST(bTemp == 1);
438 cbSize = sizeof(dwUserPref);
439 TEST(QueryUserRegValueW(KEY_DESKTOP, VAL_PREFMASK, &dwUserPref, &cbSize, NULL) == ERROR_SUCCESS);
440 TEST((dwUserPref & dwPrefMask) == 0);
441 TEST((dwUserPref & (~dwPrefMask)) == (dwUserPrefOrg & (~dwPrefMask)));
442
443 /* Value 1 with Registry */
444 NtUserSystemParametersInfo(uiSet, 0, (PVOID)1, SPIF_UPDATEINIFILE);
445 NtUserSystemParametersInfo(uiGet, 0, &bTemp, 0);
446 TEST(bTemp == 1);
447 cbSize = sizeof(dwUserPref);
448 TEST(QueryUserRegValueW(KEY_DESKTOP, VAL_PREFMASK, &dwUserPref, &cbSize, NULL) == ERROR_SUCCESS);
449 TEST((dwUserPref & dwPrefMask) == dwPrefMask);
450 TEST((dwUserPref & (~dwPrefMask)) == (dwUserPrefOrg & (~dwPrefMask)));
451
452 /* Restore original value */
453 NtUserSystemParametersInfo(uiSet, 0, (PVOID)bOrig, SPIF_UPDATEINIFILE);
454
455
456 }
457
458
459 /******************************************************************************/
460
461 void
462 Test_SPI_SETBEEP(void)
463 {
464 BOOL bOrig, bTemp = 0;
465 WCHAR szReg[10];
466 DWORD cbSize;
467
468 /* Get original value */
469 NtUserSystemParametersInfo(SPI_GETBEEP, 0, &bOrig, 0);
470
471 /* Value 0 */
472 NtUserSystemParametersInfo(SPI_SETBEEP, 0, NULL, SPIF_UPDATEINIFILE);
473 NtUserSystemParametersInfo(SPI_GETBEEP, 0, &bTemp, 0);
474 TEST(bTemp == 0);
475 cbSize = sizeof(szReg);
476 TEST(QueryUserRegValueW(KEY_SOUND, VAL_BEEP, &szReg, &cbSize, NULL) == ERROR_SUCCESS);
477 TEST(_wcsicmp(szReg, L"No") == 0);
478
479 /* Value 1 */
480 NtUserSystemParametersInfo(SPI_SETBEEP, 1, NULL, SPIF_UPDATEINIFILE);
481 NtUserSystemParametersInfo(SPI_GETBEEP, 0, &bTemp, 0);
482 TEST(bTemp == 1);
483 cbSize = sizeof(szReg);
484 TEST(QueryUserRegValueW(KEY_SOUND, VAL_BEEP, &szReg, &cbSize, NULL) == ERROR_SUCCESS);
485 TEST(_wcsicmp(szReg, L"Yes") == 0);
486
487 /* Value 2 */
488 NtUserSystemParametersInfo(SPI_SETBEEP, 2, NULL, SPIF_UPDATEINIFILE);
489 NtUserSystemParametersInfo(SPI_GETBEEP, 0, &bTemp, 0);
490 TEST(bTemp == 1);
491 cbSize = sizeof(szReg);
492 TEST(QueryUserRegValueW(KEY_SOUND, VAL_BEEP, &szReg, &cbSize, NULL) == ERROR_SUCCESS);
493 TEST(_wcsicmp(szReg, L"Yes") == 0);
494
495 /* Restore original value */
496 NtUserSystemParametersInfo(SPI_SETBEEP, 0, &bOrig, SPIF_UPDATEINIFILE);
497 }
498
499 void
500 Test_SPI_SETMOUSE(void)
501 {
502 INT aiOrig[3], aiTemp[3];
503
504 /* Get original value */
505 NtUserSystemParametersInfo(SPI_GETMOUSE, 0, aiOrig, 0);
506
507 /* Test uiParam value */
508 TEST(NtUserSystemParametersInfo(SPI_GETMOUSE, 0, aiTemp, 0) == 1);
509 TEST(NtUserSystemParametersInfo(SPI_GETMOUSE, 1, aiTemp, 0) == 1);
510 TEST(NtUserSystemParametersInfo(SPI_GETMOUSE, -1, aiTemp, 0) == 1);
511 TEST(NtUserSystemParametersInfo(SPI_GETMOUSE, 0xdeadbeef, aiTemp, 0) == 1);
512
513 /* Set modified values */
514 aiTemp[0] = aiOrig[0] + 1;
515 aiTemp[1] = aiOrig[1] - 1;
516 aiTemp[2] = aiOrig[2] + 2;
517 NtUserSystemParametersInfo(SPI_SETMOUSE, 2, aiTemp, SPIF_UPDATEINIFILE);
518 aiTemp[0] = aiTemp[1] = aiTemp[2] = 0;
519
520 /* Get new values */
521 NtUserSystemParametersInfo(SPI_GETMOUSE, 0, aiTemp, 0);
522
523 /* Test modified values */
524 TEST(aiTemp[0] == aiOrig[0] + 1);
525 TEST(aiTemp[1] == aiOrig[1] - 1);
526 TEST(aiTemp[2] == aiOrig[2] + 2);
527
528 // FIXME: Test registry values
529
530 /* Restore original value */
531 NtUserSystemParametersInfo(SPI_SETMOUSE, 0, aiOrig, SPIF_UPDATEINIFILE);
532 }
533
534 void
535 Test_SPI_SETBORDER(void)
536 {
537 INT iOrig, iTemp = 0;
538
539 /* Get original value */
540 NtUserSystemParametersInfo(SPI_GETBORDER, 0, &iOrig, 0);
541
542 /* Value 0 */
543 NtUserSystemParametersInfo(SPI_SETBORDER, 0, NULL, SPIF_UPDATEINIFILE);
544 NtUserSystemParametersInfo(SPI_GETBORDER, 0, &iTemp, 0);
545 TEST(iTemp == 1);
546 TEST(GetSystemMetrics(SM_CXBORDER) == 1);
547
548 /* Value 1 */
549 NtUserSystemParametersInfo(SPI_SETBORDER, 1, NULL, SPIF_UPDATEINIFILE);
550 NtUserSystemParametersInfo(SPI_GETBORDER, 0, &iTemp, 0);
551 TEST(iTemp == 1);
552 // Test_MetricKey(pti, VAL_BORDER, 1);
553
554 /* Value 2 */
555 NtUserSystemParametersInfo(SPI_SETBORDER, 2, NULL, SPIF_UPDATEINIFILE);
556 NtUserSystemParametersInfo(SPI_GETBORDER, 0, &iTemp, 0);
557 TEST(iTemp == 2);
558 TEST(GetSystemMetrics(SM_CXBORDER) == 1);
559
560 /* Restore original value */
561 NtUserSystemParametersInfo(SPI_SETBORDER, iOrig, NULL, SPIF_UPDATEINIFILE);
562
563 }
564
565 // Test_SPI_SETKEYBOARDSPEED();
566 // Test_SPI_LANGDRIVER();
567 // Test_SPI_ICONHORIZONTALSPACING();
568 // Test_SPI_SETSCREENSAVETIMEOUT();
569 // Test_SPI_SETSCREENSAVEACTIVE();
570 // Test_SPI_SETGRIDGRANULARITY();
571
572 void
573 Test_SPI_SETDESKWALLPAPER(void)
574 {
575 UNICODE_STRING ustrOld, ustrNew;
576 WCHAR szOld[MAX_PATH];
577 WCHAR szNew[MAX_PATH];
578
579 /* Get old Wallpaper */
580 TEST(NtUserSystemParametersInfo(SPI_GETDESKWALLPAPER, MAX_PATH, szOld, 0) == 1);
581 RtlInitUnicodeString(&ustrOld, szOld);
582
583 /* Set no Wallpaper */
584 TEST(NtUserSystemParametersInfo(SPI_SETDESKWALLPAPER, 0, L"", 0) == 1);
585 TEST(NtUserSystemParametersInfo(SPI_GETDESKWALLPAPER, MAX_PATH, szNew, 0) == 1);
586 TEST(szNew[0] == 0);
587
588 /* Set no Wallpaper 2 */
589 RtlInitUnicodeString(&ustrNew, L"");
590 TEST(NtUserSystemParametersInfo(SPI_SETDESKWALLPAPER, 0, &ustrNew, 0) == 1);
591 TEST(NtUserSystemParametersInfo(SPI_GETDESKWALLPAPER, MAX_PATH, szNew, 0) == 1);
592 TEST(szNew[0] == 0);
593
594 /* Reset Wallpaper */
595 TEST(NtUserSystemParametersInfo(SPI_SETDESKWALLPAPER, 0, NULL, 0) == 1);
596 TEST(NtUserSystemParametersInfo(SPI_GETDESKWALLPAPER, MAX_PATH, szNew, 0) == 1);
597 TEST(wcscmp(szNew, szOld) == 0);
598
599 /* Set new Wallpaper */
600 RtlInitUnicodeString(&ustrNew, L"test.bmp");
601 TEST(NtUserSystemParametersInfo(SPI_SETDESKWALLPAPER, 0, &ustrNew, 0) == 1);
602 TEST(NtUserSystemParametersInfo(SPI_GETDESKWALLPAPER, MAX_PATH, szNew, 0) == 1);
603 TEST(wcscmp(szNew, L"test.bmp") == 0);
604
605 /* Get Wallpaper, too small buffer */
606 szNew[0] = 0; szNew[1] = 0; szNew[2] = 0;
607 TEST(NtUserSystemParametersInfo(SPI_GETDESKWALLPAPER, 3, szNew, 0) == 1);
608 TEST(szNew[0] != 0);
609 TEST(szNew[1] != 0);
610 TEST(szNew[2] != 0);
611
612 /* Set invalid Wallpaper */
613 SetLastError(0xdeadbeef);
614 RtlInitUnicodeString(&ustrNew, L"*#!!-&");
615 TEST(NtUserSystemParametersInfo(SPI_SETDESKWALLPAPER, 0, &ustrNew, 0) == 0);
616 TEST(GetLastError() == ERROR_FILE_NOT_FOUND);
617 TEST(NtUserSystemParametersInfo(SPI_GETDESKWALLPAPER, MAX_PATH, szNew, 0) == 1);
618 TEST(wcscmp(szNew, L"*#!!-&") == 0);
619
620 /* Restore old Wallpaper */
621 TEST(NtUserSystemParametersInfo(SPI_SETDESKWALLPAPER, MAX_PATH, &ustrOld, SPIF_UPDATEINIFILE) == 1);
622
623 }
624
625 // Test_SPI_SETDESKPATTERN();
626 // Test_SPI_SETKEYBOARDDELAY();
627 // Test_SPI_ICONVERTICALSPACING();
628 // Test_SPI_SETICONTITLEWRAP();
629 // Test_SPI_SETMENUDROPALIGNMENT();
630 // Test_SPI_SETDOUBLECLKWIDTH();
631 // Test_SPI_SETDOUBLECLKHEIGHT();
632 // Test_SPI_SETDOUBLECLICKTIME();
633
634 void
635 Test_SPI_SETMOUSEBUTTONSWAP(void)
636 {
637 BOOL bOrig, bTemp = 0;
638 WCHAR szReg[10];
639 DWORD cbSize;
640
641 /* Get original value */
642 bOrig = GetSystemMetrics(SM_SWAPBUTTON);
643
644 /* Value 0 */
645 NtUserSystemParametersInfo(SPI_SETMOUSEBUTTONSWAP, 0, NULL, SPIF_UPDATEINIFILE);
646 bTemp = GetSystemMetrics(SM_SWAPBUTTON);
647 TEST(bTemp == 0);
648 cbSize = sizeof(szReg);
649 TEST(QueryUserRegValueW(KEY_MOUSE, VAL_SWAP, &szReg, &cbSize, NULL) == ERROR_SUCCESS);
650 TEST(_wcsicmp(szReg, L"0") == 0);
651
652 /* Value 1 */
653 NtUserSystemParametersInfo(SPI_SETMOUSEBUTTONSWAP, 1, NULL, SPIF_UPDATEINIFILE);
654 bTemp = GetSystemMetrics(SM_SWAPBUTTON);
655 TEST(bTemp == 1);
656 cbSize = sizeof(szReg);
657 TEST(QueryUserRegValueW(KEY_MOUSE, VAL_SWAP, &szReg, &cbSize, NULL) == ERROR_SUCCESS);
658 TEST(_wcsicmp(szReg, L"1") == 0);
659
660 /* Value 2 */
661 NtUserSystemParametersInfo(SPI_SETMOUSEBUTTONSWAP, 2, NULL, SPIF_UPDATEINIFILE);
662 bTemp = GetSystemMetrics(SM_SWAPBUTTON);
663 TEST(bTemp == 1);
664 cbSize = sizeof(szReg);
665 TEST(QueryUserRegValueW(KEY_MOUSE, VAL_SWAP, &szReg, &cbSize, NULL) == ERROR_SUCCESS);
666 TEST(_wcsicmp(szReg, L"2") == 0);
667
668 /* Value -1 */
669 NtUserSystemParametersInfo(SPI_SETMOUSEBUTTONSWAP, -1, NULL, SPIF_UPDATEINIFILE);
670 bTemp = GetSystemMetrics(SM_SWAPBUTTON);
671 TEST(bTemp == 1);
672 cbSize = sizeof(szReg);
673 TEST(QueryUserRegValueW(KEY_MOUSE, VAL_SWAP, &szReg, &cbSize, NULL) == ERROR_SUCCESS);
674 TEST(_wcsicmp(szReg, L"-1") == 0);
675
676 /* Restore original value */
677 NtUserSystemParametersInfo(SPI_SETMOUSEBUTTONSWAP, bOrig, 0, SPIF_UPDATEINIFILE);
678
679
680 }
681
682 void
683 Test_SPI_SETICONTITLELOGFONT(void)
684 {
685 LOGFONTW lfOrig;
686 struct
687 {
688 LOGFONTW lf;
689 DWORD dwRedzone;
690 } buf;
691
692 /* Get original value */
693 ASSERT(NtUserSystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(lfOrig), &lfOrig, 0));
694
695 /* Test uiParam == 0 */
696 memset(&buf, 0, sizeof(buf));
697 buf.lf.lfFaceName[LF_FACESIZE-1] = 33;
698 buf.dwRedzone = 0xdeadbeef;
699 TEST(NtUserSystemParametersInfo(SPI_GETICONTITLELOGFONT, 0, &buf.lf, 0) == 1);
700 TEST(buf.lf.lfHeight != 0);
701 TEST(buf.lf.lfWeight != 0);
702 TEST(buf.lf.lfFaceName[0] != 0);
703 TEST(buf.lf.lfFaceName[LF_FACESIZE-1] == 0);
704 TEST(buf.dwRedzone == 0xdeadbeef);
705
706 /* Test uiParam < sizeof(LOGFONTW) */
707 memset(&buf, 0, sizeof(buf));
708 buf.lf.lfFaceName[LF_FACESIZE-1] = 33;
709 buf.dwRedzone = 0xdeadbeef;
710 TEST(NtUserSystemParametersInfo(SPI_GETICONTITLELOGFONT, 8, &buf.lf, 0) == 1);
711 TEST(buf.lf.lfHeight != 0);
712 TEST(buf.lf.lfWeight != 0);
713 TEST(buf.lf.lfFaceName[0] != 0);
714 TEST(buf.lf.lfFaceName[LF_FACESIZE-1] == 0);
715 TEST(buf.dwRedzone == 0xdeadbeef);
716
717 /* Test uiParam < 0 */
718 TEST(NtUserSystemParametersInfo(SPI_GETICONTITLELOGFONT, -1, &buf.lf, 0) == 1);
719
720
721 }
722
723 void
724 Test_SPI_SETFASTTASKSWITCH(void)
725 {
726 char buf[10];
727 TEST(NtUserSystemParametersInfo(SPI_SETFASTTASKSWITCH, 0, 0, 0) == 1);
728 TEST(NtUserSystemParametersInfo(SPI_SETFASTTASKSWITCH, 0, buf, 0) == 1);
729
730
731 }
732
733 void
734 Test_SPI_SETDRAGFULLWINDOWS(void)
735 {
736
737 }
738
739 void
740 Test_SPI_SETNONCLIENTMETRICS(void)
741 {
742 NONCLIENTMETRICSW metrics;
743
744 metrics.cbSize = sizeof(NONCLIENTMETRICSW);
745 TEST(NtUserSystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICSW), &metrics, 0) == 1);
746 TEST(NtUserSystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICSW) + 1, &metrics, 0) == 0);
747 TEST(NtUserSystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICSW), (PVOID)0xdeadbeef, 0) == 0);
748 }
749
750 void
751 Test_SPI_SETMINIMIZEDMETRICS(void)
752 {
753 MINIMIZEDMETRICS metrics;
754
755 metrics.cbSize = sizeof(MINIMIZEDMETRICS);
756 TEST(NtUserSystemParametersInfo(SPI_GETMINIMIZEDMETRICS, sizeof(MINIMIZEDMETRICS), (PVOID)&metrics, 0) == 1);
757 TEST(NtUserSystemParametersInfo(SPI_GETMINIMIZEDMETRICS, sizeof(MINIMIZEDMETRICS) + 1, (PVOID)&metrics, 0) == 0);
758 TEST(NtUserSystemParametersInfo(SPI_GETMINIMIZEDMETRICS, sizeof(MINIMIZEDMETRICS), (PVOID)0xdeadbeef, 0) == 0);
759 }
760
761 void
762 Test_SPI_SETICONMETRICS(void)
763 {
764 ICONMETRICSW metrics;
765
766 metrics.cbSize = sizeof(ICONMETRICSW);
767 TEST(NtUserSystemParametersInfo(SPI_GETICONMETRICS, sizeof(ICONMETRICSW), (PVOID)&metrics, 0) == 1);
768 TEST(NtUserSystemParametersInfo(SPI_GETICONMETRICS, sizeof(ICONMETRICSW) + 1, (PVOID)&metrics, 0) == 0);
769 TEST(NtUserSystemParametersInfo(SPI_GETICONMETRICS, sizeof(ICONMETRICSW), (PVOID)0xdeadbeef, 0) == 0);
770 }
771
772 void
773 Test_SPI_SETWORKAREA(void)
774 {
775 RECT rcOrig, rc;
776
777 /* Get the original value */
778 ASSERT(NtUserSystemParametersInfo(SPI_GETWORKAREA, 0, &rcOrig, 0) == 1);
779
780 /* Change value */
781 rc = rcOrig;
782 rc.left += 1;
783 rc.top += 2;
784 rc.right -= 3;
785 rc.bottom -= 2;
786 TEST(NtUserSystemParametersInfo(SPI_SETWORKAREA, 1, &rc, 0) == 1);
787 TEST(NtUserSystemParametersInfo(SPI_SETWORKAREA, 0, &rc, 0) == 1);
788 TEST(NtUserSystemParametersInfo(SPI_SETWORKAREA, sizeof(RECT), &rc, 0) == 1);
789
790 TEST(NtUserSystemParametersInfo(SPI_GETWORKAREA, 1, &rc, 0) == 1);
791 TEST(NtUserSystemParametersInfo(SPI_GETWORKAREA, -1, &rc, 0) == 1);
792 TEST(NtUserSystemParametersInfo(SPI_GETWORKAREA, 0xdeadbeef, &rc, 0) == 1);
793 TEST(NtUserSystemParametersInfo(SPI_GETWORKAREA, 0, (PVOID)0xdeadbeef, 0) == 0);
794
795 /* Test values */
796 rc = rcOrig; rc.left = -1;
797 TEST(NtUserSystemParametersInfo(SPI_SETWORKAREA, 0, &rc, 0) == 0);
798 rc = rcOrig; rc.top = -1;
799 TEST(NtUserSystemParametersInfo(SPI_SETWORKAREA, 0, &rc, 0) == 0);
800 rc = rcOrig; rc.top = 10; rc.bottom = 11;
801 TEST(NtUserSystemParametersInfo(SPI_SETWORKAREA, 0, &rc, 0) == 1);
802 rc = rcOrig; rc.top = 10; rc.bottom = 10;
803 TEST(NtUserSystemParametersInfo(SPI_SETWORKAREA, 0, &rc, 0) == 0);
804 rc = rcOrig; rc.top = 10; rc.bottom = 9;
805 TEST(NtUserSystemParametersInfo(SPI_SETWORKAREA, 0, &rc, 0) == 0);
806 rc = rcOrig; rc.left = 10; rc.right = 11;
807 TEST(NtUserSystemParametersInfo(SPI_SETWORKAREA, 0, &rc, 0) == 1);
808 rc = rcOrig; rc.left = 10; rc.right = 10;
809 TEST(NtUserSystemParametersInfo(SPI_SETWORKAREA, 0, &rc, 0) == 0);
810 rc = rcOrig; rc.left = 10; rc.right = 9;
811 TEST(NtUserSystemParametersInfo(SPI_SETWORKAREA, 0, &rc, 0) == 0);
812 rc = rcOrig; rc.bottom = GetSystemMetrics(SM_CYVIRTUALSCREEN);
813 TEST(NtUserSystemParametersInfo(SPI_SETWORKAREA, 0, &rc, 0) == 1);
814 rc = rcOrig; rc.bottom = GetSystemMetrics(SM_CYVIRTUALSCREEN)+1;
815 TEST(NtUserSystemParametersInfo(SPI_SETWORKAREA, 0, &rc, 0) == 0);
816 rc = rcOrig; rc.right = GetSystemMetrics(SM_CXVIRTUALSCREEN);
817 TEST(NtUserSystemParametersInfo(SPI_SETWORKAREA, 0, &rc, 0) == 1);
818 rc = rcOrig; rc.right = GetSystemMetrics(SM_CXVIRTUALSCREEN)+1;
819 TEST(NtUserSystemParametersInfo(SPI_SETWORKAREA, 0, &rc, 0) == 0);
820
821 /* Restore original value */
822 ASSERT(NtUserSystemParametersInfo(SPI_SETWORKAREA, 0, &rcOrig, 0) == 1);
823
824
825 }
826
827 void
828 Test_SPI_SETPENWINDOWS(void)
829 {
830
831 }
832
833 void
834 Test_SPI_SETFILTERKEYS(void)
835 {
836
837 }
838
839 void
840 Test_SPI_SETTOGGLEKEYS(void)
841 {
842
843 }
844
845 void
846 Test_SPI_SETMOUSEKEYS(void)
847 {
848
849 }
850
851 void
852 Test_SPI_SETSHOWSOUNDS(void)
853 {
854
855 }
856
857 void
858 Test_SPI_SETSTICKYKEYS(void)
859 {
860 STICKYKEYS skOrig, sk;
861
862 /* Get original values */
863 skOrig.cbSize = sizeof(STICKYKEYS);
864 ASSERT(NtUserSystemParametersInfo(SPI_GETSTICKYKEYS, 0, &skOrig, 0) == 1);
865
866 sk.cbSize = sizeof(STICKYKEYS)+1;
867 TEST(NtUserSystemParametersInfo(SPI_GETSTICKYKEYS, 0, &sk, 0) == 0);
868
869 sk.cbSize = sizeof(STICKYKEYS)-1;
870 TEST(NtUserSystemParametersInfo(SPI_GETSTICKYKEYS, 0, &sk, 0) == 0);
871
872 sk.cbSize = sizeof(STICKYKEYS);
873 TEST(NtUserSystemParametersInfo(SPI_GETSTICKYKEYS, 1, &sk, 0) == 0);
874 TEST(NtUserSystemParametersInfo(SPI_GETSTICKYKEYS, -1, &sk, 0) == 0);
875 TEST(NtUserSystemParametersInfo(SPI_GETSTICKYKEYS, sk.cbSize, &sk, 0) == 1);
876 TEST(NtUserSystemParametersInfo(SPI_GETSTICKYKEYS, sk.cbSize-1, &sk, 0) == 0);
877 TEST(NtUserSystemParametersInfo(SPI_GETSTICKYKEYS, sk.cbSize+1, &sk, 0) == 0);
878
879 sk = skOrig;
880 sk.dwFlags = (skOrig.dwFlags ^ 1);
881 TEST(NtUserSystemParametersInfo(SPI_SETSTICKYKEYS, sk.cbSize+1, &sk, 0) == 0);
882 TEST(NtUserSystemParametersInfo(SPI_SETSTICKYKEYS, sk.cbSize-1, &sk, 0) == 0);
883 TEST(NtUserSystemParametersInfo(SPI_SETSTICKYKEYS, sk.cbSize, &sk, 0) == 1);
884
885 sk = skOrig;
886 TEST(NtUserSystemParametersInfo(SPI_GETSTICKYKEYS, 0, &sk, 0) == 1);
887 TEST(sk.dwFlags == (skOrig.dwFlags ^ 1));
888
889 /* Restore original values */
890 skOrig.cbSize = sizeof(STICKYKEYS);
891 ASSERT(NtUserSystemParametersInfo(SPI_SETSTICKYKEYS, 0, &skOrig, 0) == 1);
892
893 }
894
895 void
896 Test_SPI_SETACCESSTIMEOUT(void)
897 {
898 ACCESSTIMEOUT atoOrig, atoTmp;
899
900 /* Get original values */
901 atoOrig.cbSize = sizeof(ACCESSTIMEOUT);
902 ASSERT(NtUserSystemParametersInfo(SPI_GETACCESSTIMEOUT, 0, &atoOrig, 0) == 1);
903
904 atoTmp.cbSize = sizeof(ACCESSTIMEOUT) - 1;
905 TEST(NtUserSystemParametersInfo(SPI_GETACCESSTIMEOUT, 0, &atoTmp, 0) == 0);
906 atoTmp.cbSize = sizeof(ACCESSTIMEOUT) + 1;
907 TEST(NtUserSystemParametersInfo(SPI_GETACCESSTIMEOUT, 0, &atoTmp, 0) == 0);
908 atoTmp.cbSize = sizeof(ACCESSTIMEOUT);
909 TEST(NtUserSystemParametersInfo(SPI_GETACCESSTIMEOUT, 0, &atoTmp, 0) == 1);
910 atoTmp.cbSize = sizeof(ACCESSTIMEOUT);
911 TEST(NtUserSystemParametersInfo(SPI_GETACCESSTIMEOUT, 1, &atoTmp, 0) == 0);
912 atoTmp.cbSize = sizeof(ACCESSTIMEOUT);
913 TEST(NtUserSystemParametersInfo(SPI_GETACCESSTIMEOUT, -1, &atoTmp, 0) == 0);
914 atoTmp.cbSize = sizeof(ACCESSTIMEOUT);
915 TEST(NtUserSystemParametersInfo(SPI_GETACCESSTIMEOUT, sizeof(ACCESSTIMEOUT), &atoTmp, 0) == 1);
916 atoTmp.cbSize = sizeof(ACCESSTIMEOUT);
917 TEST(NtUserSystemParametersInfo(SPI_GETACCESSTIMEOUT, sizeof(ACCESSTIMEOUT)-1, &atoTmp, 0) == 0);
918 atoTmp.cbSize = sizeof(ACCESSTIMEOUT);
919 TEST(NtUserSystemParametersInfo(SPI_GETACCESSTIMEOUT, sizeof(ACCESSTIMEOUT)+1, &atoTmp, 0) == 0);
920
921 /* Restore original values */
922 ASSERT(NtUserSystemParametersInfo(SPI_SETACCESSTIMEOUT, sizeof(atoOrig), &atoOrig, 0) == 1);
923 }
924
925 void
926 Test_SPI_SETSERIALKEYS(void)
927 {
928
929 }
930
931 void
932 Test_SPI_SETSOUNDSENTRY(void)
933 {
934
935 }
936
937 void
938 Test_SPI_SETHIGHCONTRAST(void)
939 {
940
941 }
942
943 void
944 Test_SPI_SETKEYBOARDPREF(void)
945 {
946
947 }
948
949 // Test_SPI_SETSCREENREADER();
950 /// Test_SPI_SETANIMATION();
951 // Test_SPI_SETFONTSMOOTHING();
952 // Test_SPI_SETDRAGWIDTH();
953 // Test_SPI_SETDRAGHEIGHT();
954 // Test_SPI_SETHANDHELD();
955 // Test_SPI_SETLOWPOWERTIMEOUT();
956 // Test_SPI_SETPOWEROFFTIMEOUT();
957 // Test_SPI_SETLOWPOWERACTIVE();
958 // Test_SPI_SETPOWEROFFACTIVE();
959 // Test_SPI_SETCURSORS();
960 // Test_SPI_SETICONS();
961 // Test_SPI_SETDEFAULTINPUTLANG();
962 // Test_SPI_SETLANGTOGGLE();
963 // Test_SPI_GETWINDOWSEXTENSION();
964 // Test_SPI_SETMOUSETRAILS();
965 // Test_SPI_SETSNAPTODEFBUTTON();
966 // Test_SPI_GETSCREENSAVERRUNNING();
967 // Test_SPI_SETMOUSEHOVERWIDTH();
968 // Test_SPI_SETMOUSEHOVERHEIGHT();
969 // Test_SPI_SETMOUSEHOVERTIME();
970 // Test_SPI_SETWHEELSCROLLLINES();
971 // Test_SPI_SETMENUSHOWDELAY();
972 // Test_SPI_SETWHEELSCROLLCHARS();
973 // Test_SPI_SETSHOWIMEUI();
974 // Test_SPI_SETMOUSESPEED();
975 // Test_SPI_GETSCREENSAVERRUNNING();
976 // Test_SPI_SETAUDIODESCRIPTION();
977 // Test_SPI_SETSCREENSAVESECURE();
978 // Test_SPI_SETACTIVEWINDOWTRACKING();
979
980 void
981 Test_SPI_SETMENUANIMATION(void)
982 {
983 BOOL bOrig, bTemp = 0;
984 DWORD dwUserPrefMask;
985 DWORD cbSize;
986
987 /* Get original values */
988 NtUserSystemParametersInfo(SPI_GETMENUANIMATION, 0, &bOrig, 0);
989
990 /* Value 0 */
991 NtUserSystemParametersInfo(SPI_SETMENUANIMATION, 0, NULL, SPIF_UPDATEINIFILE);
992 NtUserSystemParametersInfo(SPI_GETMENUANIMATION, 0, &bTemp, 0);
993 TEST(bTemp == 0);
994 cbSize = sizeof(dwUserPrefMask);
995 TEST(QueryUserRegValueW(KEY_DESKTOP, VAL_PREFMASK, &dwUserPrefMask, &cbSize, NULL) == ERROR_SUCCESS);
996 TEST((dwUserPrefMask & UPM_MENUANIMATION) == 0);
997
998 /* Value 1 */
999 NtUserSystemParametersInfo(SPI_SETMENUANIMATION, 0, (PVOID)1, SPIF_UPDATEINIFILE);
1000 NtUserSystemParametersInfo(SPI_GETMENUANIMATION, 0, &bTemp, 0);
1001 TEST(bTemp == 1);
1002 cbSize = sizeof(dwUserPrefMask);
1003 TEST(QueryUserRegValueW(KEY_DESKTOP, VAL_PREFMASK, &dwUserPrefMask, &cbSize, NULL) == ERROR_SUCCESS);
1004 TEST((dwUserPrefMask & UPM_MENUANIMATION) != 0);
1005
1006
1007 /* Restore original values */
1008 NtUserSystemParametersInfo(SPI_SETMENUANIMATION, 0, (PVOID)bOrig, SPIF_UPDATEINIFILE);
1009 }
1010
1011 // Test_SPI_SETCOMBOBOXANIMATION();
1012 // Test_SPI_SETLISTBOXSMOOTHSCROLLING();
1013 // Test_SPI_SETGRADIENTCAPTIONS();
1014
1015 void
1016 Test_SPI_SETKEYBOARDCUES(void)
1017 {
1018 Test_UserPref(SPI_GETKEYBOARDCUES, SPI_SETKEYBOARDCUES, UPM_KEYBOARDCUES);
1019 }
1020
1021 // Test_SPI_SETACTIVEWNDTRKZORDER();
1022 // Test_SPI_SETHOTTRACKING();
1023 // Test_SPI_SETMENUFADE();
1024 // Test_SPI_SETSELECTIONFADE();
1025 // Test_SPI_SETTOOLTIPANIMATION();
1026 // Test_SPI_SETTOOLTIPFADE();
1027 // Test_SPI_SETCURSORSHADOW();
1028 // Test_SPI_SETMOUSESONAR();
1029
1030 void
1031 Test_SPI_SETMOUSECLICKLOCK(void)
1032 {
1033 Test_UserPref(SPI_GETMOUSECLICKLOCK, SPI_SETMOUSECLICKLOCK, UPM_CLICKLOCK);
1034 }
1035
1036 // Test_SPI_SETMOUSEVANISH();
1037 // Test_SPI_SETFLATMENU();
1038 // Test_SPI_SETDROPSHADOW();
1039 // Test_SPI_SETBLOCKSENDINPUTRESETS();
1040 // Test_SPI_GETSETUIEFFECTS();
1041 // Test_SPI_SETDISABLEOVERLAPPEDCONTENT();
1042 // Test_SPI_SETCLIENTAREAANIMATION();
1043 // Test_SPI_SETCLEARTYPE();
1044 // Test_SPI_SETSPEECHRECOGNITION();
1045 // Test_SPI_SETFOREGROUNDLOCKTIMEOUT();
1046 // Test_SPI_SETACTIVEWNDTRKTIMEOUT();
1047 // Test_SPI_SETFOREGROUNDFLASHCOUNT();
1048 // Test_SPI_SETCARETWIDTH();
1049 // Test_SPI_SETMOUSECLICKLOCKTIME();
1050 // Test_SPI_SETFONTSMOOTHINGTYPE();
1051 // Test_SPI_SETFONTSMOOTHINGCONTRAST();
1052 // Test_SPI_SETFOCUSBORDERWIDTH();
1053 // Test_SPI_SETFOCUSBORDERHEIGHT();
1054 // Test_SPI_SETFONTSMOOTHINGORIENTATION();
1055
1056
1057 START_TEST(NtUserSystemParametersInfo)
1058 {
1059 HWND hWnd;
1060
1061 hWnd = CreateTestWindow();
1062 ASSERT(hWnd);
1063
1064 Test_NtUserSystemParametersInfo_Params();
1065 Test_NtUserSystemParametersInfo_fWinIni();
1066 Test_NtUserSystemParametersInfo_Winsta();
1067
1068 Test_SPI_SETBEEP();
1069 Test_SPI_SETMOUSE();
1070 Test_SPI_SETBORDER();
1071 // Test_SPI_SETKEYBOARDSPEED();
1072 // Test_SPI_LANGDRIVER();
1073 // Test_SPI_ICONHORIZONTALSPACING();
1074 // Test_SPI_SETSCREENSAVETIMEOUT();
1075 // Test_SPI_SETSCREENSAVEACTIVE();
1076 // Test_SPI_SETGRIDGRANULARITY();
1077 Test_SPI_SETDESKWALLPAPER();
1078 // Test_SPI_SETDESKPATTERN();
1079 // Test_SPI_SETKEYBOARDDELAY();
1080 // Test_SPI_ICONVERTICALSPACING();
1081 // Test_SPI_SETICONTITLEWRAP();
1082 // Test_SPI_SETMENUDROPALIGNMENT();
1083 // Test_SPI_SETDOUBLECLKWIDTH();
1084 // Test_SPI_SETDOUBLECLKHEIGHT();
1085 // Test_SPI_SETDOUBLECLICKTIME();
1086 Test_SPI_SETMOUSEBUTTONSWAP();
1087 Test_SPI_SETICONTITLELOGFONT();
1088 Test_SPI_SETFASTTASKSWITCH();
1089 Test_SPI_SETDRAGFULLWINDOWS();
1090 Test_SPI_SETNONCLIENTMETRICS();
1091 Test_SPI_SETMINIMIZEDMETRICS();
1092 Test_SPI_SETICONMETRICS();
1093 Test_SPI_SETWORKAREA();
1094 Test_SPI_SETPENWINDOWS();
1095 Test_SPI_SETFILTERKEYS();
1096 Test_SPI_SETTOGGLEKEYS();
1097 Test_SPI_SETMOUSEKEYS();
1098 Test_SPI_SETSHOWSOUNDS();
1099 Test_SPI_SETSTICKYKEYS();
1100 Test_SPI_SETACCESSTIMEOUT();
1101 Test_SPI_SETSERIALKEYS();
1102 Test_SPI_SETSOUNDSENTRY();
1103 Test_SPI_SETHIGHCONTRAST();
1104 Test_SPI_SETKEYBOARDPREF();
1105 // Test_SPI_SETSCREENREADER();
1106 /// Test_SPI_SETANIMATION();
1107 // Test_SPI_SETFONTSMOOTHING();
1108 // Test_SPI_SETDRAGWIDTH();
1109 // Test_SPI_SETDRAGHEIGHT();
1110 // Test_SPI_SETHANDHELD();
1111 // Test_SPI_SETLOWPOWERTIMEOUT();
1112 // Test_SPI_SETPOWEROFFTIMEOUT();
1113 // Test_SPI_SETLOWPOWERACTIVE();
1114 // Test_SPI_SETPOWEROFFACTIVE();
1115 // Test_SPI_SETCURSORS();
1116 // Test_SPI_SETICONS();
1117 // Test_SPI_SETDEFAULTINPUTLANG();
1118 // Test_SPI_SETLANGTOGGLE();
1119 // Test_SPI_GETWINDOWSEXTENSION();
1120 // Test_SPI_SETMOUSETRAILS();
1121 // Test_SPI_SETSNAPTODEFBUTTON();
1122 // Test_SPI_GETSCREENSAVERRUNNING();
1123 // Test_SPI_SETMOUSEHOVERWIDTH();
1124 // Test_SPI_SETMOUSEHOVERHEIGHT();
1125 // Test_SPI_SETMOUSEHOVERTIME();
1126 // Test_SPI_SETWHEELSCROLLLINES();
1127 // Test_SPI_SETMENUSHOWDELAY();
1128 // Test_SPI_SETWHEELSCROLLCHARS();
1129 // Test_SPI_SETSHOWIMEUI();
1130 // Test_SPI_SETMOUSESPEED();
1131 // Test_SPI_GETSCREENSAVERRUNNING();
1132 // Test_SPI_SETAUDIODESCRIPTION();
1133 // Test_SPI_SETSCREENSAVESECURE();
1134 // Test_SPI_SETACTIVEWINDOWTRACKING();
1135 Test_SPI_SETMENUANIMATION();
1136 // Test_SPI_SETCOMBOBOXANIMATION();
1137 // Test_SPI_SETLISTBOXSMOOTHSCROLLING();
1138 // Test_SPI_SETGRADIENTCAPTIONS();
1139 Test_SPI_SETKEYBOARDCUES();
1140 // Test_SPI_SETACTIVEWNDTRKZORDER();
1141 // Test_SPI_SETHOTTRACKING();
1142 // Test_SPI_SETMENUFADE();
1143 // Test_SPI_SETSELECTIONFADE();
1144 // Test_SPI_SETTOOLTIPANIMATION();
1145 // Test_SPI_SETTOOLTIPFADE();
1146 // Test_SPI_SETCURSORSHADOW();
1147 // Test_SPI_SETMOUSESONAR();
1148 Test_SPI_SETMOUSECLICKLOCK();
1149 // Test_SPI_SETMOUSEVANISH();
1150 // Test_SPI_SETFLATMENU();
1151 // Test_SPI_SETDROPSHADOW();
1152 // Test_SPI_SETBLOCKSENDINPUTRESETS();
1153 // Test_SPI_GETSETUIEFFECTS();
1154 // Test_SPI_SETDISABLEOVERLAPPEDCONTENT();
1155 // Test_SPI_SETCLIENTAREAANIMATION();
1156 // Test_SPI_SETCLEARTYPE();
1157 // Test_SPI_SETSPEECHRECOGNITION();
1158 // Test_SPI_SETFOREGROUNDLOCKTIMEOUT();
1159 // Test_SPI_SETACTIVEWNDTRKTIMEOUT();
1160 // Test_SPI_SETFOREGROUNDFLASHCOUNT();
1161 // Test_SPI_SETCARETWIDTH();
1162 // Test_SPI_SETMOUSECLICKLOCKTIME();
1163 // Test_SPI_SETFONTSMOOTHINGTYPE();
1164 // Test_SPI_SETFONTSMOOTHINGCONTRAST();
1165 // Test_SPI_SETFOCUSBORDERWIDTH();
1166 // Test_SPI_SETFOCUSBORDERHEIGHT();
1167 // Test_SPI_SETFONTSMOOTHINGORIENTATION();
1168
1169 DestroyWindow(hWnd);
1170 }