Commit 7e2f4421 authored by Alexandre Julliard's avatar Alexandre Julliard

user32/tests: Fix some sysparams results on recent Windows.

parent 52583589
......@@ -167,7 +167,6 @@ static DWORD WINAPI SysParamsThreadFunc( LPVOID lpParam );
static LRESULT CALLBACK SysParamsTestWndProc( HWND hWnd, UINT msg, WPARAM wParam,
LPARAM lParam );
static int change_counter;
static int change_setworkarea_param, change_iconverticalspacing_param;
static int change_last_param;
static int last_bpp;
static BOOL displaychange_ok = FALSE, displaychange_test_active = FALSE;
......@@ -223,34 +222,23 @@ static LRESULT CALLBACK SysParamsTestWndProc( HWND hWnd, UINT msg, WPARAM wParam
break;
case WM_SETTINGCHANGE:
if (change_counter>0) {
/* ignore these messages caused by resizing of toolbars */
if( wParam == SPI_SETWORKAREA){
change_setworkarea_param = 1;
break;
} else if( wParam == SPI_ICONVERTICALSPACING) {
change_iconverticalspacing_param = 1;
break;
} else if( displaychange_test_active)
if (wParam == SPI_SETHANDEDNESS) break; /* ignore */
if (!change_counter++) change_last_param = 0;
if (displaychange_test_active) break;
if (!change_last_param) change_last_param = wParam;
else if (change_last_param != wParam)
{
switch (wParam)
{
/* ignore these messages when caused by other actions */
case SPI_ICONVERTICALSPACING:
case SPI_SETWORKAREA:
break;
if( !change_last_param){
change_last_param = wParam;
default:
ok( 0, "too many changes counter=%d last change=%Iu\n", change_counter, wParam );
break;
}
ok(0,"too many changes counter=%d last change=%d\n",
change_counter,change_last_param);
change_counter++;
change_last_param = wParam;
break;
}
change_counter++;
change_last_param = change_setworkarea_param = change_iconverticalspacing_param =0;
if( wParam == SPI_SETWORKAREA)
change_setworkarea_param = 1;
else if( wParam == SPI_ICONVERTICALSPACING)
change_iconverticalspacing_param = 1;
else
change_last_param = wParam;
break;
case WM_DESTROY:
......@@ -273,18 +261,22 @@ params:
*/
static void test_change_message( int action, int optional )
{
SendMessageA( ghTestWnd, WM_NULL, 0, 0 );
if (change_counter==0 && optional==1)
return;
ok( 1 == change_counter,
"Missed a message: change_counter=%d\n", change_counter );
ok( change_counter >= 1, "Missed a message: change_counter=%d\n", change_counter );
change_counter = 0;
ok( action == change_last_param ||
( change_setworkarea_param && action == SPI_SETWORKAREA) ||
( change_iconverticalspacing_param && action == SPI_ICONVERTICALSPACING),
"Wrong action got %d expected %d\n", change_last_param, action );
ok( action == change_last_param, "Wrong action got %d expected %d\n", change_last_param, action );
change_last_param = 0;
}
static void flush_change_messages(void)
{
change_counter = 0;
SendMessageA( ghTestWnd, WM_NULL, 0, 0 );
change_counter = 0;
}
static BOOL test_error_msg ( int rc, const char *name )
{
DWORD last_error = GetLastError();
......@@ -1189,6 +1181,7 @@ static void test_SPI_SETMENUDROPALIGNMENT( void ) /* 28 */
rc=SystemParametersInfoA( SPI_SETMENUDROPALIGNMENT, old_b, 0,
SPIF_UPDATEINIFILE );
ok(rc, "***warning*** failed to restore the original value: rc=%d err=%ld\n", rc, GetLastError());
flush_change_messages();
}
static void test_SPI_SETDOUBLECLKWIDTH( void ) /* 29 */
......@@ -1257,6 +1250,7 @@ static void test_SPI_SETDOUBLECLKHEIGHT( void ) /* 30 */
rc=SystemParametersInfoA( SPI_SETDOUBLECLKHEIGHT, old_height, 0,
SPIF_UPDATEINIFILE );
ok(rc, "***warning*** failed to restore the original value: rc=%d err=%ld\n", rc, GetLastError());
flush_change_messages();
}
static void test_SPI_SETDOUBLECLICKTIME( void ) /* 32 */
......@@ -1313,24 +1307,25 @@ static void test_SPI_SETDOUBLECLICKTIME( void ) /* 32 */
rc=SystemParametersInfoA(SPI_SETDOUBLECLICKTIME, old_time, 0, SPIF_UPDATEINIFILE);
ok(rc, "***warning*** failed to restore the original value: rc=%d err=%ld\n", rc, GetLastError());
flush_change_messages();
}
static void test_SPI_SETMOUSEBUTTONSWAP( void ) /* 33 */
{
BOOL rc;
BOOL old_b;
const UINT vals[]={TRUE,FALSE};
BOOL vals[2];
unsigned int i;
trace("testing SPI_{GET,SET}MOUSEBUTTONSWAP\n");
old_b = GetSystemMetrics( SM_SWAPBUTTON );
vals[1] = GetSystemMetrics( SM_SWAPBUTTON );
vals[0] = !vals[1];
for (i=0;i<ARRAY_SIZE(vals);i++)
{
SetLastError(0xdeadbeef);
rc=SystemParametersInfoA( SPI_SETMOUSEBUTTONSWAP, vals[i], 0,
SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
if (!test_error_msg(rc,"SPI_SETMOUSEBUTTONSWAP")) return;
if (!test_error_msg(rc,"SPI_SETMOUSEBUTTONSWAP")) break;
test_change_message( SPI_SETMOUSEBUTTONSWAP, 0 );
test_reg_key( SPI_SETMOUSEBUTTONSWAP_REGKEY,
......@@ -1342,11 +1337,13 @@ static void test_SPI_SETMOUSEBUTTONSWAP( void ) /* 33 */
eq( GetSystemMetrics( SM_SWAPBUTTON ), (int)vals[i^1],
"SwapMouseButton", "%d" );
ok( rc==(BOOL)vals[i], "SwapMouseButton does not return previous state (really %d)\n", rc );
test_change_message( SPI_SETMOUSEBUTTONSWAP, 1 );
}
rc=SystemParametersInfoA( SPI_SETMOUSEBUTTONSWAP, old_b, 0,
rc=SystemParametersInfoA( SPI_SETMOUSEBUTTONSWAP, vals[1], 0,
SPIF_UPDATEINIFILE );
ok(rc, "***warning*** failed to restore the original value: rc=%d err=%ld\n", rc, GetLastError());
flush_change_messages();
}
static void test_SPI_SETFASTTASKSWITCH( void ) /* 36 */
......@@ -1400,6 +1397,7 @@ static void test_SPI_SETDRAGFULLWINDOWS( void ) /* 37 */
rc=SystemParametersInfoA( SPI_SETDRAGFULLWINDOWS, old_b, 0, SPIF_UPDATEINIFILE );
ok(rc, "***warning*** failed to restore the original value: rc=%d err=%ld\n", rc, GetLastError());
flush_change_messages();
}
#define test_reg_metric( KEY, VAL, val) do { \
......@@ -1589,6 +1587,7 @@ static void test_SPI_SETNONCLIENTMETRICS( void ) /* 44 */
&Ncmorig, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
test_change_message( SPI_SETNONCLIENTMETRICS, 0 );
ok(rc, "***warning*** failed to restore the original value: rc=%d err=%ld\n", rc, GetLastError());
flush_change_messages();
/* test the system metrics with these settings */
test_GetSystemMetrics();
}
......@@ -1710,6 +1709,7 @@ static void test_SPI_SETMINIMIZEDMETRICS( void ) /* 44 */
rc=SystemParametersInfoA( SPI_SETMINIMIZEDMETRICS, sizeof(MINIMIZEDMETRICS),
&lpMm_orig, SPIF_UPDATEINIFILE );
ok(rc, "***warning*** failed to restore the original value: rc=%d err=%ld\n", rc, GetLastError());
flush_change_messages();
/* check that */
rc=SystemParametersInfoA( SPI_GETMINIMIZEDMETRICS, sizeof(MINIMIZEDMETRICS), &lpMm_new, FALSE );
ok(rc, "SystemParametersInfoA: rc=%d err=%ld\n", rc, GetLastError());
......@@ -1829,6 +1829,7 @@ static void test_SPI_SETICONMETRICS( void ) /* 46 */
/* restore old values */
rc=SystemParametersInfoA( SPI_SETICONMETRICS, sizeof(ICONMETRICSA), &im_orig,SPIF_UPDATEINIFILE );
ok(rc, "***warning*** failed to restore the original value: rc=%d err=%ld\n", rc, GetLastError());
flush_change_messages();
rc=SystemParametersInfoA( SPI_GETICONMETRICS, sizeof(ICONMETRICSA), &im_new, FALSE );
ok(rc, "SystemParametersInfoA: rc=%d err=%ld\n", rc, GetLastError());
......@@ -1888,6 +1889,7 @@ static void test_SPI_SETWORKAREA( void ) /* 47 */
"right: got %ld instead of %ld\n", area.right, old_area.right );
ok( area.bottom >= old_area.bottom - 16 && area.bottom < old_area.bottom + 16,
"bottom: got %ld instead of %ld\n", area.bottom, old_area.bottom );
flush_change_messages();
}
static void test_SPI_SETSHOWSOUNDS( void ) /* 57 */
......@@ -1925,20 +1927,21 @@ static void test_SPI_SETSHOWSOUNDS( void ) /* 57 */
rc=SystemParametersInfoA( SPI_SETSHOWSOUNDS, old_b, 0, SPIF_UPDATEINIFILE );
ok(rc, "***warning*** failed to restore the original value: rc=%d err=%ld\n", rc, GetLastError());
flush_change_messages();
}
static void test_SPI_SETKEYBOARDPREF( void ) /* 69 */
{
BOOL rc;
BOOL old_b;
const UINT vals[]={TRUE,FALSE};
BOOL vals[2];
unsigned int i;
trace("testing SPI_{GET,SET}KEYBOARDPREF\n");
SetLastError(0xdeadbeef);
rc=SystemParametersInfoA( SPI_GETKEYBOARDPREF, 0, &old_b, 0 );
rc=SystemParametersInfoA( SPI_GETKEYBOARDPREF, 0, &vals[1], 0 );
if (!test_error_msg(rc,"SPI_{GET,SET}KEYBOARDPREF"))
return;
vals[0] = !vals[1];
for (i=0;i<ARRAY_SIZE(vals);i++)
{
......@@ -1946,7 +1949,7 @@ static void test_SPI_SETKEYBOARDPREF( void ) /* 69 */
rc=SystemParametersInfoA( SPI_SETKEYBOARDPREF, vals[i], 0,
SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
if (!test_error_msg(rc,"SPI_SETKEYBOARDPREF")) return;
if (!test_error_msg(rc,"SPI_SETKEYBOARDPREF")) break;
ok(rc, "%d: rc=%d err=%ld\n", i, rc, GetLastError());
test_change_message( SPI_SETKEYBOARDPREF, 1 );
test_reg_key_ex2( SPI_SETKEYBOARDPREF_REGKEY, SPI_SETKEYBOARDPREF_REGKEY_LEGACY,
......@@ -1958,8 +1961,9 @@ static void test_SPI_SETKEYBOARDPREF( void ) /* 69 */
eq( v, (BOOL)vals[i], "SPI_GETKEYBOARDPREF", "%d" );
}
rc=SystemParametersInfoA( SPI_SETKEYBOARDPREF, old_b, 0, SPIF_UPDATEINIFILE );
rc=SystemParametersInfoA( SPI_SETKEYBOARDPREF, vals[1], 0, SPIF_UPDATEINIFILE );
ok(rc, "***warning*** failed to restore the original value: rc=%d err=%ld\n", rc, GetLastError());
flush_change_messages();
}
static void test_SPI_SETSCREENREADER( void ) /* 71 */
......@@ -1995,6 +1999,7 @@ static void test_SPI_SETSCREENREADER( void ) /* 71 */
rc=SystemParametersInfoA( SPI_SETSCREENREADER, old_b, 0, SPIF_UPDATEINIFILE );
ok(rc, "***warning*** failed to restore the original value: rc=%d err=%ld\n", rc, GetLastError());
flush_change_messages();
}
static void test_SPI_SETFONTSMOOTHING( void ) /* 75 */
......@@ -2076,6 +2081,7 @@ static void test_SPI_SETFONTSMOOTHING( void ) /* 75 */
ok(rc, "***warning*** failed to restore the original value: rc=%d err=%ld\n", rc, GetLastError());
rc=SystemParametersInfoA( SPI_SETFONTSMOOTHINGORIENTATION, old_orient, 0, SPIF_UPDATEINIFILE );
ok(rc, "***warning*** failed to restore the original value: rc=%d err=%ld\n", rc, GetLastError());
flush_change_messages();
}
static void test_SPI_SETLOWPOWERACTIVE( void ) /* 85 */
......@@ -2114,6 +2120,7 @@ static void test_SPI_SETLOWPOWERACTIVE( void ) /* 85 */
rc=SystemParametersInfoA( SPI_SETLOWPOWERACTIVE, old_b, 0, SPIF_UPDATEINIFILE );
ok(rc, "***warning*** failed to restore the original value: rc=%d err=%ld\n", rc, GetLastError());
flush_change_messages();
}
static void test_SPI_SETPOWEROFFACTIVE( void ) /* 86 */
......@@ -2152,6 +2159,7 @@ static void test_SPI_SETPOWEROFFACTIVE( void ) /* 86 */
rc=SystemParametersInfoA( SPI_SETPOWEROFFACTIVE, old_b, 0, SPIF_UPDATEINIFILE );
ok(rc, "***warning*** failed to restore the original value: rc=%d err=%ld\n", rc, GetLastError());
flush_change_messages();
}
static void test_SPI_SETSNAPTODEFBUTTON( void ) /* 95 */
......@@ -2187,6 +2195,7 @@ static void test_SPI_SETSNAPTODEFBUTTON( void ) /* 95 */
rc=SystemParametersInfoA( SPI_SETSNAPTODEFBUTTON, old_b, 0, SPIF_UPDATEINIFILE );
ok(rc, "***warning*** failed to restore the original value: rc=%d err=%ld\n", rc, GetLastError());
flush_change_messages();
}
static void test_SPI_SETMOUSEHOVERWIDTH( void ) /* 99 */
......@@ -2224,6 +2233,7 @@ static void test_SPI_SETMOUSEHOVERWIDTH( void ) /* 99 */
rc=SystemParametersInfoA( SPI_SETMOUSEHOVERWIDTH, old_width, 0,
SPIF_UPDATEINIFILE );
ok(rc, "***warning*** failed to restore the original value: rc=%d err=%ld\n", rc, GetLastError());
flush_change_messages();
}
static void test_SPI_SETMOUSEHOVERHEIGHT( void ) /* 101 */
......@@ -2261,6 +2271,7 @@ static void test_SPI_SETMOUSEHOVERHEIGHT( void ) /* 101 */
rc=SystemParametersInfoA( SPI_SETMOUSEHOVERHEIGHT, old_height, 0,
SPIF_UPDATEINIFILE );
ok(rc, "***warning*** failed to restore the original value: rc=%d err=%ld\n", rc, GetLastError());
flush_change_messages();
}
static void test_SPI_SETMOUSEHOVERTIME( void ) /* 103 */
......@@ -2302,6 +2313,7 @@ static void test_SPI_SETMOUSEHOVERTIME( void ) /* 103 */
rc=SystemParametersInfoA( SPI_SETMOUSEHOVERTIME, old_time, 0,
SPIF_UPDATEINIFILE );
ok(rc, "***warning*** failed to restore the original value: rc=%d err=%ld\n", rc, GetLastError());
flush_change_messages();
}
static void test_SPI_SETWHEELSCROLLLINES( void ) /* 105 */
......@@ -2341,6 +2353,7 @@ static void test_SPI_SETWHEELSCROLLLINES( void ) /* 105 */
rc=SystemParametersInfoA( SPI_SETWHEELSCROLLLINES, old_lines, 0,
SPIF_UPDATEINIFILE );
ok(rc, "***warning*** failed to restore the original value: rc=%d err=%ld\n", rc, GetLastError());
flush_change_messages();
}
static void test_SPI_SETMENUSHOWDELAY( void ) /* 107 */
......@@ -2380,6 +2393,7 @@ static void test_SPI_SETMENUSHOWDELAY( void ) /* 107 */
rc=SystemParametersInfoA( SPI_SETMENUSHOWDELAY, old_delay, 0,
SPIF_UPDATEINIFILE );
ok(rc, "***warning*** failed to restore the original value: rc=%d err=%ld\n", rc, GetLastError());
flush_change_messages();
}
static void test_SPI_SETWHEELSCROLLCHARS( void ) /* 108 */
......@@ -2418,6 +2432,7 @@ static void test_SPI_SETWHEELSCROLLCHARS( void ) /* 108 */
rc=SystemParametersInfoA( SPI_SETWHEELSCROLLCHARS, old_chars, 0,
SPIF_UPDATEINIFILE );
ok(rc, "***warning*** failed to restore the original value: rc=%d err=%ld\n", rc, GetLastError());
flush_change_messages();
}
static void test_SPI_SETWALLPAPER( void ) /* 115 */
......@@ -2442,6 +2457,7 @@ static void test_SPI_SETWALLPAPER( void ) /* 115 */
ok(rc, "***warning*** failed to restore the original value: rc=%d err=%ld\n", rc, GetLastError());
test_reg_key(SPI_SETDESKWALLPAPER_REGKEY, SPI_SETDESKWALLPAPER_VALNAME, oldval);
flush_change_messages();
}
static void test_WM_DISPLAYCHANGE(void)
......@@ -2694,7 +2710,7 @@ static void test_GetSystemMetrics( void)
HDC hdc = CreateICA( "Display", 0, 0, 0);
UINT avcwCaption;
INT CaptionWidthfromreg, smicon, broken_val;
INT CaptionWidthfromreg, width, smicon, broken_val;
MINIMIZEDMETRICS minim;
NONCLIENTMETRICSA ncm;
SIZE screen;
......@@ -2812,11 +2828,12 @@ static void test_GetSystemMetrics( void)
ok_gsm( SM_CYMINSPACING, GetSystemMetrics( SM_CYMINIMIZED) + (short)minim.iVertGap );
smicon = MulDiv( 16, dpi, USER_DEFAULT_SCREEN_DPI );
width = CaptionWidthfromreg > 0 ? CaptionWidthfromreg : ncm.iCaptionWidth;
if (!pIsProcessDPIAware || pIsProcessDPIAware())
smicon = max( min( smicon, CaptionWidthfromreg - 2), 4 ) & ~1;
smicon = max( min( smicon, width - 2), 4 ) & ~1;
todo_wine_if( real_dpi == dpi && smicon != (MulDiv( 16, dpi, USER_DEFAULT_SCREEN_DPI) & ~1) )
{
broken_val = (min( ncm.iCaptionHeight, CaptionWidthfromreg ) - 2) & ~1;
broken_val = (min( ncm.iCaptionHeight, width ) - 2) & ~1;
broken_val = min( broken_val, 20 );
if (smicon == 4)
......@@ -2824,16 +2841,11 @@ static void test_GetSystemMetrics( void)
ok_gsm_2( SM_CXSMICON, smicon, 6 );
ok_gsm_2( SM_CYSMICON, smicon, 6 );
}
else if (smicon < broken_val)
else
{
ok_gsm_2( SM_CXSMICON, smicon, broken_val );
ok_gsm_2( SM_CYSMICON, smicon, broken_val );
}
else
{
ok_gsm( SM_CXSMICON, smicon );
ok_gsm( SM_CYSMICON, smicon );
}
}
ok_gsm( SM_CYSMCAPTION, ncm.iSmCaptionHeight + 1);
......@@ -3009,6 +3021,12 @@ static void test_metrics_for_dpi( int custom_dpi )
val += 2 * ncm2.iPaddedBorderWidth;
ok( ret1 == ret2 || ret2 == val /* Win10 1709+ */, "%u: expected %u or %u, got %u\n", i, ret1, val, ret2 );
break;
case SM_CXMIN:
case SM_CXMINTRACK:
val = MulDiv( ret1 - 7, custom_dpi, dpi );
ok( ret1 == ret2 || (ret2 >= val - 10 && ret2 <= val + 10) /* Win10 1709+ */,
"%u: expected %u or %u, got %u\n", i, ret1, val, ret2 );
break;
default:
ok( ret1 == ret2, "%u: wrong value %u vs %u\n", i, ret1, ret2 );
break;
......@@ -3821,9 +3839,16 @@ static void test_dpi_context(void)
ok( ret, "got %d\n", ret );
todo_wine
ok( awareness == DPI_AWARENESS_SYSTEM_AWARE, "wrong value %d\n", awareness );
SetLastError(0xdeadbeef);
ret = pGetProcessDpiAwarenessInternal( (HANDLE)0xdeadbeef, &awareness );
ok( ret, "got %d\n", ret );
ok( awareness == DPI_AWARENESS_UNAWARE, "wrong value %d\n", awareness );
todo_wine
ok( !ret || broken(ret) /* <= win10 1709 */, "got %d\n", ret );
if (!ret)
{
ok( GetLastError() == ERROR_INVALID_PARAMETER, "got %lu\n", GetLastError() );
ok( awareness == DPI_AWARENESS_INVALID, "wrong value %d\n", awareness );
}
else ok( awareness == DPI_AWARENESS_UNAWARE, "wrong value %d\n", awareness );
ret = pIsProcessDPIAware();
ok(ret, "got %d\n", ret);
......@@ -3908,6 +3933,9 @@ static void test_dpi_context(void)
"%Ix: wrong value %u\n", i, awareness );
break;
case 0x11:
ok( awareness == DPI_AWARENESS_SYSTEM_AWARE || awareness == DPI_AWARENESS_INVALID /* Win10 1709+ */,
"%Ix: wrong value %u\n", i, awareness );
break;
case 0x12:
ok( awareness == (i & ~0x10), "%Ix: wrong value %u\n", i, awareness );
break;
......@@ -3931,6 +3959,9 @@ static void test_dpi_context(void)
"%Ix: wrong value %u\n", i | 0x80000000, awareness );
break;
case 0x11:
ok( awareness == DPI_AWARENESS_SYSTEM_AWARE || awareness == DPI_AWARENESS_INVALID /* Win10 1709+ */,
"%Ix: wrong value %u\n", i | 0x80000000, awareness );
break;
case 0x12:
ok( awareness == (i & ~0x10), "%Ix: wrong value %u\n", i | 0x80000000, awareness );
break;
......
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