Release 20030408.
[wine/gsoc-2012-control.git] / dlls / user / tests / sysparams.c
blob4f773e0189ab1a4d4b5cdbee9a2008bf7bb07094
1 /* Unit test suite for functions SystemParametersInfo and GetSystemMetrics.
3 * Copyright 2002 Andriy Palamarchuk
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #include <assert.h>
21 #include <stdlib.h>
22 #include <stdio.h>
24 #include "wine/test.h"
25 #include "winbase.h"
26 #include "winreg.h"
27 #include "winuser.h"
29 #ifndef IDI_APPLICATIONA
30 # define IDI_APPLICATIONA IDI_APPLICATION
31 #endif
32 #ifndef IDC_ARROWA
33 # define IDC_ARROWA IDC_ARROW
34 #endif
36 #ifndef SPI_GETDESKWALLPAPER
37 # define SPI_GETDESKWALLPAPER 0x0073
38 #endif
40 static int strict;
42 #define eq(received, expected, label, type) \
43 ok((received) == (expected), "%s: got " type " instead of " type, (label),(received),(expected))
46 #define SPI_SETBEEP_REGKEY "Control Panel\\Sound"
47 #define SPI_SETBEEP_VALNAME "Beep"
48 #define SPI_SETMOUSE_REGKEY "Control Panel\\Mouse"
49 #define SPI_SETMOUSE_VALNAME1 "MouseThreshold1"
50 #define SPI_SETMOUSE_VALNAME2 "MouseThreshold2"
51 #define SPI_SETMOUSE_VALNAME3 "MouseSpeed"
52 #define SPI_SETBORDER_REGKEY "Control Panel\\Desktop\\WindowMetrics"
53 #define SPI_SETBORDER_VALNAME "BorderWidth"
54 #define SPI_SETKEYBOARDSPEED_REGKEY "Control Panel\\Keyboard"
55 #define SPI_SETKEYBOARDSPEED_VALNAME "KeyboardSpeed"
56 #define SPI_SETSCREENSAVETIMEOUT_REGKEY "Control Panel\\Desktop"
57 #define SPI_SETSCREENSAVETIMEOUT_VALNAME "ScreenSaveTimeOut"
58 #define SPI_SETSCREENSAVEACTIVE_REGKEY "Control Panel\\Desktop"
59 #define SPI_SETSCREENSAVEACTIVE_VALNAME "ScreenSaveActive"
60 #define SPI_SETGRIDGRANULARITY_REGKEY "Control Panel\\Desktop"
61 #define SPI_SETGRIDGRANULARITY_VALNAME "GridGranularity"
62 #define SPI_SETKEYBOARDDELAY_REGKEY "Control Panel\\Keyboard"
63 #define SPI_SETKEYBOARDDELAY_VALNAME "KeyboardDelay"
64 #define SPI_SETICONTITLEWRAP_REGKEY1 "Control Panel\\Desktop\\WindowMetrics"
65 #define SPI_SETICONTITLEWRAP_REGKEY2 "Control Panel\\Desktop"
66 #define SPI_SETICONTITLEWRAP_VALNAME "IconTitleWrap"
67 #define SPI_SETMENUDROPALIGNMENT_REGKEY1 "Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows"
68 #define SPI_SETMENUDROPALIGNMENT_REGKEY2 "Control Panel\\Desktop"
69 #define SPI_SETMENUDROPALIGNMENT_VALNAME "MenuDropAlignment"
70 #define SPI_SETDOUBLECLKWIDTH_REGKEY1 "Control Panel\\Mouse"
71 #define SPI_SETDOUBLECLKWIDTH_REGKEY2 "Control Panel\\Desktop"
72 #define SPI_SETDOUBLECLKWIDTH_VALNAME "DoubleClickWidth"
73 #define SPI_SETDOUBLECLKHEIGHT_REGKEY1 "Control Panel\\Mouse"
74 #define SPI_SETDOUBLECLKHEIGHT_REGKEY2 "Control Panel\\Desktop"
75 #define SPI_SETDOUBLECLKHEIGHT_VALNAME "DoubleClickHeight"
76 #define SPI_SETDOUBLECLICKTIME_REGKEY "Control Panel\\Mouse"
77 #define SPI_SETDOUBLECLICKTIME_VALNAME "DoubleClickSpeed"
78 #define SPI_SETMOUSEBUTTONSWAP_REGKEY "Control Panel\\Mouse"
79 #define SPI_SETMOUSEBUTTONSWAP_VALNAME "SwapMouseButtons"
80 #define SPI_SETWORKAREA_REGKEY "Control Panel\\Desktop"
81 #define SPI_SETWORKAREA_VALNAME "WINE_WorkArea"
82 #define SPI_SETSHOWSOUNDS_REGKEY "Control Panel\\Accessibility\\ShowSounds"
83 #define SPI_SETSHOWSOUNDS_VALNAME "On"
84 #define SPI_SETDRAGFULLWINDOWS_REGKEY "Control Panel\\Desktop"
85 #define SPI_SETDRAGFULLWINDOWS_VALNAME "DragFullWindows"
86 #define SPI_SETDESKWALLPAPER_REGKEY "Control Panel\\Desktop"
87 #define SPI_SETDESKWALLPAPER_VALNAME "Wallpaper"
88 /* FIXME - don't have access to Windows with this action (W95, NT5.0). Set real values */
89 #define SPI_SETKEYBOARDPREF_REGKEY "Control Panel\\Desktop"
90 #define SPI_SETKEYBOARDPREF_VALNAME "WINE_WorkArea"
91 #define SPI_SETSCREENREADER_REGKEY "Control Panel\\Desktop"
92 #define SPI_SETSCREENREADER_VALNAME "???"
94 /* volatile registry branch under CURRENT_USER_REGKEY for temporary values storage */
95 #define WINE_CURRENT_USER_REGKEY "Wine"
97 static HWND ghTestWnd;
99 static DWORD WINAPI SysParamsThreadFunc( LPVOID lpParam );
100 static LRESULT CALLBACK SysParamsTestWndProc( HWND hWnd, UINT msg, WPARAM wParam,
101 LPARAM lParam );
102 static int change_counter;
103 static int change_last_param;
105 static LRESULT CALLBACK SysParamsTestWndProc( HWND hWnd, UINT msg, WPARAM wParam,
106 LPARAM lParam )
108 switch (msg) {
110 case WM_SETTINGCHANGE:
111 if (change_counter>0) {
112 ok(0,"too many changes counter=%d last change=%d\n",
113 change_counter,change_last_param);
115 change_counter++;
116 change_last_param = wParam;
117 break;
119 case WM_DESTROY:
120 PostQuitMessage( 0 );
121 break;
123 default:
124 return( DefWindowProcA( hWnd, msg, wParam, lParam ) );
127 return 0;
131 Performs testing for system parameters messages
132 params:
133 - system parameter id
134 - supposed value of the registry key
136 static void test_change_message( int action, int optional )
138 if (change_counter==0 && optional==1)
139 return;
140 ok( 1 == change_counter,
141 "Missed a message: change_counter=%d", change_counter );
142 change_counter = 0;
143 ok( action == change_last_param,
144 "Wrong action got %d expected %d", change_last_param, action );
145 change_last_param = 0;
149 * Tests the HKEY_CURRENT_USER subkey value.
150 * The value should contain string value.
152 * Params:
153 * lpsSubKey - subkey name
154 * lpsRegName - registry entry name
155 * lpsTestValue - value to test
157 static void _test_reg_key( LPSTR subKey1, LPSTR subKey2, LPSTR valName, LPSTR testValue )
159 CHAR value[MAX_PATH];
160 DWORD valueLen;
161 DWORD type;
162 HKEY hKey;
163 LONG rc;
164 int found=0;
166 *value='\0';
167 valueLen=sizeof(value);
168 RegOpenKeyA( HKEY_CURRENT_USER, subKey1, &hKey );
169 rc=RegQueryValueExA( hKey, valName, NULL, &type, value, &valueLen );
170 RegCloseKey( hKey );
171 if (rc==ERROR_SUCCESS)
173 ok( !strcmp( testValue, value ),
174 "Wrong value in registry: subKey=%s, valName=%s, testValue=%s, value=%s",
175 subKey1, valName, testValue, value );
176 found++;
178 else if (strict)
180 ok(0,"Missing registry entry: subKey=%s, valName=%s",
181 subKey1, valName);
183 if (subKey2 && !strict)
185 *value='\0';
186 valueLen=sizeof(value);
187 RegOpenKeyA( HKEY_CURRENT_USER, subKey2, &hKey );
188 rc=RegQueryValueExA( hKey, valName, NULL, &type, value, &valueLen );
189 RegCloseKey( hKey );
190 if (rc==ERROR_SUCCESS)
192 ok( !strcmp( testValue, value ),
193 "Wrong value in registry: subKey=%s, valName=%s, testValue=%s, value=%s",
194 subKey2, valName, testValue, value );
195 found++;
198 ok(found,"Missing registry entry: %s in %s or %s",
199 valName, subKey1, (subKey2?subKey2:"<n/a>") );
202 #define test_reg_key( subKey, valName, testValue ) \
203 _test_reg_key( subKey, NULL, valName, testValue )
204 #define test_reg_key_ex( subKey1, subKey2, valName, testValue ) \
205 _test_reg_key( subKey1, subKey2, valName, testValue )
207 static void test_SPI_SETBEEP( void ) /* 2 */
209 BOOL rc;
210 BOOL old_b;
211 BOOL b;
212 BOOL curr_val;
214 trace("testing SPI_{GET,SET}BEEP\n");
215 rc=SystemParametersInfoA( SPI_GETBEEP, 0, &old_b, 0 );
216 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
218 curr_val = TRUE;
219 rc=SystemParametersInfoA( SPI_SETBEEP, curr_val, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
220 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
221 test_change_message( SPI_SETBEEP, 0 );
222 test_reg_key( SPI_SETBEEP_REGKEY,
223 SPI_SETBEEP_VALNAME,
224 curr_val ? "Yes" : "No" );
225 rc=SystemParametersInfoA( SPI_GETBEEP, 0, &b, 0 );
226 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
227 eq( b, curr_val, "SPI_{GET,SET}BEEP", "%d" );
228 rc=SystemParametersInfoW( SPI_GETBEEP, 0, &b, 0 );
229 if (rc!=0 || GetLastError()!=ERROR_CALL_NOT_IMPLEMENTED)
231 ok(rc!=0,"SystemParametersInfoW: rc=%d err=%ld\n",rc,GetLastError());
232 eq( b, curr_val, "SystemParametersInfoW", "%d" );
235 /* is a message sent for the second change? */
236 rc=SystemParametersInfoA( SPI_SETBEEP, curr_val, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
237 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
238 test_change_message( SPI_SETBEEP, 0 );
240 curr_val = FALSE;
241 rc=SystemParametersInfoW( SPI_SETBEEP, curr_val, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
242 if (rc==0 && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
243 rc=SystemParametersInfoA( SPI_SETBEEP, curr_val, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
244 ok(rc!=0,"SystemParametersInfo: rc=%d err=%ld\n",rc,GetLastError());
245 test_change_message( SPI_SETBEEP, 0 );
246 test_reg_key( SPI_SETBEEP_REGKEY,
247 SPI_SETBEEP_VALNAME,
248 curr_val ? "Yes" : "No" );
249 rc=SystemParametersInfoA( SPI_GETBEEP, 0, &b, 0 );
250 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
251 eq( b, curr_val, "SPI_{GET,SET}BEEP", "%d" );
252 rc=SystemParametersInfoW( SPI_GETBEEP, 0, &b, 0 );
253 if (rc!=0 || GetLastError()!=ERROR_CALL_NOT_IMPLEMENTED)
255 ok(rc!=0,"SystemParametersInfoW: rc=%d err=%ld\n",rc,GetLastError());
256 eq( b, curr_val, "SystemParametersInfoW", "%d" );
258 ok( MessageBeep( MB_OK ), "Return value of MessageBeep when sound is disabled" );
260 rc=SystemParametersInfoA( SPI_SETBEEP, old_b, 0, SPIF_UPDATEINIFILE );
261 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
264 static char *setmouse_valuenames[3] = {
265 SPI_SETMOUSE_VALNAME1,
266 SPI_SETMOUSE_VALNAME2,
267 SPI_SETMOUSE_VALNAME3
271 * Runs check for one setting of spi_setmouse.
273 static void run_spi_setmouse_test( int curr_val[], POINT *req_change, POINT *proj_change,
274 int nchange )
276 BOOL rc;
277 INT mi[3];
278 static int aw_turn = 0;
280 char buf[20];
281 int i;
283 aw_turn++;
284 rc=0;
285 if (aw_turn % 2!=0) /* call unicode version each second call */
286 rc=SystemParametersInfoW( SPI_SETMOUSE, 0, curr_val, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
287 if (aw_turn % 2==0 || (rc==0 && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED))
288 rc=SystemParametersInfoA( SPI_SETMOUSE, 0, curr_val, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
289 ok(rc!=0,"SystemParametersInfo: rc=%d err=%ld\n",rc,GetLastError());
290 test_change_message( SPI_SETMOUSE, 0 );
291 for (i = 0; i < 3; i++)
293 sprintf( buf, "%d", curr_val[i] );
294 test_reg_key( SPI_SETMOUSE_REGKEY, setmouse_valuenames[i], buf );
297 rc=SystemParametersInfoA( SPI_GETMOUSE, 0, mi, 0 );
298 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
299 for (i = 0; i < 3; i++)
301 ok(mi[i] == curr_val[i],
302 "incorrect value for %d: %d != %d", i, mi[i], curr_val[i]);
305 rc=SystemParametersInfoW( SPI_GETMOUSE, 0, mi, 0 );
306 if (rc!=0 && GetLastError()!=ERROR_CALL_NOT_IMPLEMENTED)
308 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
309 for (i = 0; i < 3; i++)
311 ok(mi[i] == curr_val[i],
312 "incorrect value for %d: %d != %d", i, mi[i], curr_val[i]);
316 #if 0 /* FIXME: this always fails for me - AJ */
317 for (i = 0; i < nchange; i++)
319 POINT mv;
320 mouse_event( MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, 0, 0, 0, 0 );
321 mouse_event( MOUSEEVENTF_MOVE, req_change[i].x, req_change[i].y, 0, 0 );
322 GetCursorPos( &mv );
323 ok( proj_change[i].x == mv.x, "Projected dx and real dx comparison. May fail under high load." );
324 ok( proj_change[i].y == mv.y, "Projected dy equals real dy. May fail under high load." );
326 #endif
329 static void test_SPI_SETMOUSE( void ) /* 4 */
331 BOOL rc;
332 INT old_mi[3];
334 /* win nt default values - 6, 10, 1 */
335 INT curr_val[3] = {6, 10, 1};
337 /* requested and projected mouse movements */
338 POINT req_change[] = { {6, 6}, { 7, 6}, { 8, 6}, {10, 10}, {11, 10}, {100, 100} };
339 POINT proj_change1[] = { {6, 6}, {14, 6}, {16, 6}, {20, 20}, {22, 20}, {200, 200} };
340 POINT proj_change2[] = { {6, 6}, {14, 6}, {16, 6}, {20, 20}, {44, 20}, {400, 400} };
341 POINT proj_change3[] = { {6, 6}, {14, 6}, {16, 6}, {20, 20}, {22, 20}, {200, 200} };
342 POINT proj_change4[] = { {6, 6}, { 7, 6}, { 8, 6}, {10, 10}, {11, 10}, {100, 100} };
343 POINT proj_change5[] = { {6, 6}, { 7, 6}, {16, 6}, {20, 20}, {22, 20}, {200, 200} };
344 POINT proj_change6[] = { {6, 6}, {28, 6}, {32, 6}, {40, 40}, {44, 40}, {400, 400} };
345 POINT proj_change7[] = { {6, 6}, {14, 6}, {32, 6}, {40, 40}, {44, 40}, {400, 400} };
346 POINT proj_change8[] = { {6, 6}, {28, 6}, {32, 6}, {40, 40}, {44, 40}, {400, 400} };
348 int nchange = sizeof( req_change ) / sizeof( POINT );
350 trace("testing SPI_{GET,SET}MOUSE\n");
351 rc=SystemParametersInfoA( SPI_GETMOUSE, 0, old_mi, 0 );
352 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
354 run_spi_setmouse_test( curr_val, req_change, proj_change1, nchange );
356 /* acceleration change */
357 curr_val[2] = 2;
358 run_spi_setmouse_test( curr_val, req_change, proj_change2, nchange );
360 /* acceleration change */
361 curr_val[2] = 3;
362 run_spi_setmouse_test( curr_val, req_change, proj_change3, nchange );
364 /* acceleration change */
365 curr_val[2] = 0;
366 run_spi_setmouse_test( curr_val, req_change, proj_change4, nchange );
368 /* threshold change */
369 curr_val[2] = 1;
370 curr_val[0] = 7;
371 run_spi_setmouse_test( curr_val, req_change, proj_change5, nchange );
373 /* threshold change */
374 curr_val[2] = 2;
375 curr_val[0] = 6;
376 curr_val[1] = 6;
377 run_spi_setmouse_test( curr_val, req_change, proj_change6, nchange );
379 /* threshold change */
380 curr_val[1] = 7;
381 run_spi_setmouse_test( curr_val, req_change, proj_change7, nchange );
383 /* threshold change */
384 curr_val[1] = 5;
385 run_spi_setmouse_test( curr_val, req_change, proj_change8, nchange );
387 rc=SystemParametersInfoA( SPI_SETMOUSE, 0, old_mi, SPIF_UPDATEINIFILE );
388 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
391 #if 0
392 static void test_setborder(UINT curr_val)
394 BOOL rc;
395 UINT border;
396 INT frame;
397 char buf[10];
399 rc=SystemParametersInfoA( SPI_SETBORDER, curr_val, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
400 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
401 test_change_message( SPI_SETBORDER, 1 );
402 sprintf( buf, "%d", curr_val );
403 test_reg_key( SPI_SETBORDER_REGKEY, SPI_SETBORDER_VALNAME, buf );
405 if (curr_val == 0)
406 curr_val = 1;
407 rc=SystemParametersInfoA( SPI_GETBORDER, 0, &border, 0 );
408 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
409 eq( border, curr_val, "SPI_{GET,SET}BORDER", "%d");
411 frame = curr_val + GetSystemMetrics( SM_CXDLGFRAME );
412 eq( frame, GetSystemMetrics( SM_CXFRAME ), "SM_CXFRAME", "%d" );
413 eq( frame, GetSystemMetrics( SM_CYFRAME ), "SM_CYFRAME", "%d" );
414 eq( frame, GetSystemMetrics( SM_CXSIZEFRAME ), "SM_CXSIZEFRAME", "%d" );
415 eq( frame, GetSystemMetrics( SM_CYSIZEFRAME ), "SM_CYSIZEFRAME", "%d" );
418 static void test_SPI_SETBORDER( void ) /* 6 */
420 BOOL rc;
421 UINT old_border;
423 /* These tests hang when XFree86 4.0 for Windows is running (tested on
424 * WinNT, SP2, Cygwin/XFree 4.1.0. Skip the test when XFree86 is
425 * running.
427 if (FindWindowA( NULL, "Cygwin/XFree86" ))
428 return;
430 trace("testing SPI_{GET,SET}BORDER\n");
431 rc=SystemParametersInfoA( SPI_GETBORDER, 0, &old_border, 0 );
432 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
434 test_setborder(1);
435 test_setborder(0);
436 test_setborder(7);
437 test_setborder(20);
439 /* This will restore sane values if the test hang previous run. */
440 if ( old_border == 7 || old_border == 20 )
441 old_border = -15;
443 rc=SystemParametersInfoA( SPI_SETBORDER, old_border, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
444 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
446 #endif
448 static void test_SPI_SETKEYBOARDSPEED( void ) /* 10 */
450 BOOL rc;
451 UINT old_speed;
452 const UINT vals[]={0,20,31};
453 int i;
455 trace("testing SPI_{GET,SET}KEYBOARDSPEED\n");
456 rc=SystemParametersInfoA( SPI_GETKEYBOARDSPEED, 0, &old_speed, 0 );
457 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
459 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
461 UINT v;
462 char buf[10];
464 rc=SystemParametersInfoA( SPI_SETKEYBOARDSPEED, vals[i], 0,
465 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
466 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
467 test_change_message( SPI_SETKEYBOARDSPEED, 0 );
468 sprintf( buf, "%d", vals[i] );
469 test_reg_key( SPI_SETKEYBOARDSPEED_REGKEY, SPI_SETKEYBOARDSPEED_VALNAME, buf );
471 rc=SystemParametersInfoA( SPI_GETKEYBOARDSPEED, 0, &v, 0 );
472 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
473 eq( v, vals[i], "SPI_{GET,SET}KEYBOARDSPEED", "%d" );
476 rc=SystemParametersInfoA( SPI_SETKEYBOARDSPEED, old_speed, 0, SPIF_UPDATEINIFILE );
477 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
480 static void test_SPI_ICONHORIZONTALSPACING( void ) /* 13 */
482 BOOL rc;
483 INT old_spacing;
484 INT spacing;
485 INT curr_val;
487 trace("testing SPI_ICONHORIZONTALSPACING\n");
488 /* default value: 75 */
489 rc=SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, 0, &old_spacing, 0 );
490 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
492 /* do not increase the value as it would upset the user's icon layout */
493 curr_val = (old_spacing > 32 ? old_spacing-1 : 32);
494 rc=SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, curr_val, 0,
495 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
496 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
497 test_change_message( SPI_ICONHORIZONTALSPACING, 0 );
498 /* The registry keys depend on the Windows version and the values too
499 * => don't test them
502 rc=SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, 0, &spacing, 0 );
503 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
504 eq( spacing, curr_val, "ICONHORIZONTALSPACING", "%d");
505 eq( GetSystemMetrics( SM_CXICONSPACING ), curr_val, "SM_CXICONSPACING", "%d" );
507 curr_val = 10;
508 rc=SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, curr_val, 0,
509 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
510 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
511 curr_val = 32; /*min value*/
512 test_change_message( SPI_ICONHORIZONTALSPACING, 0 );
514 rc=SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, 0, &spacing, 0 );
515 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
516 eq( spacing, curr_val, "ICONHORIZONTALSPACING", "%d" );
517 eq( GetSystemMetrics( SM_CXICONSPACING ), curr_val, "SM_CXICONSPACING", "%d" );
519 rc=SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, old_spacing, 0, SPIF_UPDATEINIFILE );
520 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
523 static void test_SPI_SETSCREENSAVETIMEOUT( void ) /* 14 */
525 BOOL rc;
526 UINT old_timeout;
527 const UINT vals[]={0,32767};
528 int i;
530 trace("testing SPI_{GET,SET}SCREENSAVETIMEOUT\n");
531 rc=SystemParametersInfoA( SPI_GETSCREENSAVETIMEOUT, 0, &old_timeout, 0 );
532 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
534 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
536 UINT v;
537 char buf[10];
539 rc=SystemParametersInfoA( SPI_SETSCREENSAVETIMEOUT, vals[i], 0,
540 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
541 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
542 test_change_message( SPI_SETSCREENSAVETIMEOUT, 0 );
543 sprintf( buf, "%d", vals[i] );
544 test_reg_key( SPI_SETSCREENSAVETIMEOUT_REGKEY,
545 SPI_SETSCREENSAVETIMEOUT_VALNAME, buf );
547 SystemParametersInfoA( SPI_GETSCREENSAVETIMEOUT, 0, &v, 0 );
548 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
549 eq( v, vals[i], "SPI_{GET,SET}SCREENSAVETIMEOUT", "%d" );
552 rc=SystemParametersInfoA( SPI_SETSCREENSAVETIMEOUT, old_timeout, 0,
553 SPIF_UPDATEINIFILE );
554 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
557 static void test_SPI_SETSCREENSAVEACTIVE( void ) /* 17 */
559 BOOL rc;
560 BOOL old_b;
561 const UINT vals[]={TRUE,FALSE};
562 int i;
564 trace("testing SPI_{GET,SET}SCREENSAVEACTIVE\n");
565 rc=SystemParametersInfoA( SPI_GETSCREENSAVEACTIVE, 0, &old_b, 0 );
566 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
568 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
570 UINT v;
572 rc=SystemParametersInfoA( SPI_SETSCREENSAVEACTIVE, vals[i], 0,
573 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
574 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
575 test_change_message( SPI_SETSCREENSAVEACTIVE, 0 );
576 test_reg_key( SPI_SETSCREENSAVEACTIVE_REGKEY,
577 SPI_SETSCREENSAVEACTIVE_VALNAME,
578 vals[i] ? "1" : "0" );
580 rc=SystemParametersInfoA( SPI_GETSCREENSAVEACTIVE, 0, &v, 0 );
581 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
582 eq( v, vals[i], "SPI_{GET,SET}SCREENSAVEACTIVE", "%d" );
585 rc=SystemParametersInfoA( SPI_SETSCREENSAVEACTIVE, old_b, 0, SPIF_UPDATEINIFILE );
586 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
589 static void test_SPI_SETGRIDGRANULARITY( void ) /* 19 */
591 /* ??? */;
594 static void test_SPI_SETKEYBOARDDELAY( void ) /* 23 */
596 BOOL rc;
597 UINT old_delay;
598 const UINT vals[]={0,3};
599 int i;
601 trace("testing SPI_{GET,SET}KEYBOARDDELAY\n");
602 rc=SystemParametersInfoA( SPI_GETKEYBOARDDELAY, 0, &old_delay, 0 );
603 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
605 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
607 UINT delay;
608 char buf[10];
610 rc=SystemParametersInfoA( SPI_SETKEYBOARDDELAY, vals[i], 0,
611 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
612 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
613 test_change_message( SPI_SETKEYBOARDDELAY, 0 );
614 sprintf( buf, "%d", vals[i] );
615 test_reg_key( SPI_SETKEYBOARDDELAY_REGKEY,
616 SPI_SETKEYBOARDDELAY_VALNAME, buf );
618 rc=SystemParametersInfoA( SPI_GETKEYBOARDDELAY, 0, &delay, 0 );
619 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
620 eq( delay, vals[i], "SPI_{GET,SET}KEYBOARDDELAY", "%d" );
623 rc=SystemParametersInfoA( SPI_SETKEYBOARDDELAY, old_delay, 0, SPIF_UPDATEINIFILE );
624 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
627 static void test_SPI_ICONVERTICALSPACING( void ) /* 24 */
629 BOOL rc;
630 INT old_spacing;
631 INT spacing;
632 INT curr_val;
634 trace("testing SPI_ICONVERTICALSPACING\n");
635 /* default value: 75 */
636 rc=SystemParametersInfoA( SPI_ICONVERTICALSPACING, 0, &old_spacing, 0 );
637 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
639 /* do not increase the value as it would upset the user's icon layout */
640 curr_val = old_spacing-1;
641 rc=SystemParametersInfoA( SPI_ICONVERTICALSPACING, curr_val, 0,
642 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
643 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
644 test_change_message( SPI_ICONVERTICALSPACING, 0 );
645 /* The registry keys depend on the Windows version and the values too
646 * => don't test them
649 rc=SystemParametersInfoA( SPI_ICONVERTICALSPACING, 0, &spacing, 0 );
650 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
651 eq( spacing, curr_val, "ICONVERTICALSPACING", "%d" );
652 eq( GetSystemMetrics( SM_CYICONSPACING ), curr_val, "SM_CYICONSPACING", "%d" );
654 curr_val = 10;
655 rc=SystemParametersInfoA( SPI_ICONVERTICALSPACING, curr_val, 0,
656 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
657 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
658 curr_val = 32; /*min value*/
659 test_change_message( SPI_ICONVERTICALSPACING, 0 );
661 rc=SystemParametersInfoA( SPI_ICONVERTICALSPACING, 0, &spacing, 0 );
662 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
663 eq( spacing, curr_val, "ICONVERTICALSPACING", "%d" );
664 eq( GetSystemMetrics( SM_CYICONSPACING ), curr_val, "SM_CYICONSPACING", "%d" );
666 rc=SystemParametersInfoA( SPI_ICONVERTICALSPACING, old_spacing, 0,
667 SPIF_UPDATEINIFILE );
668 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
671 static void test_SPI_SETICONTITLEWRAP( void ) /* 26 */
673 BOOL rc;
674 BOOL old_b;
675 const UINT vals[]={TRUE,FALSE};
676 int i;
678 /* These tests hang when XFree86 4.0 for Windows is running (tested on
679 * WinNT, SP2, Cygwin/XFree 4.1.0. Skip the test when XFree86 is
680 * running.
682 if (FindWindowA( NULL, "Cygwin/XFree86" ))
683 return;
685 trace("testing SPI_{GET,SET}ICONTITLEWRAP\n");
686 rc=SystemParametersInfoA( SPI_GETICONTITLEWRAP, 0, &old_b, 0 );
687 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
689 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
691 UINT v;
693 rc=SystemParametersInfoA( SPI_SETICONTITLEWRAP, vals[i], 0,
694 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
695 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
696 test_change_message( SPI_SETICONTITLEWRAP, 1 );
697 test_reg_key_ex( SPI_SETICONTITLEWRAP_REGKEY1,
698 SPI_SETICONTITLEWRAP_REGKEY2,
699 SPI_SETICONTITLEWRAP_VALNAME,
700 vals[i] ? "1" : "0" );
702 rc=SystemParametersInfoA( SPI_GETICONTITLEWRAP, 0, &v, 0 );
703 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
704 eq( v, vals[i], "SPI_{GET,SET}ICONTITLEWRAP", "%d" );
707 rc=SystemParametersInfoA( SPI_SETICONTITLEWRAP, old_b, 0, SPIF_UPDATEINIFILE );
708 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
711 static void test_SPI_SETMENUDROPALIGNMENT( void ) /* 28 */
713 BOOL rc;
714 BOOL old_b;
715 const UINT vals[]={TRUE,FALSE};
716 int i;
718 trace("testing SPI_{GET,SET}MENUDROPALIGNMENT\n");
719 rc=SystemParametersInfoA( SPI_GETMENUDROPALIGNMENT, 0, &old_b, 0 );
720 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
722 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
724 UINT v;
726 rc=SystemParametersInfoA( SPI_SETMENUDROPALIGNMENT, vals[i], 0,
727 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
728 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
729 test_change_message( SPI_SETMENUDROPALIGNMENT, 0 );
730 test_reg_key_ex( SPI_SETMENUDROPALIGNMENT_REGKEY1,
731 SPI_SETMENUDROPALIGNMENT_REGKEY2,
732 SPI_SETMENUDROPALIGNMENT_VALNAME,
733 vals[i] ? "1" : "0" );
735 rc=SystemParametersInfoA( SPI_GETMENUDROPALIGNMENT, 0, &v, 0 );
736 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
737 eq( v, vals[i], "SPI_{GET,SET}MENUDROPALIGNMENT", "%d" );
738 eq( GetSystemMetrics( SM_MENUDROPALIGNMENT ), (int)vals[i],
739 "SM_MENUDROPALIGNMENT", "%d" );
742 rc=SystemParametersInfoA( SPI_SETMENUDROPALIGNMENT, old_b, 0,
743 SPIF_UPDATEINIFILE );
744 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
747 static void test_SPI_SETDOUBLECLKWIDTH( void ) /* 29 */
749 BOOL rc;
750 INT old_width;
751 const UINT vals[]={0,10000};
752 int i;
754 trace("testing SPI_{GET,SET}DOUBLECLKWIDTH\n");
755 old_width = GetSystemMetrics( SM_CXDOUBLECLK );
757 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
759 char buf[10];
761 rc=SystemParametersInfoA( SPI_SETDOUBLECLKWIDTH, vals[i], 0,
762 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
763 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
764 test_change_message( SPI_SETDOUBLECLKWIDTH, 0 );
765 sprintf( buf, "%d", vals[i] );
766 test_reg_key_ex( SPI_SETDOUBLECLKWIDTH_REGKEY1,
767 SPI_SETDOUBLECLKWIDTH_REGKEY2,
768 SPI_SETDOUBLECLKWIDTH_VALNAME, buf );
769 eq( GetSystemMetrics( SM_CXDOUBLECLK ), (int)vals[i],
770 "SM_CXDOUBLECLK", "%d" );
773 rc=SystemParametersInfoA( SPI_SETDOUBLECLKWIDTH, old_width, 0,
774 SPIF_UPDATEINIFILE );
775 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
778 static void test_SPI_SETDOUBLECLKHEIGHT( void ) /* 30 */
780 BOOL rc;
781 INT old_height;
782 const UINT vals[]={0,10000};
783 int i;
785 trace("testing SPI_{GET,SET}DOUBLECLKHEIGHT\n");
786 old_height = GetSystemMetrics( SM_CYDOUBLECLK );
788 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
790 char buf[10];
792 rc=SystemParametersInfoA( SPI_SETDOUBLECLKHEIGHT, vals[i], 0,
793 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
794 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
795 test_change_message( SPI_SETDOUBLECLKHEIGHT, 0 );
796 sprintf( buf, "%d", vals[i] );
797 test_reg_key_ex( SPI_SETDOUBLECLKHEIGHT_REGKEY1,
798 SPI_SETDOUBLECLKHEIGHT_REGKEY2,
799 SPI_SETDOUBLECLKHEIGHT_VALNAME, buf );
800 eq( GetSystemMetrics( SM_CYDOUBLECLK ), (int)vals[i],
801 "SM_CYDOUBLECLK", "%d" );
804 rc=SystemParametersInfoA( SPI_SETDOUBLECLKHEIGHT, old_height, 0,
805 SPIF_UPDATEINIFILE );
806 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
809 static void test_SPI_SETDOUBLECLICKTIME( void ) /* 32 */
811 BOOL rc;
812 UINT curr_val;
813 UINT saved_val;
814 UINT old_time;
815 char buf[10];
817 trace("testing SPI_{GET,SET}DOUBLECLICKTIME\n");
818 old_time = GetDoubleClickTime();
820 curr_val = 0;
821 rc=SystemParametersInfoA( SPI_SETDOUBLECLICKTIME, curr_val, 0,
822 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
823 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
824 test_change_message( SPI_SETDOUBLECLICKTIME, 0 );
825 sprintf( buf, "%d", curr_val );
826 test_reg_key( SPI_SETDOUBLECLICKTIME_REGKEY,
827 SPI_SETDOUBLECLICKTIME_VALNAME, buf );
828 curr_val = 500; /* used value for 0 */
829 eq( GetDoubleClickTime(), curr_val, "GetDoubleClickTime", "%d" );
831 curr_val = 1000;
832 rc=SystemParametersInfoA( SPI_SETDOUBLECLICKTIME, curr_val, 0,
833 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
834 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
835 test_change_message( SPI_SETDOUBLECLICKTIME, 0 );
836 sprintf( buf, "%d", curr_val );
837 test_reg_key( SPI_SETDOUBLECLICKTIME_REGKEY,
838 SPI_SETDOUBLECLICKTIME_VALNAME, buf );
839 eq( GetDoubleClickTime(), curr_val, "GetDoubleClickTime", "%d" );
841 saved_val = curr_val;
843 curr_val = 0;
844 SetDoubleClickTime( curr_val );
845 sprintf( buf, "%d", saved_val );
846 test_reg_key( SPI_SETDOUBLECLICKTIME_REGKEY,
847 SPI_SETDOUBLECLICKTIME_VALNAME, buf );
848 curr_val = 500; /* used value for 0 */
849 eq( GetDoubleClickTime(), curr_val, "GetDoubleClickTime", "%d" );
851 curr_val = 1000;
852 SetDoubleClickTime( curr_val );
853 sprintf( buf, "%d", saved_val );
854 test_reg_key( SPI_SETDOUBLECLICKTIME_REGKEY,
855 SPI_SETDOUBLECLICKTIME_VALNAME, buf );
856 eq( GetDoubleClickTime(), curr_val, "GetDoubleClickTime", "%d" );
858 rc=SystemParametersInfoA(SPI_SETDOUBLECLICKTIME, old_time, 0, SPIF_UPDATEINIFILE);
859 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
862 static void test_SPI_SETMOUSEBUTTONSWAP( void ) /* 33 */
864 BOOL rc;
865 BOOL old_b;
866 const UINT vals[]={TRUE,FALSE};
867 int i;
869 trace("testing SPI_{GET,SET}MOUSEBUTTONSWAP\n");
870 old_b = GetSystemMetrics( SM_SWAPBUTTON );
872 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
874 rc=SystemParametersInfoA( SPI_SETMOUSEBUTTONSWAP, vals[i], 0,
875 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
876 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
877 test_change_message( SPI_SETMOUSEBUTTONSWAP, 0 );
878 test_reg_key( SPI_SETMOUSEBUTTONSWAP_REGKEY,
879 SPI_SETMOUSEBUTTONSWAP_VALNAME,
880 vals[i] ? "1" : "0" );
881 eq( GetSystemMetrics( SM_SWAPBUTTON ), (int)vals[i],
882 "SM_SWAPBUTTON", "%d" );
885 rc=SystemParametersInfoA( SPI_SETMOUSEBUTTONSWAP, old_b, 0,
886 SPIF_UPDATEINIFILE );
887 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
890 static void test_SPI_SETFASTTASKSWITCH( void ) /* 36 */
892 BOOL rc;
893 BOOL v;
895 trace("testing SPI_GETFASTTASKSWITCH\n");
896 rc=SystemParametersInfoA( SPI_GETFASTTASKSWITCH, 0, &v, 0 );
897 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
898 /* there is not a single Windows platform on which SPI_GETFASTTASKSWITCH
899 * works. That sure simplifies testing!
903 static void test_SPI_SETDRAGFULLWINDOWS( void ) /* 37 */
905 BOOL rc;
906 BOOL old_b;
907 const UINT vals[]={TRUE,FALSE};
908 int i;
910 trace("testing SPI_{GET,SET}DRAGFULLWINDOWS\n");
911 rc=SystemParametersInfoA( SPI_GETDRAGFULLWINDOWS, 0, &old_b, 0 );
912 if (rc==0 && (GetLastError()==0 || GetLastError()==ERROR_CALL_NOT_IMPLEMENTED))
914 /* SPI_{GET,SET}DRAGFULLWINDOWS is not implemented on Win95 */
915 trace("SPI_{GET,SET}DRAGFULLWINDOWS not supported on this platform\n");
916 return;
918 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
920 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
922 UINT v;
924 rc=SystemParametersInfoA( SPI_SETDRAGFULLWINDOWS, vals[i], 0,
925 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
926 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
927 test_change_message( SPI_SETDRAGFULLWINDOWS, 0 );
928 test_reg_key( SPI_SETDRAGFULLWINDOWS_REGKEY,
929 SPI_SETDRAGFULLWINDOWS_VALNAME,
930 vals[i] ? "1" : "0" );
932 rc=SystemParametersInfoA( SPI_GETDRAGFULLWINDOWS, 0, &v, 0 );
933 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
934 eq( v, vals[i], "SPI_{GET,SET}DRAGFULLWINDOWS", "%d" );
937 rc=SystemParametersInfoA( SPI_SETDRAGFULLWINDOWS, old_b, 0, SPIF_UPDATEINIFILE );
938 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
941 static void test_SPI_SETWORKAREA( void ) /* 47 */
943 BOOL rc;
944 RECT old_area;
945 RECT area;
946 RECT curr_val;
948 trace("testing SPI_{GET,SET}WORKAREA\n");
949 rc=SystemParametersInfoA(SPI_GETWORKAREA, 0, &old_area, 0);
950 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
952 /* Modify the work area only minimally as this causes the icons that
953 * fall outside it to be moved around thus requiring the user to
954 * reposition them manually one by one.
955 * Changing the work area by just one pixel should make this occurence
956 * reasonably unlikely.
958 curr_val.left = old_area.left;
959 curr_val.top = old_area.top;
960 curr_val.right = old_area.right-1;
961 curr_val.bottom = old_area.bottom-1;
962 rc=SystemParametersInfoA( SPI_SETWORKAREA, 0, &curr_val,
963 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
964 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
965 test_change_message( SPI_SETWORKAREA, 0 );
966 rc=SystemParametersInfoA( SPI_GETWORKAREA, 0, &area, 0 );
967 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
968 eq( area.left, curr_val.left, "left", "%ld" );
969 eq( area.top, curr_val.top, "top", "%ld" );
970 eq( area.right, curr_val.right, "right", "%ld" );
971 eq( area.bottom, curr_val.bottom, "bottom", "%ld" );
973 rc=SystemParametersInfoA( SPI_SETWORKAREA, 0, &old_area,
974 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
975 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
976 test_change_message( SPI_SETWORKAREA, 0 );
977 rc=SystemParametersInfoA( SPI_GETWORKAREA, 0, &area, 0 );
978 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
979 eq( area.left, old_area.left, "left", "%ld" );
980 eq( area.top, old_area.top, "top", "%ld" );
981 eq( area.right, old_area.right, "right", "%ld" );
982 eq( area.bottom, old_area.bottom, "bottom", "%ld" );
985 static void test_SPI_SETSHOWSOUNDS( void ) /* 57 */
987 BOOL rc;
988 BOOL old_b;
989 const UINT vals[]={TRUE,FALSE};
990 int i;
992 trace("testing SPI_{GET,SET}SHOWSOUNDS\n");
993 SetLastError(0);
994 rc=SystemParametersInfoA( SPI_GETSHOWSOUNDS, 0, &old_b, 0 );
995 if (rc==0 && GetLastError()==0)
997 /* SPI_{GET,SET}SHOWSOUNDS is completely broken on Win9x */
998 trace("SPI_{GET,SET}SHOWSOUNDS not supported on this platform\n");
999 return;
1001 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
1003 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
1005 UINT v;
1007 rc=SystemParametersInfoA( SPI_SETSHOWSOUNDS, vals[i], 0,
1008 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
1009 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
1010 test_change_message( SPI_SETSHOWSOUNDS, 0 );
1011 test_reg_key( SPI_SETSHOWSOUNDS_REGKEY,
1012 SPI_SETSHOWSOUNDS_VALNAME,
1013 vals[i] ? "1" : "0" );
1015 rc=SystemParametersInfoA( SPI_GETSHOWSOUNDS, 0, &v, 0 );
1016 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
1017 eq( v, vals[i], "SPI_GETSHOWSOUNDS", "%d" );
1018 eq( GetSystemMetrics( SM_SHOWSOUNDS ), (int)vals[i],
1019 "SM_SHOWSOUNDS", "%d" );
1022 rc=SystemParametersInfoA( SPI_SETSHOWSOUNDS, old_b, 0, SPIF_UPDATEINIFILE );
1023 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
1026 static void test_SPI_SETKEYBOARDPREF( void ) /* 69 */
1028 /* TODO!!! - don't have version of Windows which has this */
1031 static void test_SPI_SETSCREENREADER( void ) /* 71 */
1033 /* TODO!!! - don't have version of Windows which has this */
1036 static void test_SPI_SETWALLPAPER( void ) /* 115 */
1038 BOOL rc;
1039 char oldval[260];
1040 char newval[260];
1042 trace("testing SPI_{GET,SET}DESKWALLPAPER\n");
1043 SetLastError(0);
1044 rc=SystemParametersInfoA(SPI_GETDESKWALLPAPER, 260, oldval, 0);
1045 if (rc==0 && (GetLastError()==0 || GetLastError()==ERROR_INVALID_SPI_VALUE))
1047 /* SPI_{GET,SET}DESKWALLPAPER is completely broken on Win9x and
1048 * unimplemented on NT4
1050 trace("SPI_{GET,SET}DESKWALLPAPER not supported on this platform\n");
1051 return;
1053 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
1054 test_reg_key(SPI_SETDESKWALLPAPER_REGKEY, SPI_SETDESKWALLPAPER_VALNAME, oldval);
1056 strcpy(newval, "");
1057 rc=SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, newval, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
1058 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
1059 test_change_message(SPI_SETDESKWALLPAPER, 0);
1061 rc=SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, oldval, SPIF_UPDATEINIFILE);
1062 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
1066 * Registry entries for the system parameters.
1067 * Names are created by 'SET' flags names.
1068 * We assume that corresponding 'GET' entries use the same registry keys.
1070 static DWORD WINAPI SysParamsThreadFunc( LPVOID lpParam )
1072 test_SPI_SETBEEP(); /* 1 */
1073 test_SPI_SETMOUSE(); /* 4 */
1074 /* Messes up systems settings on Win9x */
1075 /*test_SPI_SETBORDER();*/ /* 6 */
1076 test_SPI_SETKEYBOARDSPEED(); /* 10 */
1077 test_SPI_ICONHORIZONTALSPACING(); /* 13 */
1078 test_SPI_SETSCREENSAVETIMEOUT(); /* 14 */
1079 test_SPI_SETSCREENSAVEACTIVE(); /* 17 */
1080 test_SPI_SETGRIDGRANULARITY(); /* 19 */
1081 test_SPI_SETKEYBOARDDELAY(); /* 23 */
1082 test_SPI_ICONVERTICALSPACING(); /* 24 */
1083 test_SPI_SETICONTITLEWRAP(); /* 26 */
1084 test_SPI_SETMENUDROPALIGNMENT(); /* 28 */
1085 test_SPI_SETDOUBLECLKWIDTH(); /* 29 */
1086 test_SPI_SETDOUBLECLKHEIGHT(); /* 30 */
1087 test_SPI_SETDOUBLECLICKTIME(); /* 32 */
1088 test_SPI_SETMOUSEBUTTONSWAP(); /* 33 */
1089 test_SPI_SETFASTTASKSWITCH(); /* 36 */
1090 test_SPI_SETDRAGFULLWINDOWS(); /* 37 */
1091 test_SPI_SETWORKAREA(); /* 47 */
1092 test_SPI_SETSHOWSOUNDS(); /* 57 */
1093 test_SPI_SETKEYBOARDPREF(); /* 69 */
1094 test_SPI_SETSCREENREADER(); /* 71 */
1095 test_SPI_SETWALLPAPER(); /* 115 */
1096 SendMessageA( ghTestWnd, WM_DESTROY, 0, 0 );
1097 return 0;
1100 START_TEST(sysparams)
1102 int argc;
1103 char** argv;
1104 WNDCLASSA wc;
1105 MSG msg;
1106 HANDLE hThread;
1107 DWORD dwThreadId;
1108 HANDLE hInstance = GetModuleHandleA( NULL );
1110 argc = winetest_get_mainargs(&argv);
1111 strict=(argc >= 3 && strcmp(argv[2],"strict")==0);
1112 trace("strict=%d\n",strict);
1114 change_counter = 0;
1115 change_last_param = 0;
1117 wc.lpszClassName = "SysParamsTestClass";
1118 wc.lpfnWndProc = SysParamsTestWndProc;
1119 wc.style = CS_OWNDC | CS_VREDRAW | CS_HREDRAW;
1120 wc.hInstance = hInstance;
1121 wc.hIcon = LoadIconA( 0, IDI_APPLICATIONA );
1122 wc.hCursor = LoadCursorA( 0, IDC_ARROWA );
1123 wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1 );
1124 wc.lpszMenuName = 0;
1125 wc.cbClsExtra = 0;
1126 wc.cbWndExtra = 0;
1127 RegisterClassA( &wc );
1129 ghTestWnd = CreateWindowA( "SysParamsTestClass", "Test System Parameters Application",
1130 WS_OVERLAPPEDWINDOW, 0, 0, 100, 100, 0, 0, hInstance, NULL );
1132 hThread = CreateThread( NULL, 0, SysParamsThreadFunc, 0, 0, &dwThreadId );
1133 assert( hThread );
1134 CloseHandle( hThread );
1136 while( GetMessageA( &msg, 0, 0, 0 )) {
1137 TranslateMessage( &msg );
1138 DispatchMessageA( &msg );