ReactOS 0.4.16-dev-88-ga65b6ae
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
14
15/* FIXME: test for HWND_TOP, etc...*/
16static int get_iwnd(HWND hWnd)
17{
18 if(hWnd == hWnd1) return 1;
19 else if(hWnd == hWnd2) return 2;
20 else return 0;
21}
22
24{
25 int iwnd = get_iwnd(hWnd);
26
27 if(message > WM_USER || !iwnd || IsDWmMsg(message) || IseKeyMsg(message))
29
30 switch(message)
31 {
32 case WM_GETICON :
33 case WM_SETICON:
34 break;
37 {
38 WINDOWPOS* pwp = (WINDOWPOS*)lParam;
39 ok(wParam==0,"expected wParam=0\n");
41 break;
42 }
43 case WM_DISPLAYCHANGE:
45 {
48 }
49 break;
50 default:
51 RECORD_MESSAGE(iwnd, message, SENT, 0,0);
52 }
54}
55
56static void FlushMessages()
57{
58 MSG msg;
59
60 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
61 {
62 int iwnd = get_iwnd(msg.hwnd);
63 if(!(msg.message > WM_USER || !iwnd || IsDWmMsg(msg.message) || IseKeyMsg(msg.message)))
64 RECORD_MESSAGE(iwnd, msg.message, POST,0,0);
66 }
67}
68
72 {2,WM_NCCALCSIZE},
76 {1,WM_NCCALCSIZE},
78 {0,0}};
79
83 {2,WM_NCCALCSIZE},
87 {1,WM_NCCALCSIZE},
91 {0,0}};
92
96 {2,WM_NCCALCSIZE},
98 {2,WM_MOVE},
101 {1,WM_NCCALCSIZE},
103 {1,WM_MOVE},
104 {0,0}};
105
107{
108 NONCLIENTMETRICS NonClientMetrics;
109
110 /* WARNING: this test requires themes and dwm to be disabled */
111
112 SetCursorPos(0,0);
113
114 /* Retrieve th non client metrics */
115 NonClientMetrics.cbSize = sizeof(NONCLIENTMETRICS);
116 SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &NonClientMetrics, 0);
119
120 /* Set the non client metric without making any change */
121 SystemParametersInfo(SPI_SETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &NonClientMetrics, 0);
124
125 /* Set the same metrics again with the SPIF_SENDCHANGE param */
126 SystemParametersInfo(SPI_SETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &NonClientMetrics, SPIF_SENDCHANGE|SPIF_UPDATEINIFILE );
129
130 /* Slightly change the caption height */
131 NonClientMetrics.iCaptionHeight += 1;
132 SystemParametersInfo(SPI_SETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &NonClientMetrics, 0);
135
136 /* Restore the original caption height */
137 NonClientMetrics.iCaptionHeight -= 1;
138 SystemParametersInfo(SPI_SETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &NonClientMetrics, 0);
141}
142
143static void Test_MouseSpeed()
144{
145 ULONG ulMouseSpeed, temp;
146 BOOL ret;
147
148 ret = SystemParametersInfo(SPI_GETMOUSESPEED, 0, &ulMouseSpeed, 0);
149 ok(ret, "SystemParametersInfo failed\n");
150 ok(ulMouseSpeed >= 1 && ulMouseSpeed <=20, "Wrong mouse speed (%d)\n", (int)ulMouseSpeed);
151
152 temp = 1;
154 ok(ret, "SystemParametersInfo failed\n");
155 ret = SystemParametersInfo(SPI_GETMOUSESPEED, 0, &temp, 0);
156 ok(ret, "SystemParametersInfo failed\n");
157 ok(temp == 1, "SPI_GETMOUSESPEED did not get value set by SPI_SETMOUSESPEED (%d instead of 1)\n", (int)temp);
158
159 temp = 20;
161 ok(ret, "SystemParametersInfo failed\n");
162 ret = SystemParametersInfo(SPI_GETMOUSESPEED, 0, &temp, 0);
163 ok(ret, "SystemParametersInfo failed\n");
164 ok(temp == 20, "SPI_GETMOUSESPEED did not get value set by SPI_SETMOUSESPEED (%d instead of 20)\n", (int)temp);
165
166 temp = 21;
168 ok(!ret, "expected SystemParametersInfo to fail\n");
169 ret = SystemParametersInfo(SPI_GETMOUSESPEED, 0, &temp, 0);
170 ok(ret, "SystemParametersInfo failed\n");
171 ok(temp == 20, "SPI_GETMOUSESPEED got unexpected value (%d instead of 20)\n", (int)temp);
172
173 temp = 0;
175 ok(!ret, "expected SystemParametersInfo to fail\n");
176 ret = SystemParametersInfo(SPI_GETMOUSESPEED, 0, &temp, 0);
177 ok(ret, "SystemParametersInfo failed\n");
178 ok(temp == 20, "SPI_GETMOUSESPEED got unexpected value (%d instead of 20)\n", (int)temp);
179
180 ret = SystemParametersInfo(SPI_SETMOUSESPEED, 0, UlongToPtr(ulMouseSpeed), SPIF_SENDCHANGE | SPIF_UPDATEINIFILE);
181 ok(ret, "SystemParametersInfo failed\n");
182}
183
184static void Test_GradientCaptions(void)
185{
186 BOOL ret;
187 LONG lResult;
188 DWORD dwResult;
189 BOOL bGradientCaptions, bModeFound;
190 DEVMODEW OldDevMode, NewDevMode;
191 INT iMode;
192
193 ret = SystemParametersInfo(SPI_GETGRADIENTCAPTIONS, 0, &bGradientCaptions, 0);
194 ok(ret, "SystemParametersInfo failed\n");
195 if (bGradientCaptions == FALSE)
196 {
197 skip("GRADIENTCAPTIONS value has changed from its original state\n");
198 return;
199 }
200
201 /* Try to find a graphics mode with 16 or 256 colors */
202 iMode = 0;
203 bModeFound = FALSE;
204 while (EnumDisplaySettingsW(NULL, iMode, &NewDevMode))
205 {
206 if ((NewDevMode.dmBitsPerPel == 4) ||
207 (NewDevMode.dmBitsPerPel == 8))
208 {
209 bModeFound = TRUE;
210 break;
211 }
212
213 ++iMode;
214 }
215 if (!bModeFound)
216 {
217 skip("4bpp/8bpp graphics mode is not supported\n");
218 return;
219 }
220
221 /* Save the current graphics mode */
223 ok(ret, "EnumDisplaySettingsW failed\n");
224
226
227 /* Switch to the new graphics mode */
229 lResult = ChangeDisplaySettingsExW(NULL, &NewDevMode, NULL, 0, NULL);
230 if (lResult == DISP_CHANGE_SUCCESSFUL)
231 {
232 dwResult = WaitForSingleObject(g_hSemDisplayChange, 10000);
233 ok(dwResult == WAIT_OBJECT_0, "Waiting for the WM_DISPLAYCHANGE message timed out\n");
234 }
236 ok(lResult == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW returned %ld\n", lResult);
237
238 /* SPI_GETGRADIENTCAPTIONS will now always return FALSE */
239 ret = SystemParametersInfo(SPI_GETGRADIENTCAPTIONS, 0, &bGradientCaptions, 0);
240 ok(ret, "SystemParametersInfo failed\n");
241 ok(bGradientCaptions == FALSE, "SPI_GETGRADIENTCAPTIONS got unexpected value (%d instead of 0)\n", bGradientCaptions);
242
243 /* Enable gradient captions */
244 bGradientCaptions = TRUE;
245 SystemParametersInfo(SPI_SETGRADIENTCAPTIONS, 0, UlongToPtr(bGradientCaptions), 0);
246
247 /* Still FALSE */
248 ret = SystemParametersInfo(SPI_GETGRADIENTCAPTIONS, 0, &bGradientCaptions, 0);
249 ok(ret, "SystemParametersInfo failed\n");
250 ok(bGradientCaptions == FALSE, "SPI_GETGRADIENTCAPTIONS got unexpected value (%d instead of 0)\n", bGradientCaptions);
251
252 /* Restore the previous graphics mode */
254 lResult = ChangeDisplaySettingsExW(NULL, &OldDevMode, NULL, 0, NULL);
255 if (lResult == DISP_CHANGE_SUCCESSFUL)
256 {
257 dwResult = WaitForSingleObject(g_hSemDisplayChange, 10000);
258 ok(dwResult == WAIT_OBJECT_0, "Waiting for the WM_DISPLAYCHANGE message timed out\n");
259 }
261 ok(lResult == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW returned %ld\n", lResult);
262
263 /* The original value should be restored */
264 ret = SystemParametersInfo(SPI_GETGRADIENTCAPTIONS, 0, &bGradientCaptions, 0);
265 ok(ret, "SystemParametersInfo failed\n");
266 ok(bGradientCaptions == TRUE, "SPI_GETGRADIENTCAPTIONS got unexpected value (%d instead of 1)\n", bGradientCaptions);
267
269}
270
272{
273 RegisterSimpleClass(SysParamsTestProc, L"sysparamstest");
274 hWnd1 = CreateWindowW(L"sysparamstest", L"sysparamstest", WS_OVERLAPPEDWINDOW,
275 20, 20, 300, 300, NULL, NULL, 0, NULL);
276
277 hWnd2 = CreateWindowW(L"sysparamstest", L"sysparamstest", WS_OVERLAPPEDWINDOW,
278 200, 200, 300, 300, NULL, NULL, 0, NULL);
279
283
286 UnregisterClassW(L"sysparamstest", 0);
287}
static void FlushMessages()
static HANDLE g_hSemDisplayChange
static void Test_MouseSpeed()
static int get_iwnd(HWND hWnd)
static MSG_ENTRY NcMetricsChange1_chain[]
LRESULT CALLBACK SysParamsTestProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
static HWND hWnd1
static void Test_GradientCaptions(void)
static MSG_ENTRY CaptionHeight_chain[]
static HWND hWnd2
static void Test_NonClientMetrics()
static MSG_ENTRY NcMetricsChange_chain[]
static BOOL g_bReadyForDisplayChange
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define START_TEST(x)
Definition: atltest.h:75
#define msg(x)
Definition: auth_time.c:54
HWND hWnd
Definition: settings.c:17
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define SWP_NOCLIENTSIZE
Definition: msg.h:31
#define SWP_NOCLIENTMOVE
Definition: msg.h:32
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
#define CALLBACK
Definition: compat.h:35
#define UlongToPtr(u)
Definition: config.h:106
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
MSG_ENTRY empty_chain[]
Definition: msgtrace.c:20
static BOOL IsDWmMsg(UINT msg)
Definition: msgtrace.h:39
#define RECORD_MESSAGE(...)
Definition: msgtrace.h:60
#define COMPARE_CACHE(msg_chain)
Definition: msgtrace.h:57
@ POST
Definition: msgtrace.h:7
@ SENT
Definition: msgtrace.h:6
static BOOL IseKeyMsg(UINT msg)
Definition: msgtrace.h:52
unsigned int UINT
Definition: ndis.h:50
#define L(x)
Definition: ntvdm.h:50
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
long LONG
Definition: pedump.c:60
#define DefWindowProc
Definition: ros2win.h:31
static calc_node_t temp
Definition: rpn_ieee.c:38
Definition: msgtrace.h:15
UINT flags
Definition: winuser.h:3597
HWND hwndInsertAfter
Definition: winuser.h:3592
DWORD dmBitsPerPel
Definition: wingdi.h:1647
Definition: tftpd.h:60
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
HANDLE WINAPI DECLSPEC_HOTPATCH CreateSemaphoreW(IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes OPTIONAL, IN LONG lInitialCount, IN LONG lMaximumCount, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:444
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseSemaphore(IN HANDLE hSemaphore, IN LONG lReleaseCount, IN LPLONG lpPreviousCount)
Definition: synch.c:542
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG
Definition: typedefs.h:59
static __inline ATOM RegisterSimpleClass(WNDPROC lpfnWndProc, LPCWSTR lpszClassName)
int ret
LONG WINAPI ChangeDisplaySettingsExW(LPCWSTR lpszDeviceName, LPDEVMODEW lpDevMode, HWND hwnd, DWORD dwflags, LPVOID lParam)
Definition: display.c:585
BOOL WINAPI EnumDisplaySettingsW(LPCWSTR lpszDeviceName, DWORD iModeNum, LPDEVMODEW lpDevMode)
Definition: display.c:408
#define WAIT_OBJECT_0
Definition: winbase.h:406
_In_ ULONG iMode
Definition: winddi.h:3520
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
UINT_PTR WPARAM
Definition: windef.h:207
LRESULT WINAPI DispatchMessageA(_In_ const MSG *)
#define SWP_NOACTIVATE
Definition: winuser.h:1245
#define SWP_NOREDRAW
Definition: winuser.h:1249
#define SWP_FRAMECHANGED
Definition: winuser.h:1243
#define WM_WINDOWPOSCHANGING
Definition: winuser.h:1664
#define SWP_NOMOVE
Definition: winuser.h:1247
#define DISP_CHANGE_SUCCESSFUL
Definition: winuser.h:190
#define SWP_NOSIZE
Definition: winuser.h:1248
BOOL WINAPI SetCursorPos(_In_ int, _In_ int)
Definition: cursoricon.c:2706
#define SPIF_SENDCHANGE
Definition: winuser.h:1575
#define WM_SETTINGCHANGE
Definition: winuser.h:1632
#define SPIF_UPDATEINIFILE
Definition: winuser.h:1574
#define ENUM_CURRENT_SETTINGS
Definition: winuser.h:179
#define WM_GETMINMAXINFO
Definition: winuser.h:1643
#define SWP_NOCOPYBITS
Definition: winuser.h:1246
#define PM_REMOVE
Definition: winuser.h:1199
#define PeekMessage
Definition: winuser.h:5842
#define CreateWindowW(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4319
#define WM_MOVE
Definition: winuser.h:1613
#define WM_USER
Definition: winuser.h:1898
BOOL WINAPI UnregisterClassW(_In_ LPCWSTR, HINSTANCE)
#define SWP_NOZORDER
Definition: winuser.h:1250
#define SystemParametersInfo
Definition: winuser.h:5870
#define WM_NCCALCSIZE
Definition: winuser.h:1688
#define WM_WINDOWPOSCHANGED
Definition: winuser.h:1665
BOOL WINAPI DestroyWindow(_In_ HWND)