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