2011-10-17 16:35:22 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS API tests
|
|
|
|
* LICENSE: GPL - See COPYING in the top level directory
|
|
|
|
* PURPOSE: Test for SystemParametersInfo function family
|
|
|
|
* PROGRAMMERS: Giannis Adamopoulos
|
|
|
|
*/
|
|
|
|
|
2013-09-22 18:17:54 +00:00
|
|
|
#include <apitest.h>
|
|
|
|
|
2013-02-05 17:54:22 +00:00
|
|
|
#include <wingdi.h>
|
|
|
|
#include <winuser.h>
|
2011-10-17 16:35:22 +00:00
|
|
|
#include <undocuser.h>
|
|
|
|
|
2017-03-07 22:29:48 +00:00
|
|
|
#include <msgtrace.h>
|
|
|
|
#include <user32testhelpers.h>
|
|
|
|
|
2011-10-17 16:35:22 +00:00
|
|
|
HWND hWnd1, hWnd2;
|
|
|
|
|
|
|
|
/* FIXME: test for HWND_TOP, etc...*/
|
|
|
|
static int get_iwnd(HWND hWnd)
|
|
|
|
{
|
|
|
|
if(hWnd == hWnd1) return 1;
|
|
|
|
else if(hWnd == hWnd2) return 2;
|
|
|
|
else return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT CALLBACK SysParamsTestProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
int iwnd = get_iwnd(hWnd);
|
|
|
|
|
|
|
|
if(message > WM_USER || !iwnd || IsDWmMsg(message) || IseKeyMsg(message))
|
|
|
|
return DefWindowProc(hWnd, message, wParam, lParam);
|
|
|
|
|
|
|
|
switch(message)
|
|
|
|
{
|
|
|
|
case WM_GETICON :
|
|
|
|
case WM_SETICON:
|
|
|
|
break;
|
|
|
|
case WM_WINDOWPOSCHANGING:
|
|
|
|
case WM_WINDOWPOSCHANGED:
|
|
|
|
{
|
|
|
|
WINDOWPOS* pwp = (WINDOWPOS*)lParam;
|
|
|
|
ok(wParam==0,"expected wParam=0\n");
|
2015-11-03 21:14:15 +00:00
|
|
|
RECORD_MESSAGE(iwnd, message, SENT, get_iwnd(pwp->hwndInsertAfter), pwp->flags);
|
2011-10-17 16:35:22 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2015-11-03 21:14:15 +00:00
|
|
|
RECORD_MESSAGE(iwnd, message, SENT, 0,0);
|
2011-10-17 16:35:22 +00:00
|
|
|
}
|
|
|
|
return DefWindowProc(hWnd, message, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void FlushMessages()
|
|
|
|
{
|
|
|
|
MSG msg;
|
|
|
|
|
|
|
|
while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
|
|
|
|
{
|
|
|
|
int iwnd = get_iwnd(msg.hwnd);
|
|
|
|
if(!(msg.message > WM_USER || !iwnd || IsDWmMsg(msg.message) || IseKeyMsg(msg.message)))
|
2015-11-03 21:14:15 +00:00
|
|
|
RECORD_MESSAGE(iwnd, msg.message, POST,0,0);
|
2011-10-17 16:35:22 +00:00
|
|
|
DispatchMessageA( &msg );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MSG_ENTRY NcMetricsChange_chain[]={
|
|
|
|
{2,WM_WINDOWPOSCHANGING, SENT, 0, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW},
|
|
|
|
{2,WM_GETMINMAXINFO},
|
|
|
|
{2,WM_NCCALCSIZE},
|
2011-10-18 11:19:24 +00:00
|
|
|
{2,WM_WINDOWPOSCHANGED, SENT, 0, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW | SWP_NOCLIENTSIZE | SWP_NOCLIENTMOVE | SWP_NOSIZE},
|
2011-10-17 16:35:22 +00:00
|
|
|
{1,WM_WINDOWPOSCHANGING, SENT, 0, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW},
|
|
|
|
{1,WM_GETMINMAXINFO},
|
|
|
|
{1,WM_NCCALCSIZE},
|
2011-10-18 11:19:24 +00:00
|
|
|
{1,WM_WINDOWPOSCHANGED, SENT, 0, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW | SWP_NOCLIENTSIZE | SWP_NOCLIENTMOVE | SWP_NOSIZE},
|
|
|
|
{0,0}};
|
|
|
|
|
|
|
|
MSG_ENTRY NcMetricsChange1_chain[]={
|
|
|
|
{2,WM_WINDOWPOSCHANGING, SENT, 0, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW},
|
|
|
|
{2,WM_GETMINMAXINFO},
|
|
|
|
{2,WM_NCCALCSIZE},
|
|
|
|
{2,WM_WINDOWPOSCHANGED, SENT, 0, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW | SWP_NOCLIENTSIZE | SWP_NOCLIENTMOVE | SWP_NOSIZE},
|
|
|
|
{1,WM_WINDOWPOSCHANGING, SENT, 0, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW},
|
|
|
|
{1,WM_GETMINMAXINFO},
|
|
|
|
{1,WM_NCCALCSIZE},
|
|
|
|
{1,WM_WINDOWPOSCHANGED, SENT, 0, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW | SWP_NOCLIENTSIZE | SWP_NOCLIENTMOVE | SWP_NOSIZE},
|
|
|
|
{2,WM_SETTINGCHANGE},
|
|
|
|
{1,WM_SETTINGCHANGE},
|
2011-10-17 16:35:22 +00:00
|
|
|
{0,0}};
|
|
|
|
|
|
|
|
MSG_ENTRY CaptionHeight_chain[]={
|
|
|
|
{2,WM_WINDOWPOSCHANGING, SENT, 0, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW},
|
|
|
|
{2,WM_GETMINMAXINFO},
|
|
|
|
{2,WM_NCCALCSIZE},
|
|
|
|
{2,WM_WINDOWPOSCHANGED, SENT, 0, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW | SWP_NOCLIENTSIZE},
|
|
|
|
{2,WM_MOVE},
|
|
|
|
{1,WM_WINDOWPOSCHANGING, SENT, 0, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW},
|
|
|
|
{1,WM_GETMINMAXINFO},
|
|
|
|
{1,WM_NCCALCSIZE},
|
2011-10-18 11:19:24 +00:00
|
|
|
{1,WM_WINDOWPOSCHANGED, SENT, 0, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW | SWP_NOCLIENTSIZE},
|
2011-10-17 16:35:22 +00:00
|
|
|
{1,WM_MOVE},
|
|
|
|
{0,0}};
|
|
|
|
|
|
|
|
static void Test_NonClientMetrics()
|
|
|
|
{
|
|
|
|
NONCLIENTMETRICS NonClientMetrics;
|
|
|
|
|
2011-10-18 11:19:24 +00:00
|
|
|
/* WARNING: this test requires themes and dwm to be disabled */
|
|
|
|
|
2011-10-17 16:35:22 +00:00
|
|
|
SetCursorPos(0,0);
|
|
|
|
|
2011-10-18 11:19:24 +00:00
|
|
|
/* Retrieve th non client metrics */
|
2011-10-17 16:35:22 +00:00
|
|
|
NonClientMetrics.cbSize = sizeof(NONCLIENTMETRICS);
|
|
|
|
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &NonClientMetrics, 0);
|
|
|
|
FlushMessages();
|
|
|
|
COMPARE_CACHE(empty_chain);
|
2011-10-18 11:19:24 +00:00
|
|
|
|
|
|
|
/* Set the non client metric without making any change */
|
2011-10-17 16:35:22 +00:00
|
|
|
SystemParametersInfo(SPI_SETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &NonClientMetrics, 0);
|
|
|
|
FlushMessages();
|
|
|
|
COMPARE_CACHE(NcMetricsChange_chain);
|
|
|
|
|
2011-10-18 11:19:24 +00:00
|
|
|
/* Set the same metrics again with the SPIF_SENDCHANGE param */
|
|
|
|
SystemParametersInfo(SPI_SETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &NonClientMetrics, SPIF_SENDCHANGE|SPIF_UPDATEINIFILE );
|
|
|
|
FlushMessages();
|
|
|
|
COMPARE_CACHE(NcMetricsChange1_chain);
|
|
|
|
|
|
|
|
/* Slightly change the caption height */
|
2011-10-17 16:35:22 +00:00
|
|
|
NonClientMetrics.iCaptionHeight += 1;
|
|
|
|
SystemParametersInfo(SPI_SETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &NonClientMetrics, 0);
|
|
|
|
FlushMessages();
|
|
|
|
COMPARE_CACHE(CaptionHeight_chain);
|
|
|
|
|
2011-10-18 11:19:24 +00:00
|
|
|
/* Restore the original caption height */
|
2011-10-17 16:35:22 +00:00
|
|
|
NonClientMetrics.iCaptionHeight -= 1;
|
|
|
|
SystemParametersInfo(SPI_SETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &NonClientMetrics, 0);
|
|
|
|
FlushMessages();
|
|
|
|
COMPARE_CACHE(CaptionHeight_chain);
|
|
|
|
}
|
|
|
|
|
2012-01-31 09:58:05 +00:00
|
|
|
static void Test_MouseSpeed()
|
|
|
|
{
|
|
|
|
ULONG ulMouseSpeed, temp;
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
ret = SystemParametersInfo(SPI_GETMOUSESPEED, 0, &ulMouseSpeed, 0);
|
|
|
|
ok(ret, "SystemParametersInfo failed\n");
|
|
|
|
ok(ulMouseSpeed >= 1 && ulMouseSpeed <=20, "Wrong mouse speed (%d)\n", (int)ulMouseSpeed);
|
|
|
|
|
|
|
|
temp = 1;
|
|
|
|
ret = SystemParametersInfo(SPI_SETMOUSESPEED, 0, (PVOID)temp, SPIF_SENDCHANGE | SPIF_UPDATEINIFILE);
|
|
|
|
ok(ret, "SystemParametersInfo failed\n");
|
|
|
|
ret = SystemParametersInfo(SPI_GETMOUSESPEED, 0, &temp, 0);
|
|
|
|
ok(ret, "SystemParametersInfo failed\n");
|
|
|
|
ok(temp == 1, "SPI_GETMOUSESPEED did not get value set by SPI_SETMOUSESPEED (%d instead of 1)\n", (int)temp);
|
|
|
|
|
2012-01-31 10:49:44 +00:00
|
|
|
temp = 20;
|
|
|
|
ret = SystemParametersInfo(SPI_SETMOUSESPEED, 0, (PVOID)temp, SPIF_SENDCHANGE | SPIF_UPDATEINIFILE);
|
|
|
|
ok(ret, "SystemParametersInfo failed\n");
|
|
|
|
ret = SystemParametersInfo(SPI_GETMOUSESPEED, 0, &temp, 0);
|
|
|
|
ok(ret, "SystemParametersInfo failed\n");
|
|
|
|
ok(temp == 20, "SPI_GETMOUSESPEED did not get value set by SPI_SETMOUSESPEED (%d instead of 20)\n", (int)temp);
|
|
|
|
|
|
|
|
temp = 21;
|
|
|
|
ret = SystemParametersInfo(SPI_SETMOUSESPEED, 0, (PVOID)temp, SPIF_SENDCHANGE | SPIF_UPDATEINIFILE);
|
|
|
|
ok(!ret, "expected SystemParametersInfo to fail\n");
|
|
|
|
ret = SystemParametersInfo(SPI_GETMOUSESPEED, 0, &temp, 0);
|
|
|
|
ok(ret, "SystemParametersInfo failed\n");
|
|
|
|
ok(temp == 20, "SPI_GETMOUSESPEED got unexpected value (%d instead of 20)\n", (int)temp);
|
|
|
|
|
|
|
|
temp = 0;
|
|
|
|
ret = SystemParametersInfo(SPI_SETMOUSESPEED, 0, (PVOID)temp, SPIF_SENDCHANGE | SPIF_UPDATEINIFILE);
|
|
|
|
ok(!ret, "expected SystemParametersInfo to fail\n");
|
|
|
|
ret = SystemParametersInfo(SPI_GETMOUSESPEED, 0, &temp, 0);
|
|
|
|
ok(ret, "SystemParametersInfo failed\n");
|
|
|
|
ok(temp == 20, "SPI_GETMOUSESPEED got unexpected value (%d instead of 20)\n", (int)temp);
|
|
|
|
|
2012-01-31 09:58:05 +00:00
|
|
|
ret = SystemParametersInfo(SPI_SETMOUSESPEED, 0, (PVOID)ulMouseSpeed, SPIF_SENDCHANGE | SPIF_UPDATEINIFILE);
|
|
|
|
ok(ret, "SystemParametersInfo failed\n");
|
|
|
|
}
|
|
|
|
|
2011-10-17 16:35:22 +00:00
|
|
|
START_TEST(SystemParametersInfo)
|
|
|
|
{
|
|
|
|
RegisterSimpleClass(SysParamsTestProc, L"sysparamstest");
|
|
|
|
hWnd1 = CreateWindowW(L"sysparamstest", L"sysparamstest", WS_OVERLAPPEDWINDOW,
|
|
|
|
20, 20, 300, 300, NULL, NULL, 0, NULL);
|
|
|
|
|
|
|
|
hWnd2 = CreateWindowW(L"sysparamstest", L"sysparamstest", WS_OVERLAPPEDWINDOW,
|
|
|
|
200, 200, 300, 300, NULL, NULL, 0, NULL);
|
|
|
|
|
|
|
|
Test_NonClientMetrics();
|
2012-01-31 09:58:05 +00:00
|
|
|
Test_MouseSpeed();
|
2011-10-17 16:35:22 +00:00
|
|
|
|
|
|
|
DestroyWindow(hWnd1);
|
|
|
|
DestroyWindow(hWnd2);
|
|
|
|
UnregisterClassW(L"sysparamstest", 0);
|
|
|
|
}
|