ReactOS  0.4.14-dev-52-g6116262
SystemParametersInfo.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS API tests
3  * LICENSE: GPL - See COPYING in the top level directory
4  * PURPOSE: Test for SystemParametersInfo function family
5  * PROGRAMMERS: Giannis Adamopoulos
6  */
7 
8 #include "precomp.h"
9 
11 
12 /* FIXME: test for HWND_TOP, etc...*/
13 static int get_iwnd(HWND hWnd)
14 {
15  if(hWnd == hWnd1) return 1;
16  else if(hWnd == hWnd2) return 2;
17  else return 0;
18 }
19 
21 {
22  int iwnd = get_iwnd(hWnd);
23 
24  if(message > WM_USER || !iwnd || IsDWmMsg(message) || IseKeyMsg(message))
26 
27  switch(message)
28  {
29  case WM_GETICON :
30  case WM_SETICON:
31  break;
34  {
35  WINDOWPOS* pwp = (WINDOWPOS*)lParam;
36  ok(wParam==0,"expected wParam=0\n");
38  break;
39  }
40  default:
41  RECORD_MESSAGE(iwnd, message, SENT, 0,0);
42  }
44 }
45 
46 static void FlushMessages()
47 {
48  MSG msg;
49 
50  while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
51  {
52  int iwnd = get_iwnd(msg.hwnd);
53  if(!(msg.message > WM_USER || !iwnd || IsDWmMsg(msg.message) || IseKeyMsg(msg.message)))
54  RECORD_MESSAGE(iwnd, msg.message, POST,0,0);
56  }
57 }
58 
61  {2,WM_GETMINMAXINFO},
62  {2,WM_NCCALCSIZE},
65  {1,WM_GETMINMAXINFO},
66  {1,WM_NCCALCSIZE},
68  {0,0}};
69 
72  {2,WM_GETMINMAXINFO},
73  {2,WM_NCCALCSIZE},
76  {1,WM_GETMINMAXINFO},
77  {1,WM_NCCALCSIZE},
79  {2,WM_SETTINGCHANGE},
80  {1,WM_SETTINGCHANGE},
81  {0,0}};
82 
85  {2,WM_GETMINMAXINFO},
86  {2,WM_NCCALCSIZE},
88  {2,WM_MOVE},
90  {1,WM_GETMINMAXINFO},
91  {1,WM_NCCALCSIZE},
93  {1,WM_MOVE},
94  {0,0}};
95 
96 static void Test_NonClientMetrics()
97 {
98  NONCLIENTMETRICS NonClientMetrics;
99 
100  /* WARNING: this test requires themes and dwm to be disabled */
101 
102  SetCursorPos(0,0);
103 
104  /* Retrieve th non client metrics */
105  NonClientMetrics.cbSize = sizeof(NONCLIENTMETRICS);
106  SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &NonClientMetrics, 0);
107  FlushMessages();
109 
110  /* Set the non client metric without making any change */
111  SystemParametersInfo(SPI_SETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &NonClientMetrics, 0);
112  FlushMessages();
114 
115  /* Set the same metrics again with the SPIF_SENDCHANGE param */
116  SystemParametersInfo(SPI_SETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &NonClientMetrics, SPIF_SENDCHANGE|SPIF_UPDATEINIFILE );
117  FlushMessages();
119 
120  /* Slightly change the caption height */
121  NonClientMetrics.iCaptionHeight += 1;
122  SystemParametersInfo(SPI_SETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &NonClientMetrics, 0);
123  FlushMessages();
125 
126  /* Restore the original caption height */
127  NonClientMetrics.iCaptionHeight -= 1;
128  SystemParametersInfo(SPI_SETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &NonClientMetrics, 0);
129  FlushMessages();
131 }
132 
133 static void Test_MouseSpeed()
134 {
135  ULONG ulMouseSpeed, temp;
136  BOOL ret;
137 
138  ret = SystemParametersInfo(SPI_GETMOUSESPEED, 0, &ulMouseSpeed, 0);
139  ok(ret, "SystemParametersInfo failed\n");
140  ok(ulMouseSpeed >= 1 && ulMouseSpeed <=20, "Wrong mouse speed (%d)\n", (int)ulMouseSpeed);
141 
142  temp = 1;
144  ok(ret, "SystemParametersInfo failed\n");
145  ret = SystemParametersInfo(SPI_GETMOUSESPEED, 0, &temp, 0);
146  ok(ret, "SystemParametersInfo failed\n");
147  ok(temp == 1, "SPI_GETMOUSESPEED did not get value set by SPI_SETMOUSESPEED (%d instead of 1)\n", (int)temp);
148 
149  temp = 20;
151  ok(ret, "SystemParametersInfo failed\n");
152  ret = SystemParametersInfo(SPI_GETMOUSESPEED, 0, &temp, 0);
153  ok(ret, "SystemParametersInfo failed\n");
154  ok(temp == 20, "SPI_GETMOUSESPEED did not get value set by SPI_SETMOUSESPEED (%d instead of 20)\n", (int)temp);
155 
156  temp = 21;
158  ok(!ret, "expected SystemParametersInfo to fail\n");
159  ret = SystemParametersInfo(SPI_GETMOUSESPEED, 0, &temp, 0);
160  ok(ret, "SystemParametersInfo failed\n");
161  ok(temp == 20, "SPI_GETMOUSESPEED got unexpected value (%d instead of 20)\n", (int)temp);
162 
163  temp = 0;
165  ok(!ret, "expected SystemParametersInfo to fail\n");
166  ret = SystemParametersInfo(SPI_GETMOUSESPEED, 0, &temp, 0);
167  ok(ret, "SystemParametersInfo failed\n");
168  ok(temp == 20, "SPI_GETMOUSESPEED got unexpected value (%d instead of 20)\n", (int)temp);
169 
170  ret = SystemParametersInfo(SPI_SETMOUSESPEED, 0, UlongToPtr(ulMouseSpeed), SPIF_SENDCHANGE | SPIF_UPDATEINIFILE);
171  ok(ret, "SystemParametersInfo failed\n");
172 }
173 
175 {
176  RegisterSimpleClass(SysParamsTestProc, L"sysparamstest");
177  hWnd1 = CreateWindowW(L"sysparamstest", L"sysparamstest", WS_OVERLAPPEDWINDOW,
178  20, 20, 300, 300, NULL, NULL, 0, NULL);
179 
180  hWnd2 = CreateWindowW(L"sysparamstest", L"sysparamstest", WS_OVERLAPPEDWINDOW,
181  200, 200, 300, 300, NULL, NULL, 0, NULL);
182 
184  Test_MouseSpeed();
185 
188  UnregisterClassW(L"sysparamstest", 0);
189 }
LRESULT WINAPI DispatchMessageA(_In_ const MSG *)
Definition: tftpd.h:59
#define PeekMessage
Definition: winuser.h:5731
MSG_ENTRY CaptionHeight_chain[]
BOOL WINAPI UnregisterClassW(_In_ LPCWSTR, HINSTANCE)
Definition: msgtrace.h:14
HWND hWnd1
#define WM_NCCALCSIZE
Definition: winuser.h:1667
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define CALLBACK
Definition: compat.h:27
MSG_ENTRY NcMetricsChange1_chain[]
HWND hWnd
Definition: settings.c:17
#define SystemParametersInfo
Definition: winuser.h:5759
HWND hwndInsertAfter
Definition: winuser.h:3563
#define WM_MOVE
Definition: winuser.h:1592
UINT_PTR WPARAM
Definition: windef.h:207
#define SWP_NOZORDER
Definition: winuser.h:1232
BOOL WINAPI DestroyWindow(_In_ HWND)
#define CreateWindowW(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4217
WPARAM wParam
Definition: combotst.c:138
#define WM_SETTINGCHANGE
Definition: winuser.h:1611
HWND hWnd2
#define SWP_NOCOPYBITS
Definition: winuser.h:1228
static BOOL IseKeyMsg(UINT msg)
Definition: msgtrace.h:52
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
static void FlushMessages()
UINT flags
Definition: winuser.h:3568
#define UlongToPtr(u)
Definition: config.h:106
#define DefWindowProc
Definition: ros2win.h:31
static __inline ATOM RegisterSimpleClass(WNDPROC lpfnWndProc, LPCWSTR lpszClassName)
static void Test_MouseSpeed()
#define COMPARE_CACHE(msg_chain)
Definition: msgtrace.h:57
#define SWP_NOACTIVATE
Definition: winuser.h:1227
#define WM_WINDOWPOSCHANGING
Definition: winuser.h:1643
BOOL WINAPI SetCursorPos(_In_ int, _In_ int)
Definition: cursoricon.c:2627
int ret
Definition: msgtrace.h:7
static const WCHAR L[]
Definition: oid.c:1250
#define SWP_FRAMECHANGED
Definition: winuser.h:1225
#define WM_USER
Definition: winuser.h:1877
START_TEST(SystemParametersInfo)
static void Test_NonClientMetrics()
#define SWP_NOSIZE
Definition: winuser.h:1230
static BOOL IsDWmMsg(UINT msg)
Definition: msgtrace.h:39
#define SPIF_UPDATEINIFILE
Definition: winuser.h:1553
static calc_node_t temp
Definition: rpn_ieee.c:38
MSG_ENTRY NcMetricsChange_chain[]
#define ok(value,...)
Definition: atltest.h:57
LRESULT CALLBACK SysParamsTestProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
unsigned int UINT
Definition: ndis.h:50
#define SPIF_SENDCHANGE
Definition: winuser.h:1554
#define SWP_NOREDRAW
Definition: winuser.h:1231
static int get_iwnd(HWND hWnd)
Definition: msgtrace.h:6
#define WM_WINDOWPOSCHANGED
Definition: winuser.h:1644
#define msg(x)
Definition: auth_time.c:54
#define RECORD_MESSAGE(...)
Definition: msgtrace.h:60
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
unsigned int ULONG
Definition: retypes.h:1
#define SWP_NOCLIENTMOVE
Definition: msg.h:30
#define SWP_NOMOVE
Definition: winuser.h:1229
#define PM_REMOVE
Definition: winuser.h:1182
LONG_PTR LRESULT
Definition: windef.h:209
#define SWP_NOCLIENTSIZE
Definition: msg.h:29
MSG_ENTRY empty_chain[]
Definition: msgtrace.c:20
LPARAM lParam
Definition: combotst.c:139
#define WM_GETMINMAXINFO
Definition: winuser.h:1622