Commit 7e6b3259 authored by Rein Klazes's avatar Rein Klazes Committed by Alexandre Julliard

Re-enable SPI_{GET,SET}BORDER tests and fix the bugs that caused them

to be disabled. Add tests that show that the border value manipulated by SPI_{GET,SET}BORDER is completely the same as with SPI_{GET,SET}NONCLIENTMETRICS. Fix a few signed/unsigned warnings in unrelated tests from the same source file. Made the tests pass on wine.
parent 5cd09929
...@@ -922,7 +922,8 @@ static void load_nonclient_metrics(void) ...@@ -922,7 +922,8 @@ static void load_nonclient_metrics(void)
0, KEY_QUERY_VALUE, &hkey) != ERROR_SUCCESS) hkey = 0; 0, KEY_QUERY_VALUE, &hkey) != ERROR_SUCCESS) hkey = 0;
/* initialize geometry entries */ /* initialize geometry entries */
nonclient_metrics.iBorderWidth = 1; nonclient_metrics.iBorderWidth = get_reg_metric(hkey, METRICS_BORDERWIDTH_VALNAME, 1);
if( nonclient_metrics.iBorderWidth < 1) nonclient_metrics.iBorderWidth = 1;
nonclient_metrics.iScrollWidth = get_reg_metric(hkey, METRICS_SCROLLWIDTH_VALNAME, 16); nonclient_metrics.iScrollWidth = get_reg_metric(hkey, METRICS_SCROLLWIDTH_VALNAME, 16);
nonclient_metrics.iScrollHeight = nonclient_metrics.iScrollWidth; nonclient_metrics.iScrollHeight = nonclient_metrics.iScrollWidth;
...@@ -1124,9 +1125,12 @@ BOOL WINAPI SystemParametersInfoW( UINT uiAction, UINT uiParam, ...@@ -1124,9 +1125,12 @@ BOOL WINAPI SystemParametersInfoW( UINT uiAction, UINT uiParam,
SPI_SETBORDER_REGKEY, SPI_SETBORDER_REGKEY,
SPI_SETBORDER_VALNAME, SPI_SETBORDER_VALNAME,
&border, pvParam ); &border, pvParam );
if( *(INT*)pvParam < 1) *(INT*)pvParam = 1;
break; break;
case SPI_SETBORDER: case SPI_SETBORDER:
nonclient_metrics.iBorderWidth = uiParam > 0 ? uiParam : 1;
/* raw value goes to registry */
ret = set_uint_param( SPI_SETBORDER_IDX, ret = set_uint_param( SPI_SETBORDER_IDX,
SPI_SETBORDER_REGKEY, SPI_SETBORDER_REGKEY,
SPI_SETBORDER_VALNAME, SPI_SETBORDER_VALNAME,
...@@ -1413,6 +1417,13 @@ BOOL WINAPI SystemParametersInfoW( UINT uiAction, UINT uiParam, ...@@ -1413,6 +1417,13 @@ BOOL WINAPI SystemParametersInfoW( UINT uiAction, UINT uiParam,
if (lpnm && lpnm->cbSize == sizeof(NONCLIENTMETRICSW)) if (lpnm && lpnm->cbSize == sizeof(NONCLIENTMETRICSW))
{ {
/* FIXME: there are likely a few more parameters to save here */
set_uint_param( SPI_SETBORDER_IDX,
SPI_SETBORDER_REGKEY,
SPI_SETBORDER_VALNAME,
&border,
lpnm->iBorderWidth, fWinIni );
if( lpnm->iBorderWidth < 1) lpnm->iBorderWidth = 1;
memcpy( &nonclient_metrics, lpnm, sizeof(nonclient_metrics) ); memcpy( &nonclient_metrics, lpnm, sizeof(nonclient_metrics) );
spi_loaded[SPI_NONCLIENTMETRICS_IDX] = TRUE; spi_loaded[SPI_NONCLIENTMETRICS_IDX] = TRUE;
} }
...@@ -2345,11 +2356,11 @@ INT WINAPI GetSystemMetrics( INT index ) ...@@ -2345,11 +2356,11 @@ INT WINAPI GetSystemMetrics( INT index )
if (!spi_loaded[SPI_NONCLIENTMETRICS_IDX]) load_nonclient_metrics(); if (!spi_loaded[SPI_NONCLIENTMETRICS_IDX]) load_nonclient_metrics();
return nonclient_metrics.iCaptionHeight; return nonclient_metrics.iCaptionHeight;
case SM_CXFRAME: case SM_CXFRAME:
SystemParametersInfoW( SPI_GETBORDER, 0, &ret, 0 ); if (!spi_loaded[SPI_NONCLIENTMETRICS_IDX]) load_nonclient_metrics();
return GetSystemMetrics(SM_CXDLGFRAME) + ret; return GetSystemMetrics(SM_CXDLGFRAME) + nonclient_metrics.iBorderWidth;
case SM_CYFRAME: case SM_CYFRAME:
SystemParametersInfoW( SPI_GETBORDER, 0, &ret, 0 ); if (!spi_loaded[SPI_NONCLIENTMETRICS_IDX]) load_nonclient_metrics();
return GetSystemMetrics(SM_CYDLGFRAME) + ret; return GetSystemMetrics(SM_CXDLGFRAME) + nonclient_metrics.iBorderWidth;
case SM_CXMINTRACK: case SM_CXMINTRACK:
return GetSystemMetrics(SM_CXMIN); return GetSystemMetrics(SM_CXMIN);
case SM_CYMINTRACK: case SM_CYMINTRACK:
......
...@@ -124,6 +124,12 @@ static LRESULT CALLBACK SysParamsTestWndProc( HWND hWnd, UINT msg, WPARAM wParam ...@@ -124,6 +124,12 @@ static LRESULT CALLBACK SysParamsTestWndProc( HWND hWnd, UINT msg, WPARAM wParam
case WM_SETTINGCHANGE: case WM_SETTINGCHANGE:
if (change_counter>0) { if (change_counter>0) {
/* ignore these messages caused by resizing of toolbars */
if( wParam == SPI_SETWORKAREA) break;
if( change_last_param == SPI_SETWORKAREA) {
change_last_param = wParam;
break;
}
ok(0,"too many changes counter=%d last change=%d\n", ok(0,"too many changes counter=%d last change=%d\n",
change_counter,change_last_param); change_counter,change_last_param);
} }
...@@ -497,26 +503,63 @@ static void test_SPI_SETMOUSE( void ) /* 4 */ ...@@ -497,26 +503,63 @@ static void test_SPI_SETMOUSE( void ) /* 4 */
ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError()); ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
} }
#if 0 /* get a metric from the registry. If the value is negative
static void test_setborder(UINT curr_val) * it is assumed to be in twips and converted to pixels */
static UINT metricfromreg( char *keyname, char *valname, int dpi)
{
HKEY hkey;
char buf[64];
DWORD ret;
DWORD size, type;
int value;
RegOpenKeyA( HKEY_CURRENT_USER, keyname, &hkey );
size = sizeof(buf);
ret=RegQueryValueExA( hkey, valname, NULL, &type, (LPBYTE)buf, &size );
RegCloseKey( hkey );
if( ret != ERROR_SUCCESS) return -1;
value = atoi( buf);
if( value < 0)
value = ( -value * dpi + 720) / 1440;
return value;
}
static void test_setborder(UINT curr_val, int usesetborder, int dpi)
{ {
BOOL rc; BOOL rc;
UINT border; UINT border, regval;
INT frame; INT frame;
char buf[10]; NONCLIENTMETRICSA ncm;
ncm.cbSize = sizeof( ncm);
rc=SystemParametersInfo( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0);
ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
if( usesetborder) {
rc=SystemParametersInfoA( SPI_SETBORDER, curr_val, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE ); rc=SystemParametersInfoA( SPI_SETBORDER, curr_val, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError()); ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
test_change_message( SPI_SETBORDER, 1 ); test_change_message( SPI_SETBORDER, 1 );
sprintf( buf, "%d", curr_val ); } else { /* set non client metrics */
test_reg_key( SPI_SETBORDER_REGKEY, SPI_SETBORDER_VALNAME, buf ); ncm.iBorderWidth = curr_val;
rc=SystemParametersInfoA( SPI_SETNONCLIENTMETRICS, 0, &ncm, SPIF_UPDATEINIFILE|
if (curr_val == 0) SPIF_SENDCHANGE);
curr_val = 1; ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
test_change_message( SPI_SETNONCLIENTMETRICS, 1 );
}
if( curr_val) { /* skip if 0, some windows versions return 0 others 1 */
regval = metricfromreg( SPI_SETBORDER_REGKEY, SPI_SETBORDER_VALNAME, dpi);
ok( regval==curr_val, "wrong value in registry %d, epected %d\n", regval, curr_val);
}
/* minimum border width is 1 */
if (curr_val == 0) curr_val = 1;
/* should be the same as the non client metrics */
rc=SystemParametersInfo( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0);
ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
eq( (UINT)ncm.iBorderWidth, curr_val, "NonClientMetric.iBorderWidth", "%d");
/* and from SPI_GETBORDER */
rc=SystemParametersInfoA( SPI_GETBORDER, 0, &border, 0 ); rc=SystemParametersInfoA( SPI_GETBORDER, 0, &border, 0 );
ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError()); ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
eq( border, curr_val, "SPI_{GET,SET}BORDER", "%d"); eq( border, curr_val, "SPI_{GET,SET}BORDER", "%d");
/* test some SystemMetrics */
frame = curr_val + GetSystemMetrics( SM_CXDLGFRAME ); frame = curr_val + GetSystemMetrics( SM_CXDLGFRAME );
eq( frame, GetSystemMetrics( SM_CXFRAME ), "SM_CXFRAME", "%d" ); eq( frame, GetSystemMetrics( SM_CXFRAME ), "SM_CXFRAME", "%d" );
eq( frame, GetSystemMetrics( SM_CYFRAME ), "SM_CYFRAME", "%d" ); eq( frame, GetSystemMetrics( SM_CYFRAME ), "SM_CYFRAME", "%d" );
...@@ -528,6 +571,14 @@ static void test_SPI_SETBORDER( void ) /* 6 */ ...@@ -528,6 +571,14 @@ static void test_SPI_SETBORDER( void ) /* 6 */
{ {
BOOL rc; BOOL rc;
UINT old_border; UINT old_border;
HDC hdc;
int dpi;
int iswin9x;
/* The SPI_SETBORDER seems to be buggy on Win9x/ME (looks like you need to
* do it twice to make the intended change). So skip parts of the tests on
* those platforms */
iswin9x = GetVersion() & 0x80000000;
/* These tests hang when XFree86 4.0 for Windows is running (tested on /* These tests hang when XFree86 4.0 for Windows is running (tested on
* WinNT, SP2, Cygwin/XFree 4.1.0. Skip the test when XFree86 is * WinNT, SP2, Cygwin/XFree 4.1.0. Skip the test when XFree86 is
...@@ -537,24 +588,31 @@ static void test_SPI_SETBORDER( void ) /* 6 */ ...@@ -537,24 +588,31 @@ static void test_SPI_SETBORDER( void ) /* 6 */
return; return;
trace("testing SPI_{GET,SET}BORDER\n"); trace("testing SPI_{GET,SET}BORDER\n");
hdc = GetDC(0);
dpi = GetDeviceCaps( hdc, LOGPIXELSY);
ReleaseDC( 0, hdc);
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
rc=SystemParametersInfoA( SPI_GETBORDER, 0, &old_border, 0 ); rc=SystemParametersInfoA( SPI_GETBORDER, 0, &old_border, 0 );
if (!test_error_msg(rc,"SPI_{GET,SET}BORDER")) if (!test_error_msg(rc,"SPI_{GET,SET}BORDER"))
return; return;
test_setborder(1);
test_setborder(0);
test_setborder(7);
test_setborder(20);
/* This will restore sane values if the test hang previous run. */ /* This will restore sane values if the test hang previous run. */
if ( old_border == 7 || old_border == 20 ) if ( old_border == 7 || old_border == 20 )
old_border = -15; old_border = 1;
rc=SystemParametersInfoA( SPI_SETBORDER, old_border, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE ); if( !iswin9x) {
ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError()); test_setborder(1, 1, dpi);
test_setborder(0, 1, dpi);
test_setborder(7, 1, dpi);
test_setborder(20, 1, dpi);
}
test_setborder(1, 0, dpi);
test_setborder(0, 0, dpi);
test_setborder(7, 0, dpi);
test_setborder(20, 0, dpi);
/* this test should reset the old value on all platforms */
test_setborder(old_border, 0, dpi);
} }
#endif
static void test_SPI_SETKEYBOARDSPEED( void ) /* 10 */ static void test_SPI_SETKEYBOARDSPEED( void ) /* 10 */
{ {
...@@ -1022,7 +1080,7 @@ static void test_SPI_SETMOUSEBUTTONSWAP( void ) /* 33 */ ...@@ -1022,7 +1080,7 @@ static void test_SPI_SETMOUSEBUTTONSWAP( void ) /* 33 */
rc=SwapMouseButton((BOOL)vals[i^1]); rc=SwapMouseButton((BOOL)vals[i^1]);
eq( GetSystemMetrics( SM_SWAPBUTTON ), (int)vals[i^1], eq( GetSystemMetrics( SM_SWAPBUTTON ), (int)vals[i^1],
"SwapMouseButton", "%d" ); "SwapMouseButton", "%d" );
ok( rc==vals[i], "SwapMouseButton does not return previous state (really %d)\n", rc ); ok( rc==(BOOL)vals[i], "SwapMouseButton does not return previous state (really %d)\n", rc );
} }
rc=SystemParametersInfoA( SPI_SETMOUSEBUTTONSWAP, old_b, 0, rc=SystemParametersInfoA( SPI_SETMOUSEBUTTONSWAP, old_b, 0,
...@@ -1318,7 +1376,7 @@ static void test_SPI_SETKEYBOARDPREF( void ) /* 69 */ ...@@ -1318,7 +1376,7 @@ static void test_SPI_SETKEYBOARDPREF( void ) /* 69 */
rc=SystemParametersInfoA( SPI_GETKEYBOARDPREF, 0, &v, 0 ); rc=SystemParametersInfoA( SPI_GETKEYBOARDPREF, 0, &v, 0 );
ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError()); ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
eq( v, vals[i], "SPI_GETKEYBOARDPREF", "%d" ); eq( v, (BOOL)vals[i], "SPI_GETKEYBOARDPREF", "%d" );
} }
rc=SystemParametersInfoA( SPI_SETKEYBOARDPREF, old_b, 0, SPIF_UPDATEINIFILE ); rc=SystemParametersInfoA( SPI_SETKEYBOARDPREF, old_b, 0, SPIF_UPDATEINIFILE );
...@@ -1352,7 +1410,7 @@ static void test_SPI_SETSCREENREADER( void ) /* 71 */ ...@@ -1352,7 +1410,7 @@ static void test_SPI_SETSCREENREADER( void ) /* 71 */
rc=SystemParametersInfoA( SPI_GETSCREENREADER, 0, &v, 0 ); rc=SystemParametersInfoA( SPI_GETSCREENREADER, 0, &v, 0 );
ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError()); ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
eq( v, vals[i], "SPI_GETSCREENREADER", "%d" ); eq( v, (BOOL)vals[i], "SPI_GETSCREENREADER", "%d" );
} }
rc=SystemParametersInfoA( SPI_SETSCREENREADER, old_b, 0, SPIF_UPDATEINIFILE ); rc=SystemParametersInfoA( SPI_SETSCREENREADER, old_b, 0, SPIF_UPDATEINIFILE );
...@@ -1659,8 +1717,7 @@ static DWORD WINAPI SysParamsThreadFunc( LPVOID lpParam ) ...@@ -1659,8 +1717,7 @@ static DWORD WINAPI SysParamsThreadFunc( LPVOID lpParam )
{ {
test_SPI_SETBEEP(); /* 1 */ test_SPI_SETBEEP(); /* 1 */
test_SPI_SETMOUSE(); /* 4 */ test_SPI_SETMOUSE(); /* 4 */
/* Messes up systems settings on Win9x */ test_SPI_SETBORDER(); /* 6 */
/*test_SPI_SETBORDER();*/ /* 6 */
test_SPI_SETKEYBOARDSPEED(); /* 10 */ test_SPI_SETKEYBOARDSPEED(); /* 10 */
test_SPI_ICONHORIZONTALSPACING(); /* 13 */ test_SPI_ICONHORIZONTALSPACING(); /* 13 */
test_SPI_SETSCREENSAVETIMEOUT(); /* 14 */ test_SPI_SETSCREENSAVETIMEOUT(); /* 14 */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment