Keep track of per-column information inside the listview.
[wine] / dlls / user / tests / sysparams.c
1 /* Unit test suite for functions SystemParametersInfo and GetSystemMetrics.
2  *
3  * Copyright 2002 Andriy Palamarchuk
4  *
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.
9  *
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.
14  *
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
18  */
19
20 #include <assert.h>
21 #include <stdlib.h>
22 #include <stdio.h>
23
24 #include "wine/test.h"
25 #include "winbase.h"
26 #include "winreg.h"
27 #include "winuser.h"
28
29 #ifndef IDI_APPLICATIONA
30 #define IDI_APPLICATIONA IDI_APPLICATION
31 #endif
32 #ifndef IDC_ARROWA
33 #define IDC_ARROWA IDC_ARROW
34 #endif
35
36 #define eq(received, expected, label, type) \
37         ok((received) == (expected), "%s: got " type " instead of " type, (label),(received),(expected))
38
39
40 /* FIXME: should fix the tests to not require this */
41 static int has_unicode(void) { return 1; }
42
43 #define SPI_SETBEEP_REGKEY           "Control Panel\\Sound"
44 #define SPI_SETBEEP_VALNAME          "Beep"
45 #define SPI_SETMOUSE_REGKEY             "Control Panel\\Mouse"
46 #define SPI_SETMOUSE_VALNAME1           "MouseThreshold1"
47 #define SPI_SETMOUSE_VALNAME2           "MouseThreshold2"
48 #define SPI_SETMOUSE_VALNAME3           "MouseSpeed"
49 #define SPI_SETBORDER_REGKEY         "Control Panel\\Desktop"
50 #define SPI_SETBORDER_VALNAME        "BorderWidth"
51 #define SPI_SETKEYBOARDSPEED_REGKEY             "Control Panel\\Keyboard"
52 #define SPI_SETKEYBOARDSPEED_VALNAME            "KeyboardSpeed"
53 #define SPI_ICONHORIZONTALSPACING_REGKEY        "Control Panel\\Desktop"
54 #define SPI_ICONHORIZONTALSPACING_VALNAME       "IconSpacing"
55 #define SPI_SETSCREENSAVETIMEOUT_REGKEY         "Control Panel\\Desktop"
56 #define SPI_SETSCREENSAVETIMEOUT_VALNAME        "ScreenSaveTimeOut"
57 #define SPI_SETSCREENSAVEACTIVE_REGKEY          "Control Panel\\Desktop"
58 #define SPI_SETSCREENSAVEACTIVE_VALNAME         "ScreenSaveActive"
59 #define SPI_SETGRIDGRANULARITY_REGKEY           "Control Panel\\Desktop"
60 #define SPI_SETGRIDGRANULARITY_VALNAME          "GridGranularity"
61 #define SPI_SETKEYBOARDDELAY_REGKEY             "Control Panel\\Keyboard"
62 #define SPI_SETKEYBOARDDELAY_VALNAME            "KeyboardDelay"
63 #define SPI_ICONVERTICALSPACING_REGKEY          "Control Panel\\Desktop"
64 #define SPI_ICONVERTICALSPACING_VALNAME         "IconVerticalSpacing"
65 #define SPI_SETICONTITLEWRAP_REGKEY             "Control Panel\\Desktop"
66 #define SPI_SETICONTITLEWRAP_VALNAME            "IconTitleWrap"
67 #define SPI_SETMENUDROPALIGNMENT_REGKEY         "Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows"
68 #define SPI_SETMENUDROPALIGNMENT_VALNAME        "MenuDropAlignment"
69 #define SPI_SETDOUBLECLKWIDTH_REGKEY            "Control Panel\\Mouse"
70 #define SPI_SETDOUBLECLKWIDTH_VALNAME           "DoubleClickWidth"
71 #define SPI_SETDOUBLECLKHEIGHT_REGKEY           "Control Panel\\Mouse"
72 #define SPI_SETDOUBLECLKHEIGHT_VALNAME          "DoubleClickHeight"
73 #define SPI_SETDOUBLECLICKTIME_REGKEY           "Control Panel\\Mouse"
74 #define SPI_SETDOUBLECLICKTIME_VALNAME          "DoubleClickSpeed"
75 #define SPI_SETMOUSEBUTTONSWAP_REGKEY           "Control Panel\\Mouse"
76 #define SPI_SETMOUSEBUTTONSWAP_VALNAME          "SwapMouseButtons"
77 #define SPI_SETWORKAREA_REGKEY                  "Control Panel\\Desktop"
78 #define SPI_SETWORKAREA_VALNAME                 "WINE_WorkArea"
79 #define SPI_SETSHOWSOUNDS_REGKEY     "Control Panel\\Accessibility\\ShowSounds"
80 #define SPI_SETSHOWSOUNDS_VALNAME    "On"
81 #define SPI_SETFASTTASKSWITCH_REGKEY            "Control Panel\\Desktop"
82 #define SPI_SETFASTTASKSWITCH_VALNAME           "CoolSwitch"
83 #define SPI_SETDRAGFULLWINDOWS_REGKEY           "Control Panel\\Desktop"
84 #define SPI_SETDRAGFULLWINDOWS_VALNAME          "DragFullWindows"
85 #define SPI_SETDESKWALLPAPER_REGKEY             "Control Panel\\Desktop"
86 #define SPI_SETDESKWALLPAPER_VALNAME            "Wallpaper"
87 /* FIXME - don't have access to Windows with this action (W95, NT5.0). Set real values */
88 #define SPI_SETKEYBOARDPREF_REGKEY      "Control Panel\\Desktop"
89 #define SPI_SETKEYBOARDPREF_VALNAME     "WINE_WorkArea"
90 #define SPI_SETSCREENREADER_REGKEY      "Control Panel\\Desktop"
91 #define SPI_SETSCREENREADER_VALNAME     "???"
92
93 /* volatile registry branch under CURRENT_USER_REGKEY for temporary values storage */
94 #define WINE_CURRENT_USER_REGKEY     "Wine"
95
96 static HWND ghTestWnd;
97
98 static DWORD WINAPI SysParamsThreadFunc( LPVOID lpParam );
99 static LRESULT CALLBACK SysParamsTestWndProc( HWND hWnd, UINT msg, WPARAM wParam,
100                                               LPARAM lParam );
101 static int change_counter;
102 static int change_last_param;
103 static char change_reg_section[MAX_PATH];
104
105 static LRESULT CALLBACK SysParamsTestWndProc( HWND hWnd, UINT msg, WPARAM wParam,
106                                               LPARAM lParam )
107 {
108     switch(msg) {
109
110     case WM_SETTINGCHANGE:
111         change_counter++;
112         change_last_param = wParam;
113         strncpy( change_reg_section, (LPSTR) lParam, sizeof( change_reg_section ));
114         break;
115
116     case WM_DESTROY:
117         PostQuitMessage( 0 );
118         break;
119
120     default:
121         return( DefWindowProcA( hWnd, msg, wParam, lParam ) );
122     }
123
124     return 0;
125 }
126
127 /*
128 Performs testing for system parameters messages
129 params:
130  - system parameter id
131  - supposed value of the registry key
132 */
133 static void test_change_message( UINT action, char *reg_section )
134 {
135     ok( 1 == change_counter,
136         "Missed a message: change_counter=%d", change_counter );
137     change_counter = 0;
138     ok( action == change_last_param,
139         "Wrong action %d != %d", action, change_last_param );
140     change_last_param = 0;
141     ok( !strcmp( reg_section, change_reg_section ),
142         "Unexpected registry section %s != %s",
143         reg_section, change_reg_section );
144     strcpy( change_reg_section, "");
145 }
146
147 /*
148  * Tests the HKEY_CURRENT_USER subkey value.
149  * The value should contain string value.
150  *
151  * Params:
152  * lpsSubKey - subkey name
153  * lpsRegName - registry entry name
154  * lpsTestValue - value to test
155  */
156 static void _test_reg_key( LPSTR subKey, LPSTR valName, LPSTR testValue, char *file, int line )
157 {
158     CHAR  value[MAX_PATH] = "";
159     DWORD valueLen = MAX_PATH;
160     DWORD type;
161     HKEY hKey;
162
163     RegOpenKeyA( HKEY_CURRENT_USER, subKey, &hKey );
164     RegQueryValueExA( hKey, valName, NULL, &type, value, &valueLen );
165     RegCloseKey( hKey );
166     ok( !strcmp( testValue, value ),
167         "Wrong value in registry: subKey=%s, valName=%s, testValue=%s, value=%s",
168         subKey, valName, testValue, value );
169 }
170
171 #define test_reg_key( subKey, valName, testValue ) \
172     _test_reg_key( subKey, valName, testValue, __FILE__, __LINE__ )
173
174 static void test_SPI_SETBEEP( void )                   /*      2 */
175 {
176     BOOL old_b;
177     BOOL b;
178     BOOL curr_val;
179
180     trace("testing SPI_{GET,SET}BEEP\n");
181     SystemParametersInfoA( SPI_GETBEEP, 0, &old_b, 0 );
182
183     curr_val = TRUE;
184     SystemParametersInfoA( SPI_SETBEEP, curr_val, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
185     test_change_message( SPI_SETBEEP, "" );
186     test_reg_key( SPI_SETBEEP_REGKEY,
187                   SPI_SETBEEP_VALNAME,
188                   curr_val ? "Yes" : "No" );
189     SystemParametersInfoA( SPI_GETBEEP, 0, &b, 0 );
190     eq( b, curr_val, "SPI_{GET,SET}BEEP", "%d" );
191     if (has_unicode())
192     {
193         SystemParametersInfoW( SPI_GETBEEP, 0, &b, 0 );
194         eq( b, curr_val, "SystemParametersInfoW", "%d" );
195     }
196
197     /* is a message sent for the second change? */
198     SystemParametersInfoA( SPI_SETBEEP, curr_val, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
199     test_change_message( SPI_SETBEEP, "" );
200
201     curr_val = FALSE;
202     if (has_unicode())
203         SystemParametersInfoW( SPI_SETBEEP, curr_val, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
204     else
205         SystemParametersInfoA( SPI_SETBEEP, curr_val, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
206     test_change_message( SPI_SETBEEP, "" );
207     test_reg_key( SPI_SETBEEP_REGKEY,
208                   SPI_SETBEEP_VALNAME,
209                   curr_val ? "Yes" : "No" );
210     SystemParametersInfoA( SPI_GETBEEP, 0, &b, 0 );
211     eq( b, curr_val, "SPI_{GET,SET}BEEP", "%d" );
212     if (has_unicode())
213     {
214         SystemParametersInfoW( SPI_GETBEEP, 0, &b, 0 );
215         eq( b, curr_val, "SystemParametersInfoW", "%d" );
216     }
217     ok( MessageBeep( MB_OK ), "Return value of MessageBeep when sound is disabled" );
218
219     SystemParametersInfoA( SPI_SETBEEP, old_b, 0, SPIF_UPDATEINIFILE );
220 }
221
222 static char *setmouse_valuenames[3] = {
223     SPI_SETMOUSE_VALNAME1,
224     SPI_SETMOUSE_VALNAME2,
225     SPI_SETMOUSE_VALNAME3
226 };
227
228 /*
229  * Runs check for one setting of spi_setmouse.
230  */
231 static void run_spi_setmouse_test( int curr_val[], POINT *req_change, POINT *proj_change,
232                                    int nchange )
233 {
234     INT mi[3];
235     static int aw_turn = 0;
236
237     char buf[20];
238     int i;
239
240     aw_turn++;
241     if (has_unicode() && (aw_turn % 2))        /* call unicode version each second call */
242         SystemParametersInfoW( SPI_SETMOUSE, 0, curr_val, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
243     else
244         SystemParametersInfoA( SPI_SETMOUSE, 0, curr_val, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
245     test_change_message( SPI_SETMOUSE, "" );
246     for (i = 0; i < 3; i++)
247     {
248         sprintf( buf, "%d", curr_val[i] );
249         test_reg_key( SPI_SETMOUSE_REGKEY, setmouse_valuenames[i], buf );
250     }
251
252     SystemParametersInfoA( SPI_GETMOUSE, 0, mi, 0 );
253     for (i = 0; i < 3; i++)
254     {
255         ok(mi[i] == curr_val[i],
256            "incorrect value for %d: %d != %d", i, mi[i], curr_val[i]);
257     }
258
259     if (has_unicode())
260     {
261         SystemParametersInfoW( SPI_GETMOUSE, 0, mi, 0 );
262         for (i = 0; i < 3; i++)
263         {
264             ok(mi[i] == curr_val[i],
265                "incorrect value for %d: %d != %d", i, mi[i], curr_val[i]);
266         }
267     }
268
269 #if 0  /* FIXME: this always fails for me  - AJ */
270     for (i = 0; i < nchange; i++)
271     {
272         POINT mv;
273         mouse_event( MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, 0, 0, 0, 0 );
274         mouse_event( MOUSEEVENTF_MOVE, req_change[i].x, req_change[i].y, 0, 0 );
275         GetCursorPos( &mv );
276         ok( proj_change[i].x == mv.x, "Projected dx and real dx comparison. May fail under high load." );
277         ok( proj_change[i].y == mv.y, "Projected dy equals real dy. May fail under high load." );
278     }
279 #endif
280 }
281
282 static void test_SPI_SETMOUSE( void )                  /*      4 */
283 {
284     INT old_mi[3];
285
286     /* win nt default values - 6, 10, 1*/
287     INT curr_val[3] = {6, 10, 1};
288
289     /*requested and projected mouse movements */
290     POINT req_change[] =   { {6, 6}, { 7, 6}, { 8, 6}, {10, 10}, {11, 10}, {100, 100} };
291     POINT proj_change1[] = { {6, 6}, {14, 6}, {16, 6}, {20, 20}, {22, 20}, {200, 200} };
292     POINT proj_change2[] = { {6, 6}, {14, 6}, {16, 6}, {20, 20}, {44, 20}, {400, 400} };
293     POINT proj_change3[] = { {6, 6}, {14, 6}, {16, 6}, {20, 20}, {22, 20}, {200, 200} };
294     POINT proj_change4[] = { {6, 6}, { 7, 6}, { 8, 6}, {10, 10}, {11, 10}, {100, 100} };
295     POINT proj_change5[] = { {6, 6}, { 7, 6}, {16, 6}, {20, 20}, {22, 20}, {200, 200} };
296     POINT proj_change6[] = { {6, 6}, {28, 6}, {32, 6}, {40, 40}, {44, 40}, {400, 400} };
297     POINT proj_change7[] = { {6, 6}, {14, 6}, {32, 6}, {40, 40}, {44, 40}, {400, 400} };
298     POINT proj_change8[] = { {6, 6}, {28, 6}, {32, 6}, {40, 40}, {44, 40}, {400, 400} };
299
300     int nchange = sizeof( req_change ) / sizeof( POINT );
301
302     trace("testing SPI_{GET,SET}MOUSE\n");
303     SystemParametersInfoA( SPI_GETMOUSE, 0, old_mi, 0 );
304
305     run_spi_setmouse_test( curr_val, req_change, proj_change1, nchange );
306
307     /* acceleration change */
308     curr_val[2] = 2;
309     run_spi_setmouse_test( curr_val, req_change, proj_change2, nchange );
310
311     /* acceleration change */
312     curr_val[2] = 3;
313     run_spi_setmouse_test( curr_val, req_change, proj_change3, nchange );
314
315     /* acceleration change */
316     curr_val[2] = 0;
317     run_spi_setmouse_test( curr_val, req_change, proj_change4, nchange );
318
319     /* threshold change */
320     curr_val[2] = 1;
321     curr_val[0] = 7;
322     run_spi_setmouse_test( curr_val, req_change, proj_change5, nchange );
323
324     /* threshold change */
325     curr_val[2] = 2;
326     curr_val[0] = 6;
327     curr_val[1] = 6;
328     run_spi_setmouse_test( curr_val, req_change, proj_change6, nchange );
329
330     /* threshold change */
331     curr_val[1] = 7;
332     run_spi_setmouse_test( curr_val, req_change, proj_change7, nchange );
333
334     /* threshold change */
335     curr_val[1] = 5;
336     run_spi_setmouse_test( curr_val, req_change, proj_change8, nchange );
337
338     SystemParametersInfoA( SPI_SETMOUSE, 0, old_mi, SPIF_UPDATEINIFILE );
339 }
340
341 static void test_SPI_SETBORDER( void )                 /*      6 */
342 {
343     UINT old_border;
344     UINT curr_val;
345     UINT border;
346     UINT frame;
347     char buf[10];
348
349     /* tests one configuration of border settings */
350 #define TEST_SETBORDER \
351     SystemParametersInfoA( SPI_SETBORDER, curr_val, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE ); \
352     test_change_message( SPI_SETBORDER, "" ); \
353     sprintf( buf, "%d", curr_val ); \
354     test_reg_key( SPI_SETBORDER_REGKEY, SPI_SETBORDER_VALNAME, buf ); \
355     if (curr_val == 0) curr_val = 1; \
356     SystemParametersInfoA( SPI_GETBORDER, 0, &border, 0 ); \
357     eq( border, curr_val, "SPI_{GET,SET}BORDER", "%d"); \
358     frame = curr_val + GetSystemMetrics( SM_CXDLGFRAME ); \
359     eq( frame, GetSystemMetrics( SM_CXFRAME ), "SM_CXFRAME", "%d" ); \
360     eq( frame, GetSystemMetrics( SM_CYFRAME ), "SM_CYFRAME", "%d" ); \
361     eq( frame, GetSystemMetrics( SM_CXSIZEFRAME ), "SM_CXSIZEFRAME", "%d" ); \
362     eq( frame, GetSystemMetrics( SM_CYSIZEFRAME ), "SM_CYSIZEFRAME", "%d" )
363
364     /* These tests hang when XFree86 4.0 for Windows is running (tested on
365      *  WinNT, SP2, Cygwin/XFree 4.1.0. Skip the test when XFree86 is
366      * running.
367      */
368     if (!FindWindowA( NULL, "Cygwin/XFree86" ))
369     {
370         trace("testing SPI_{GET,SET}BORDER\n");
371         SystemParametersInfoA( SPI_GETBORDER, 0, &old_border, 0 );
372
373         curr_val = 1;
374         TEST_SETBORDER;
375
376         curr_val = 0;
377         TEST_SETBORDER;
378
379         curr_val = 7;
380         TEST_SETBORDER;
381
382         curr_val = 20;
383         TEST_SETBORDER;
384
385         /* This will restore sane values if the test hang previous run. */
386         if ( old_border == 7 || old_border == 20 )
387             old_border = 1;
388
389         SystemParametersInfoA( SPI_SETBORDER, old_border, 0, SPIF_UPDATEINIFILE );
390     }
391
392 #undef TEST_SETBORDER
393 }
394
395 static void test_SPI_SETKEYBOARDSPEED( void )          /*     10 */
396 {
397     UINT old_speed;
398     UINT curr_val;
399     UINT speed;
400     char buf[10];
401
402     trace("testing SPI_{GET,SET}KEYBOARDSPEED\n");
403     SystemParametersInfoA( SPI_GETKEYBOARDSPEED, 0, &old_speed, 0 );
404
405     curr_val = 0;
406     SystemParametersInfoA( SPI_SETKEYBOARDSPEED, curr_val, 0,
407                            SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
408     test_change_message( SPI_SETKEYBOARDSPEED, "" );
409     sprintf( buf, "%d", curr_val );
410     test_reg_key( SPI_SETKEYBOARDSPEED_REGKEY, SPI_SETKEYBOARDSPEED_VALNAME, buf );
411
412     SystemParametersInfoA( SPI_GETKEYBOARDSPEED, 0, &speed, 0 );
413     eq( speed, curr_val, "SPI_{GET,SET}KEYBOARDSPEED", "%d" );
414
415     curr_val = 32;
416     SystemParametersInfoA( SPI_SETKEYBOARDSPEED, curr_val, 0,
417                           SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
418     curr_val = 31; /* max value */
419     test_change_message( SPI_SETKEYBOARDSPEED, "" );
420     sprintf( buf, "%d", curr_val );
421     test_reg_key( SPI_SETKEYBOARDSPEED_REGKEY, SPI_SETKEYBOARDSPEED_VALNAME, buf );
422
423     SystemParametersInfoA( SPI_GETKEYBOARDSPEED, 0, &speed, 0 );
424     eq( speed, curr_val, "SPI_{GET,SET}KEYBOARDSPEED", "%d");
425
426     SystemParametersInfoA( SPI_SETKEYBOARDSPEED, old_speed, 0, SPIF_UPDATEINIFILE );
427 }
428
429 static void test_SPI_ICONHORIZONTALSPACING( void )     /*     13 */
430 {
431     UINT old_spacing;
432     UINT spacing;
433     UINT curr_val;
434     char buf[10];
435
436     trace("testing SPI_ICONHORIZONTALSPACING\n");
437     /* default value: 75 */
438     SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, 0, &old_spacing, 0 );
439
440     curr_val = 101;
441     SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, curr_val, 0,
442                           SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
443     test_change_message( SPI_ICONHORIZONTALSPACING, "" );
444     sprintf( buf, "%d", curr_val );
445     test_reg_key( SPI_ICONHORIZONTALSPACING_REGKEY,
446                   SPI_ICONHORIZONTALSPACING_VALNAME, buf );
447
448     SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, 0, &spacing, 0 );
449     eq( spacing, curr_val, "ICONHORIZONTALSPACING", "%d");
450     eq( GetSystemMetrics( SM_CXICONSPACING ), curr_val, "SM_CXICONSPACING", "%d" );
451
452     curr_val = 10;
453     SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, curr_val, 0,
454                           SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
455     curr_val = 32;      /*min value*/
456     test_change_message( SPI_ICONHORIZONTALSPACING, "" );
457     sprintf( buf, "%d", curr_val );
458     test_reg_key( SPI_ICONHORIZONTALSPACING_REGKEY,
459                   SPI_ICONHORIZONTALSPACING_VALNAME, buf );
460
461     SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, 0, &spacing, 0 );
462     eq( spacing, curr_val, "ICONHORIZONTALSPACING", "%d" );
463     eq( GetSystemMetrics( SM_CXICONSPACING ), curr_val, "SM_CXICONSPACING", "%d" );
464
465     SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, old_spacing, 0,
466                           SPIF_UPDATEINIFILE );
467 }
468
469 static void test_SPI_SETSCREENSAVETIMEOUT( void )      /*     14 */
470 {
471     UINT old_timeout;
472     UINT timeout;
473     UINT curr_val;
474     char buf[10];
475
476     trace("testing SPI_{GET,SET}SCREENSAVETIMEOUT\n");
477     SystemParametersInfoA( SPI_GETSCREENSAVETIMEOUT, 0, &old_timeout, 0 );
478
479     curr_val = 0;
480     SystemParametersInfoA( SPI_SETSCREENSAVETIMEOUT, curr_val, 0,
481                            SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
482     test_change_message( SPI_SETSCREENSAVETIMEOUT, "" );
483     sprintf( buf, "%d", curr_val );
484     test_reg_key( SPI_SETSCREENSAVETIMEOUT_REGKEY,
485                   SPI_SETSCREENSAVETIMEOUT_VALNAME, buf );
486
487     SystemParametersInfoA( SPI_GETSCREENSAVETIMEOUT, 0, &timeout, 0 );
488     eq( timeout, curr_val, "SPI_{GET,SET}SCREENSAVETIMEOUT", "%d" );
489
490     curr_val = 50000;
491     SystemParametersInfoA( SPI_SETSCREENSAVETIMEOUT, curr_val, 0,
492                           SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
493     test_change_message( SPI_SETSCREENSAVETIMEOUT, "" );
494     sprintf( buf, "%d", curr_val );
495     test_reg_key( SPI_SETSCREENSAVETIMEOUT_REGKEY,
496                   SPI_SETSCREENSAVETIMEOUT_VALNAME, buf );
497
498     SystemParametersInfoA( SPI_GETSCREENSAVETIMEOUT, 0, &timeout, 0 );
499     eq( timeout, curr_val, "SPI_{GET,SET}SCREENSAVETIMEOUT", "%d" );
500
501     SystemParametersInfoA( SPI_SETSCREENSAVETIMEOUT, old_timeout, 0,
502                           SPIF_UPDATEINIFILE );
503 }
504
505 static void test_SPI_SETSCREENSAVEACTIVE( void )       /*     17 */
506 {
507     BOOL old_b;
508     BOOL b;
509     BOOL curr_val;
510
511     trace("testing SPI_{GET,SET}SCREENSAVEACTIVE\n");
512     SystemParametersInfoA( SPI_GETSCREENSAVEACTIVE, 0, &old_b, 0 );
513
514     curr_val = TRUE;
515     SystemParametersInfoA( SPI_SETSCREENSAVEACTIVE, curr_val, 0,
516                            SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
517     test_change_message( SPI_SETSCREENSAVEACTIVE, "" );
518     test_reg_key( SPI_SETSCREENSAVEACTIVE_REGKEY,
519                   SPI_SETSCREENSAVEACTIVE_VALNAME,
520                   curr_val ? "1" : "0" );
521
522     SystemParametersInfoA( SPI_GETSCREENSAVEACTIVE, 0, &b, 0 );
523     eq( b, curr_val, "SPI_{GET,SET}SCREENSAVEACTIVE", "%d" );
524
525     curr_val = FALSE;
526     SystemParametersInfoA( SPI_SETSCREENSAVEACTIVE, curr_val, 0,
527                           SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
528     test_change_message( SPI_SETSCREENSAVEACTIVE, "" );
529     test_reg_key( SPI_SETSCREENSAVEACTIVE_REGKEY,
530                   SPI_SETSCREENSAVEACTIVE_VALNAME,
531                   curr_val ? "1" : "0" );
532
533     SystemParametersInfoA( SPI_GETSCREENSAVEACTIVE, 0, &b, 0 );
534     eq( b, curr_val, "SPI_{GET,SET}SCREENSAVEACTIVE", "%d" );
535
536     SystemParametersInfoA( SPI_SETSCREENSAVEACTIVE, old_b, 0, SPIF_UPDATEINIFILE );
537 }
538
539 static void test_SPI_SETGRIDGRANULARITY( void )        /*     19 */
540 {
541     /* ??? */;
542 }
543
544 static void test_SPI_SETKEYBOARDDELAY( void )          /*     23 */
545 {
546     UINT old_delay;
547     UINT delay;
548     UINT curr_val;
549     char buf[10];
550
551     trace("testing SPI_{GET,SET}KEYBOARDDELAY\n");
552     SystemParametersInfoA( SPI_GETKEYBOARDDELAY, 0, &old_delay, 0 );
553
554     curr_val = 0;
555     SystemParametersInfoA( SPI_SETKEYBOARDDELAY, curr_val, 0,
556                            SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
557     test_change_message( SPI_SETKEYBOARDDELAY, "" );
558     sprintf( buf, "%d", curr_val );
559     test_reg_key( SPI_SETKEYBOARDDELAY_REGKEY,
560                   SPI_SETKEYBOARDDELAY_VALNAME, buf );
561
562     SystemParametersInfoA( SPI_GETKEYBOARDDELAY, 0, &delay, 0 );
563     eq( delay, curr_val, "SPI_{GET,SET}KEYBOARDDELAY", "%d" );
564
565     curr_val = 3;      /* max value */
566     SystemParametersInfoA( SPI_SETKEYBOARDDELAY, curr_val, 0,
567                           SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
568     test_change_message( SPI_SETKEYBOARDDELAY, "" );
569     sprintf( buf, "%d", curr_val );
570     test_reg_key( SPI_SETKEYBOARDDELAY_REGKEY,
571                   SPI_SETKEYBOARDDELAY_VALNAME, buf );
572
573     SystemParametersInfoA( SPI_GETKEYBOARDDELAY, 0, &delay, 0 );
574     eq( delay, curr_val, "SPI_{GET,SET}KEYBOARDDELAY", "%d" );
575
576     SystemParametersInfoA( SPI_SETKEYBOARDDELAY, old_delay, 0, SPIF_UPDATEINIFILE );
577 }
578
579 static void test_SPI_ICONVERTICALSPACING( void )       /*     24 */
580 {
581     UINT old_spacing;
582     UINT spacing;
583     UINT curr_val;
584     char buf[10];
585
586     trace("testing SPI_ICONVERTICALSPACING\n");
587     /* default value: 75 */
588     SystemParametersInfoA( SPI_ICONVERTICALSPACING, 0, &old_spacing, 0 );
589
590     curr_val = 101;
591     SystemParametersInfoA( SPI_ICONVERTICALSPACING, curr_val, 0,
592                           SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
593     test_change_message( SPI_ICONVERTICALSPACING, "" );
594     sprintf( buf, "%d", curr_val );
595     test_reg_key( SPI_ICONVERTICALSPACING_REGKEY,
596                   SPI_ICONVERTICALSPACING_VALNAME, buf );
597
598     SystemParametersInfoA( SPI_ICONVERTICALSPACING, 0, &spacing, 0 );
599     eq( spacing, curr_val, "ICONVERTICALSPACING", "%d" );
600     eq( GetSystemMetrics( SM_CYICONSPACING ), curr_val, "SM_CYICONSPACING", "%d" );
601
602     curr_val = 10;
603     SystemParametersInfoA( SPI_ICONVERTICALSPACING, curr_val, 0,
604                           SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
605     curr_val = 32;      /*min value*/
606     test_change_message( SPI_ICONVERTICALSPACING, "" );
607     sprintf( buf, "%d", curr_val );
608     test_reg_key( SPI_ICONVERTICALSPACING_REGKEY,
609                   SPI_ICONVERTICALSPACING_VALNAME, buf );
610
611     SystemParametersInfoA( SPI_ICONVERTICALSPACING, 0, &spacing, 0 );
612     eq( spacing, curr_val, "ICONVERTICALSPACING", "%d" );
613     eq( GetSystemMetrics( SM_CYICONSPACING ), curr_val, "SM_CYICONSPACING", "%d" );
614
615     SystemParametersInfoA( SPI_ICONVERTICALSPACING, old_spacing, 0,
616                           SPIF_UPDATEINIFILE );
617 }
618
619 static void test_SPI_SETICONTITLEWRAP( void )          /*     26 */
620 {
621     BOOL old_b;
622     BOOL b;
623     BOOL curr_val;
624
625     /* These tests hang when XFree86 4.0 for Windows is running (tested on
626      * WinNT, SP2, Cygwin/XFree 4.1.0. Skip the test when XFree86 is
627      * running.
628      */
629     if (!FindWindowA( NULL, "Cygwin/XFree86" ))
630     {
631         trace("testing SPI_{GET,SET}ICONTITLEWRAP\n");
632         SystemParametersInfoA( SPI_GETICONTITLEWRAP, 0, &old_b, 0 );
633
634         curr_val = TRUE;
635         SystemParametersInfoA( SPI_SETICONTITLEWRAP, curr_val, 0,
636                               SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
637         test_change_message( SPI_SETICONTITLEWRAP, "" );
638         test_reg_key( SPI_SETICONTITLEWRAP_REGKEY,
639                       SPI_SETICONTITLEWRAP_VALNAME,
640                       curr_val ? "1" : "0" );
641
642         SystemParametersInfoA( SPI_GETICONTITLEWRAP, 0, &b, 0 );
643         eq( b, curr_val, "SPI_{GET,SET}ICONTITLEWRAP", "%d" );
644
645         curr_val = FALSE;
646         SystemParametersInfoA( SPI_SETICONTITLEWRAP, curr_val, 0,
647                               SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
648         test_change_message( SPI_SETICONTITLEWRAP, "" );
649         test_reg_key( SPI_SETICONTITLEWRAP_REGKEY,
650                       SPI_SETICONTITLEWRAP_VALNAME,
651                       curr_val ? "1" : "0" );
652
653         SystemParametersInfoA( SPI_GETICONTITLEWRAP, 0, &b, 0 );
654         eq( b, curr_val, "SPI_{GET,SET}ICONTITLEWRAP", "%d" );
655
656         SystemParametersInfoA( SPI_SETICONTITLEWRAP, old_b, 0, SPIF_UPDATEINIFILE );
657     }
658 }
659
660 static void test_SPI_SETMENUDROPALIGNMENT( void )      /*     28 */
661 {
662     BOOL old_b;
663     BOOL b;
664     BOOL curr_val;
665
666     trace("testing SPI_{GET,SET}MENUDROPALIGNMENT\n");
667     SystemParametersInfoA( SPI_GETMENUDROPALIGNMENT, 0, &old_b, 0 );
668
669     curr_val = TRUE;
670     SystemParametersInfoA( SPI_SETMENUDROPALIGNMENT, curr_val, 0,
671                            SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
672     test_change_message( SPI_SETMENUDROPALIGNMENT, "" );
673     test_reg_key( SPI_SETMENUDROPALIGNMENT_REGKEY,
674                   SPI_SETMENUDROPALIGNMENT_VALNAME,
675                   curr_val ? "1" : "0" );
676
677     SystemParametersInfoA( SPI_GETMENUDROPALIGNMENT, 0, &b, 0 );
678     eq( b, curr_val, "SPI_{GET,SET}MENUDROPALIGNMENT", "%d" );
679     eq( GetSystemMetrics( SM_MENUDROPALIGNMENT ), curr_val, "SM_MENUDROPALIGNMENT", "%d" );
680
681     curr_val = FALSE;
682     SystemParametersInfoA( SPI_SETMENUDROPALIGNMENT, curr_val, 0,
683                           SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
684     test_change_message( SPI_SETMENUDROPALIGNMENT, "" );
685     test_reg_key( SPI_SETMENUDROPALIGNMENT_REGKEY,
686                   SPI_SETMENUDROPALIGNMENT_VALNAME,
687                   curr_val ? "1" : "0" );
688
689     SystemParametersInfoA( SPI_GETMENUDROPALIGNMENT, 0, &b, 0 );
690     eq( b, curr_val, "SPI_{GET,SET}MENUDROPALIGNMENT", "%d" );
691     eq( GetSystemMetrics( SM_MENUDROPALIGNMENT ), curr_val, "SM_MENUDROPALIGNMENT", "%d" );
692
693     SystemParametersInfoA( SPI_SETMENUDROPALIGNMENT, old_b, 0,
694                            SPIF_UPDATEINIFILE );
695 }
696
697 static void test_SPI_SETDOUBLECLKWIDTH( void )         /*     29 */
698 {
699     UINT old_width;
700     UINT curr_val;
701     char buf[10];
702
703     trace("testing SPI_SETDOUBLECLKWIDTH\n");
704     old_width = GetSystemMetrics( SM_CXDOUBLECLK );
705
706     curr_val = 0;
707     SystemParametersInfoA( SPI_SETDOUBLECLKWIDTH, curr_val, 0,
708                            SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
709     test_change_message( SPI_SETDOUBLECLKWIDTH, "" );
710     sprintf( buf, "%d", curr_val );
711     test_reg_key( SPI_SETDOUBLECLKWIDTH_REGKEY,
712                   SPI_SETDOUBLECLKWIDTH_VALNAME, buf );
713     eq( GetSystemMetrics( SM_CXDOUBLECLK ), curr_val, "SM_CXDOUBLECLK", "%d" );
714
715     curr_val = 10000;
716     SystemParametersInfoA( SPI_SETDOUBLECLKWIDTH, curr_val, 0,
717                            SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
718     test_change_message( SPI_SETDOUBLECLKWIDTH, "" );
719     sprintf( buf, "%d", curr_val );
720     test_reg_key( SPI_SETDOUBLECLKWIDTH_REGKEY,
721                   SPI_SETDOUBLECLKWIDTH_VALNAME, buf );
722     eq( GetSystemMetrics( SM_CXDOUBLECLK ), curr_val, "SM_CXDOUBLECLK", "%d" );
723
724     SystemParametersInfoA( SPI_SETDOUBLECLKWIDTH, old_width, 0,
725                           SPIF_UPDATEINIFILE );
726 }
727
728 static void test_SPI_SETDOUBLECLKHEIGHT( void )        /*     30 */
729 {
730     UINT old_height;
731     UINT curr_val;
732     char buf[10];
733
734     trace("testing SPI_SETDOUBLECLKHEIGHT\n");
735     old_height = GetSystemMetrics( SM_CYDOUBLECLK );
736
737     curr_val = 0;
738     SystemParametersInfoA( SPI_SETDOUBLECLKHEIGHT, curr_val, 0,
739                            SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
740     test_change_message( SPI_SETDOUBLECLKHEIGHT, "" );
741     sprintf( buf, "%d", curr_val );
742     test_reg_key( SPI_SETDOUBLECLKHEIGHT_REGKEY,
743                   SPI_SETDOUBLECLKHEIGHT_VALNAME, buf );
744     eq( GetSystemMetrics( SM_CYDOUBLECLK ), curr_val, "SM_CYDOUBLECLK", "%d" );
745
746     curr_val = 10000;
747     SystemParametersInfoA( SPI_SETDOUBLECLKHEIGHT, curr_val, 0,
748                            SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
749     test_change_message( SPI_SETDOUBLECLKHEIGHT, "" );
750     sprintf( buf, "%d", curr_val );
751     test_reg_key( SPI_SETDOUBLECLKHEIGHT_REGKEY,
752                   SPI_SETDOUBLECLKHEIGHT_VALNAME, buf );
753     eq( GetSystemMetrics( SM_CYDOUBLECLK ), curr_val, "SM_CYDOUBLECLK", "%d" );
754
755     SystemParametersInfoA( SPI_SETDOUBLECLKHEIGHT, old_height, 0,
756                           SPIF_UPDATEINIFILE );
757 }
758
759 static void test_SPI_SETDOUBLECLICKTIME( void )        /*     32 */
760 {
761     UINT curr_val;
762     UINT saved_val;
763     UINT old_time;
764     char buf[10];
765
766     trace("testing SPI_SETDOUBLECLICKTIME\n");
767     old_time = GetDoubleClickTime();
768
769     curr_val = 0;
770     SystemParametersInfoA( SPI_SETDOUBLECLICKTIME, curr_val, 0,
771                            SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
772     test_change_message( SPI_SETDOUBLECLICKTIME, "" );
773     sprintf( buf, "%d", curr_val );
774     test_reg_key( SPI_SETDOUBLECLICKTIME_REGKEY,
775                   SPI_SETDOUBLECLICKTIME_VALNAME, buf );
776     curr_val = 500; /* used value for 0 */
777     eq( GetDoubleClickTime(), curr_val, "GetDoubleClickTime", "%d" );
778
779     curr_val = 1000;
780     SystemParametersInfoA( SPI_SETDOUBLECLICKTIME, curr_val, 0,
781                           SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
782     test_change_message( SPI_SETDOUBLECLICKTIME, "" );
783     sprintf( buf, "%d", curr_val );
784     test_reg_key( SPI_SETDOUBLECLICKTIME_REGKEY,
785                   SPI_SETDOUBLECLICKTIME_VALNAME, buf );
786     eq( GetDoubleClickTime(), curr_val, "GetDoubleClickTime", "%d" );
787
788     saved_val = curr_val;
789
790     curr_val = 0;
791     SetDoubleClickTime( curr_val );
792     sprintf( buf, "%d", saved_val );
793     test_reg_key( SPI_SETDOUBLECLICKTIME_REGKEY,
794                   SPI_SETDOUBLECLICKTIME_VALNAME, buf );
795     curr_val = 500; /* used value for 0 */
796     eq( GetDoubleClickTime(), curr_val, "GetDoubleClickTime", "%d" );
797
798     curr_val = 1000;
799     SetDoubleClickTime( curr_val );
800     sprintf( buf, "%d", saved_val );
801     test_reg_key( SPI_SETDOUBLECLICKTIME_REGKEY,
802                   SPI_SETDOUBLECLICKTIME_VALNAME, buf );
803     eq( GetDoubleClickTime(), curr_val, "GetDoubleClickTime", "%d" );
804
805     SystemParametersInfoA(SPI_SETDOUBLECLICKTIME, old_time, 0, SPIF_UPDATEINIFILE);
806 }
807
808 static void test_SPI_SETMOUSEBUTTONSWAP( void )        /*     33 */
809 {
810     BOOL old_b;
811     BOOL curr_val;
812
813     trace("testing SPI_SETMOUSEBUTTONSWAP\n");
814     old_b = GetSystemMetrics( SM_SWAPBUTTON );
815
816     curr_val = TRUE;
817     SystemParametersInfoA( SPI_SETMOUSEBUTTONSWAP, curr_val, 0,
818                            SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
819     test_change_message( SPI_SETMOUSEBUTTONSWAP, "" );
820     test_reg_key( SPI_SETMOUSEBUTTONSWAP_REGKEY,
821                   SPI_SETMOUSEBUTTONSWAP_VALNAME,
822                   curr_val ? "1" : "0" );
823     eq( GetSystemMetrics( SM_SWAPBUTTON ), curr_val, "SM_SWAPBUTTON", "%d" );
824
825     curr_val = FALSE;
826     SystemParametersInfoA( SPI_SETMOUSEBUTTONSWAP, curr_val, 0,
827                           SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
828     test_change_message( SPI_SETMOUSEBUTTONSWAP, "" );
829     test_reg_key( SPI_SETMOUSEBUTTONSWAP_REGKEY,
830                   SPI_SETMOUSEBUTTONSWAP_VALNAME,
831                   curr_val ? "1" : "0" );
832     eq( GetSystemMetrics( SM_SWAPBUTTON ), curr_val, "SM_SWAPBUTTON", "%d" );
833
834     SystemParametersInfoA( SPI_SETMOUSEBUTTONSWAP, old_b, 0,
835                            SPIF_UPDATEINIFILE );
836 }
837
838 static void test_SPI_SETFASTTASKSWITCH( void )         /*     36 */
839 {
840     /* Temporarily commented out.
841     BOOL old_b;
842     BOOL b;
843     BOOL res;
844     BOOL curr_val;
845
846     SystemParametersInfoA( SPI_GETFASTTASKSWITCH, 0, &old_b, 0 );
847
848     curr_val = TRUE;
849     res = SystemParametersInfoA( SPI_SETFASTTASKSWITCH, curr_val, 0,
850                                  SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
851     ok( !res, "Must not set" );
852
853     SystemParametersInfoA( SPI_GETFASTTASKSWITCH, 0, &b, 0 );
854     ok( b, "retrieved value is the same as set" );
855
856     curr_val = FALSE;
857     res = SystemParametersInfoA( SPI_SETFASTTASKSWITCH, curr_val, 0,
858                                  SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
859     ok( !res, "Must not set" );
860
861     SystemParametersInfoA( SPI_GETFASTTASKSWITCH, 0, &b, 0 );
862
863     ok( b, "retrieved value is the same as set" );
864
865     SystemParametersInfoA( SPI_SETFASTTASKSWITCH, old_b, 0,
866                            SPIF_UPDATEINIFILE );
867     */
868 }
869
870 static void test_SPI_SETDRAGFULLWINDOWS( void )        /*     37 */
871 {
872     BOOL old_b;
873     BOOL b;
874     BOOL curr_val;
875
876     trace("testing SPI_{GET,SET}DRAGFULLWINDOWS\n");
877     SystemParametersInfoA( SPI_GETDRAGFULLWINDOWS, 0, &old_b, 0 );
878
879     curr_val = TRUE;
880     SystemParametersInfoA( SPI_SETDRAGFULLWINDOWS, curr_val, 0,
881                            SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
882     test_change_message( SPI_SETDRAGFULLWINDOWS, "" );
883     test_reg_key( SPI_SETDRAGFULLWINDOWS_REGKEY,
884                   SPI_SETDRAGFULLWINDOWS_VALNAME,
885                   curr_val ? "1" : "0" );
886
887     SystemParametersInfoA( SPI_GETDRAGFULLWINDOWS, 0, &b, 0 );
888     eq( b, curr_val, "SPI_{GET,SET}DRAGFULLWINDOWS", "%d" );
889
890     curr_val = FALSE;
891     SystemParametersInfoA( SPI_SETDRAGFULLWINDOWS, curr_val, 0,
892                           SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
893     test_change_message( SPI_SETDRAGFULLWINDOWS, "" );
894     test_reg_key( SPI_SETDRAGFULLWINDOWS_REGKEY,
895                   SPI_SETDRAGFULLWINDOWS_VALNAME,
896                   curr_val ? "1" : "0" );
897
898     SystemParametersInfoA( SPI_GETDRAGFULLWINDOWS, 0, &b, 0 );
899     eq( b, curr_val, "SPI_{GET,SET}DRAGFULLWINDOWS", "%d" );
900
901     SystemParametersInfoA( SPI_SETDRAGFULLWINDOWS, old_b, 0, SPIF_UPDATEINIFILE );
902 }
903
904 static void test_SPI_SETWORKAREA( void )               /*     47 */
905 {
906     /* default - 0,0,1152, 864 */
907     RECT old_area;
908     RECT area;
909     RECT curr_val;
910
911     trace("testing SPI_{GET,SET}WORKAREA\n");
912     SystemParametersInfoA(SPI_GETWORKAREA, 0, &old_area, 0);
913
914     curr_val.left = 1;
915     curr_val.top = 1;
916     curr_val.right = 800;
917     curr_val.bottom = 600;
918     SystemParametersInfoA( SPI_SETWORKAREA, 0, &curr_val,
919                            SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
920     test_change_message( SPI_SETWORKAREA, "" );
921     SystemParametersInfoA( SPI_GETWORKAREA, 0, &area, 0 );
922     eq( area.left,   curr_val.left,   "left",   "%d" );
923     eq( area.top,    curr_val.top,    "top",    "%d" );
924     eq( area.right,  curr_val.right,  "right",  "%d" );
925     eq( area.bottom, curr_val.bottom, "bottom", "%d" );
926
927     curr_val.left = 2;
928     curr_val.top = 2;
929     curr_val.right = 801;
930     curr_val.bottom = 601;
931     SystemParametersInfoA( SPI_SETWORKAREA, 0, &curr_val,
932                           SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
933     test_change_message( SPI_SETWORKAREA, "" );
934     SystemParametersInfoA( SPI_GETWORKAREA, 0, &area, 0 );
935     eq( area.left,   curr_val.left,   "left",   "%d" );
936     eq( area.top,    curr_val.top,    "top",    "%d" );
937     eq( area.right,  curr_val.right,  "right",  "%d" );
938     eq( area.bottom, curr_val.bottom, "bottom", "%d" );
939
940     SystemParametersInfoA(SPI_SETWORKAREA, 0, &old_area, SPIF_UPDATEINIFILE);
941 }
942
943 static void test_SPI_SETSHOWSOUNDS( void )             /*     57 */
944 {
945     BOOL old_b;
946     BOOL b;
947     BOOL curr_val;
948
949     trace("testing SPI_{GET,SET}SHOWSOUNDS\n");
950     SystemParametersInfoA( SPI_GETSHOWSOUNDS, 0, &old_b, 0 );
951
952     curr_val = TRUE;
953     SystemParametersInfoA( SPI_SETSHOWSOUNDS, curr_val, 0,
954                            SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
955     test_change_message( SPI_SETSHOWSOUNDS, "" );
956     test_reg_key( SPI_SETSHOWSOUNDS_REGKEY,
957                   SPI_SETSHOWSOUNDS_VALNAME,
958                   curr_val ? "1" : "0" );
959
960     SystemParametersInfoA( SPI_GETSHOWSOUNDS, 0, &b, 0 );
961     eq( b, curr_val, "SPI_GETSHOWSOUNDS", "%d" );
962     eq( GetSystemMetrics( SM_SHOWSOUNDS ), curr_val, "SM_SHOWSOUNDS", "%d" );
963
964     curr_val = FALSE;
965     SystemParametersInfoA( SPI_SETSHOWSOUNDS, curr_val, 0,
966                           SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
967     test_change_message( SPI_SETSHOWSOUNDS, "" );
968     test_reg_key( SPI_SETSHOWSOUNDS_REGKEY,
969                   SPI_SETSHOWSOUNDS_VALNAME,
970                   curr_val ? "1" : "0" );
971
972     SystemParametersInfoA( SPI_GETSHOWSOUNDS, 0, &b, 0 );
973     eq( b, curr_val, "SPI_GETSHOWSOUNDS", "%d" );
974     eq( GetSystemMetrics( SM_SHOWSOUNDS ), curr_val, "SM_SHOWSOUNDS", "%d" );
975
976     SystemParametersInfoA( SPI_SETSHOWSOUNDS, old_b, 0, SPIF_UPDATEINIFILE );
977 }
978
979 static void test_SPI_SETKEYBOARDPREF( void )           /*     69 */
980 {
981     /* TODO!!! - don't have version of Windows which has this */
982 }
983
984 static void test_SPI_SETSCREENREADER( void )           /*     71 */
985 {
986     /* TODO!!! - don't have version of Windows which has this */
987 }
988
989 static void test_SPI_SETWALLPAPER( void )              /*   115 */
990 {
991     char oldval[260];
992     char newval[260];
993     trace("testing SPI_{GET,SET}DESKWALLPAPER\n");
994
995     SystemParametersInfoA(SPI_GETDESKWALLPAPER, 260, oldval, 0);
996     test_reg_key(SPI_SETDESKWALLPAPER_REGKEY, SPI_SETDESKWALLPAPER_VALNAME, oldval);
997
998     strcpy(newval, "");
999     SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, newval, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
1000     test_change_message(SPI_SETDESKWALLPAPER, "");
1001
1002     SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, oldval, SPIF_UPDATEINIFILE);
1003 }
1004
1005 /*
1006  * Registry entries for the system parameters.
1007  * Names are created by 'SET' flags names.
1008  * We assume that corresponding 'GET' entries use the same registry keys.
1009  */
1010 static DWORD WINAPI SysParamsThreadFunc( LPVOID lpParam )
1011 {
1012     test_SPI_SETBEEP();                         /*      1 */
1013     test_SPI_SETMOUSE();                        /*      4 */
1014     test_SPI_SETBORDER();                       /*      6 */
1015     test_SPI_SETKEYBOARDSPEED();                /*     10 */
1016     test_SPI_ICONHORIZONTALSPACING();           /*     13 */
1017     test_SPI_SETSCREENSAVETIMEOUT();            /*     14 */
1018     test_SPI_SETSCREENSAVEACTIVE();             /*     17 */
1019     test_SPI_SETGRIDGRANULARITY();              /*     19 */
1020     test_SPI_SETKEYBOARDDELAY();                /*     23 */
1021     test_SPI_ICONVERTICALSPACING();             /*     24 */
1022     test_SPI_SETICONTITLEWRAP();                /*     26 */
1023     test_SPI_SETMENUDROPALIGNMENT();            /*     28 */
1024     test_SPI_SETDOUBLECLKWIDTH();               /*     29 */
1025     test_SPI_SETDOUBLECLKHEIGHT();              /*     30 */
1026     test_SPI_SETDOUBLECLICKTIME();              /*     32 */
1027     test_SPI_SETMOUSEBUTTONSWAP();              /*     33 */
1028     test_SPI_SETFASTTASKSWITCH();               /*     36 */
1029     test_SPI_SETDRAGFULLWINDOWS();              /*     37 */
1030     test_SPI_SETWORKAREA();                     /*     47 */
1031     test_SPI_SETSHOWSOUNDS();                   /*     57 */
1032     test_SPI_SETKEYBOARDPREF();                 /*     69 */
1033     test_SPI_SETSCREENREADER();                 /*     71 */
1034     test_SPI_SETWALLPAPER();                    /*    115 */
1035     SendMessageA( ghTestWnd, WM_DESTROY, 0, 0 );
1036     return 0;
1037 }
1038
1039 START_TEST(sysparams)
1040 {
1041     WNDCLASSA wc;
1042     MSG msg;
1043     HANDLE hThread;
1044     DWORD dwThreadId;
1045     HANDLE hInstance = GetModuleHandleA( NULL );
1046
1047     change_counter = 0;
1048     change_last_param = 0;
1049     strcpy( change_reg_section, "" );
1050
1051     wc.lpszClassName = "SysParamsTestClass";
1052     wc.lpfnWndProc = SysParamsTestWndProc;
1053     wc.style = CS_OWNDC | CS_VREDRAW | CS_HREDRAW;
1054     wc.hInstance = hInstance;
1055     wc.hIcon = LoadIconA( 0, IDI_APPLICATIONA );
1056     wc.hCursor = LoadCursorA( 0, IDC_ARROWA );
1057     wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1 );
1058     wc.lpszMenuName = 0;
1059     wc.cbClsExtra = 0;
1060     wc.cbWndExtra = 0;
1061     RegisterClassA( &wc );
1062
1063     ghTestWnd = CreateWindowA( "SysParamsTestClass", "Test System Parameters Application",
1064                                WS_OVERLAPPEDWINDOW, 0, 0, 100, 100, 0, 0, hInstance, NULL );
1065
1066     hThread = CreateThread( NULL, 0, SysParamsThreadFunc, 0, 0, &dwThreadId );
1067     assert( hThread );
1068     CloseHandle( hThread );
1069
1070     while( GetMessageA( &msg, 0, 0, 0 )) {
1071         TranslateMessage( &msg );
1072         DispatchMessageA( &msg );
1073     }
1074 }