1 /* Unit tests for the track bar control.
3 * Copyright 2007 Keith Stevens
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include <wine/test.h>
22 //#include <windows.h>
30 #define expect(expected, got) ok(got == expected, "Expected %d, got %d\n", expected, got)
31 #define NUM_MSG_SEQUENCE 2
32 #define PARENT_SEQ_INDEX 0
33 #define TRACKBAR_SEQ_INDEX 1
35 static const DWORD defaultstyle
= WS_VISIBLE
| TBS_TOOLTIPS
| TBS_ENABLESELRANGE
| TBS_FIXEDLENGTH
| TBS_AUTOTICKS
;
36 static HWND hWndParent
;
38 static LRESULT WINAPI
trackbar_no_wmpaint_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
40 WNDPROC oldproc
= (WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_USERDATA
);
42 if (message
== WM_PAINT
)
45 return CallWindowProcA(oldproc
, hwnd
, message
, wParam
, lParam
);
48 static struct msg_sequence
*sequences
[NUM_MSG_SEQUENCE
];
50 static const struct message empty_seq
[] = {
54 static const struct message parent_create_trackbar_wnd_seq
[] = {
55 { WM_NOTIFYFORMAT
, sent
},
56 { WM_QUERYUISTATE
, sent
|optional
},
57 { WM_WINDOWPOSCHANGING
, sent
},
58 { WM_NCACTIVATE
, sent
},
59 { PBT_APMRESUMECRITICAL
, sent
},
60 { WM_WINDOWPOSCHANGING
, sent
},
61 { PBT_APMRESUMESTANDBY
, sent
},
62 { WM_IME_SETCONTEXT
, sent
|optional
},
63 { WM_IME_NOTIFY
, sent
|optional
},
64 { WM_CTLCOLORSTATIC
, sent
},
69 static const struct message parent_new_window_test_seq
[] = {
70 { WM_QUERYNEWPALETTE
, sent
|optional
},
71 { WM_WINDOWPOSCHANGING
, sent
|optional
},
72 { WM_NCACTIVATE
, sent
|optional
},
73 { PBT_APMRESUMECRITICAL
, sent
|optional
},
74 { WM_IME_SETCONTEXT
, sent
|defwinproc
|optional
},
75 { WM_IME_NOTIFY
, sent
|defwinproc
|optional
},
76 { WM_SETFOCUS
, sent
|defwinproc
|optional
},
77 { WM_NOTIFYFORMAT
, sent
},
78 { WM_QUERYUISTATE
, sent
|optional
},
82 static const struct message buddy_window_test_seq
[] = {
83 { TBM_GETBUDDY
, sent
|wparam
, TRUE
},
84 { TBM_SETBUDDY
, sent
|wparam
, FALSE
},
85 { WM_PAINT
, sent
|defwinproc
},
86 { TBM_SETBUDDY
, sent
|wparam
, FALSE
},
87 { WM_PAINT
, sent
|defwinproc
},
88 { TBM_GETBUDDY
, sent
|wparam
, TRUE
},
89 { TBM_SETBUDDY
, sent
|wparam
, TRUE
},
90 { WM_PAINT
, sent
|defwinproc
},
91 { TBM_SETBUDDY
, sent
|wparam
, TRUE
},
92 { WM_PAINT
, sent
|defwinproc
},
93 { TBM_GETBUDDY
, sent
|wparam
, FALSE
},
94 { TBM_GETBUDDY
, sent
|wparam
, TRUE
},
98 static const struct message parent_buddy_window_test_seq
[] = {
99 { WM_CTLCOLORSTATIC
, sent
},
101 { WM_CTLCOLORSTATIC
, sent
},
103 { WM_CTLCOLORSTATIC
, sent
},
105 { WM_CTLCOLORSTATIC
, sent
},
110 static const struct message line_size_test_seq
[] = {
111 { TBM_SETLINESIZE
, sent
|lparam
, 0, 10},
112 { TBM_SETLINESIZE
, sent
|lparam
, 0, 4},
113 { TBM_GETLINESIZE
, sent
},
117 static const struct message page_size_test_seq
[] = {
118 { TBM_SETPAGESIZE
, sent
|lparam
, 0, 10},
119 { TBM_SETPAGESIZE
, sent
|lparam
, 0, -1},
120 { TBM_GETPAGESIZE
, sent
},
124 static const struct message position_test_seq
[] = {
125 { TBM_SETPOS
, sent
|wparam
|lparam
, TRUE
, -1},
126 { WM_PAINT
, sent
|defwinproc
},
128 { TBM_SETPOS
, sent
|wparam
|lparam
, TRUE
, 5},
129 { WM_PAINT
, sent
|defwinproc
},
131 { TBM_SETPOS
, sent
|wparam
|lparam
, TRUE
, 5},
132 { TBM_SETPOS
, sent
|wparam
|lparam
, TRUE
, 1000},
133 { WM_PAINT
, sent
|defwinproc
},
135 { TBM_SETPOS
, sent
|wparam
|lparam
, FALSE
, 20},
137 { TBM_SETPOS
, sent
|wparam
|lparam
, TRUE
, 20},
142 static const struct message parent_position_test_seq
[] = {
143 { WM_CTLCOLORSTATIC
, sent
},
145 { WM_CTLCOLORSTATIC
, sent
},
147 { WM_CTLCOLORSTATIC
, sent
},
152 static const struct message range_test_seq
[] = {
153 { TBM_SETRANGE
, sent
|wparam
|lparam
, TRUE
, MAKELONG(0, 10)},
154 { WM_PAINT
, sent
|defwinproc
},
155 { TBM_GETRANGEMAX
, sent
},
156 { TBM_GETRANGEMIN
, sent
},
157 { TBM_SETRANGE
, sent
|wparam
|lparam
, TRUE
, MAKELONG(-1, 1000)},
158 { WM_PAINT
, sent
|defwinproc
},
159 { TBM_GETRANGEMAX
, sent
},
160 { TBM_GETRANGEMIN
, sent
},
161 { TBM_SETRANGE
, sent
|wparam
|lparam
, TRUE
, MAKELONG(10, 0)},
162 { WM_PAINT
, sent
|defwinproc
},
163 { TBM_GETRANGEMAX
, sent
},
164 { TBM_GETRANGEMIN
, sent
},
165 { TBM_SETRANGE
, sent
|wparam
|lparam
, FALSE
, MAKELONG(0, 10)},
166 { TBM_GETRANGEMAX
, sent
},
167 { TBM_GETRANGEMIN
, sent
},
168 { TBM_SETRANGEMAX
, sent
|wparam
|lparam
, TRUE
, 10},
169 { WM_PAINT
, sent
|defwinproc
},
170 { TBM_GETRANGEMAX
, sent
},
171 { TBM_SETRANGEMAX
, sent
|wparam
|lparam
, TRUE
, -1},
172 { WM_PAINT
, sent
|defwinproc
},
173 { TBM_GETRANGEMAX
, sent
},
174 { TBM_SETRANGEMAX
, sent
|wparam
|lparam
, FALSE
, 10},
175 { TBM_GETRANGEMAX
, sent
},
176 { TBM_SETRANGEMIN
, sent
|wparam
|lparam
, TRUE
, 0},
177 { WM_PAINT
, sent
|defwinproc
},
178 { TBM_GETRANGEMIN
, sent
},
179 { TBM_SETRANGEMIN
, sent
|wparam
|lparam
, TRUE
, 10},
180 { WM_PAINT
, sent
|defwinproc
},
181 { TBM_GETRANGEMIN
, sent
},
182 { TBM_SETRANGEMIN
, sent
|wparam
|lparam
, TRUE
, -10},
183 { WM_PAINT
, sent
|defwinproc
},
184 { TBM_GETRANGEMIN
, sent
},
185 { TBM_SETRANGEMIN
, sent
|wparam
|lparam
, FALSE
, 5},
186 { TBM_GETRANGEMIN
, sent
},
187 { TBM_GETRANGEMAX
, sent
},
188 { TBM_GETRANGEMIN
, sent
},
192 static const struct message parent_range_test_seq
[] = {
193 { WM_CTLCOLORSTATIC
, sent
},
195 { WM_CTLCOLORSTATIC
, sent
},
197 { WM_CTLCOLORSTATIC
, sent
},
199 { WM_CTLCOLORSTATIC
, sent
},
201 { WM_CTLCOLORSTATIC
, sent
},
203 { WM_CTLCOLORSTATIC
, sent
},
205 { WM_CTLCOLORSTATIC
, sent
},
207 { WM_CTLCOLORSTATIC
, sent
},
212 static const struct message selection_test_seq
[] = {
213 { TBM_SETSEL
, sent
|wparam
|lparam
, TRUE
, MAKELONG(0, 10)},
214 { WM_PAINT
, sent
|defwinproc
},
215 { TBM_GETSELEND
, sent
},
216 { TBM_GETSELSTART
, sent
},
217 { TBM_SETSEL
, sent
|wparam
|lparam
, TRUE
, MAKELONG(5, 20)},
218 { WM_PAINT
, sent
|defwinproc
},
219 { TBM_GETSELEND
, sent
},
220 { TBM_GETSELSTART
, sent
},
221 { TBM_SETSEL
, sent
|wparam
|lparam
, FALSE
, MAKELONG(5, 10)},
222 { TBM_GETSELEND
, sent
},
223 { TBM_GETSELSTART
, sent
},
224 { TBM_SETSELEND
, sent
|wparam
|lparam
, TRUE
, 10},
225 { WM_PAINT
, sent
|defwinproc
},
226 { TBM_GETSELEND
, sent
},
227 { TBM_SETSELEND
, sent
|wparam
|lparam
, TRUE
, 20},
228 { WM_PAINT
, sent
|defwinproc
},
229 { TBM_GETSELEND
, sent
},
230 { TBM_SETSELEND
, sent
|wparam
|lparam
, TRUE
, 4},
231 { WM_PAINT
, sent
|defwinproc
},
232 { TBM_GETSELEND
, sent
},
233 { TBM_SETSELEND
, sent
|wparam
|lparam
, FALSE
, 2},
234 { TBM_GETSELEND
, sent
},
235 { TBM_GETSELEND
, sent
},
236 { TBM_SETSELSTART
, sent
|wparam
|lparam
, TRUE
, 5},
237 { WM_PAINT
, sent
|defwinproc
},
238 { TBM_GETSELSTART
, sent
},
239 { TBM_SETSELSTART
, sent
|wparam
|lparam
, TRUE
, 0},
240 { WM_PAINT
, sent
|defwinproc
},
241 { TBM_GETSELSTART
, sent
},
242 { TBM_SETSELSTART
, sent
|wparam
|lparam
, TRUE
, 20},
243 { WM_PAINT
, sent
|defwinproc
},
244 { TBM_GETSELSTART
, sent
},
245 { TBM_SETSELSTART
, sent
|wparam
|lparam
, FALSE
, 8},
246 { TBM_GETSELSTART
, sent
},
247 { TBM_GETSELSTART
, sent
},
251 static const struct message parent_selection_test_seq
[] = {
252 { WM_CTLCOLORSTATIC
, sent
},
254 { WM_CTLCOLORSTATIC
, sent
},
256 { WM_CTLCOLORSTATIC
, sent
},
258 { WM_CTLCOLORSTATIC
, sent
},
260 { WM_CTLCOLORSTATIC
, sent
},
262 { WM_CTLCOLORSTATIC
, sent
},
264 { WM_CTLCOLORSTATIC
, sent
},
266 { WM_CTLCOLORSTATIC
, sent
},
271 static const struct message tic_settings_test_seq
[] = {
272 { TBM_SETTIC
, sent
|lparam
, 0, 0},
273 { TBM_SETTIC
, sent
|lparam
, 0, 5},
274 { TBM_SETTIC
, sent
|lparam
, 0, 10},
275 { TBM_SETTIC
, sent
|lparam
, 0, 20},
276 { TBM_SETRANGE
, sent
|wparam
|lparam
, TRUE
, MAKELONG(0,10)},
277 { WM_PAINT
, sent
|defwinproc
},
278 { TBM_SETTICFREQ
, sent
|wparam
, 2},
279 { WM_PAINT
, sent
|defwinproc
},
280 { TBM_GETNUMTICS
, sent
},
281 { TBM_SETTICFREQ
, sent
|wparam
, 5},
282 { WM_PAINT
, sent
|defwinproc
},
283 { TBM_GETNUMTICS
, sent
},
284 { TBM_SETTICFREQ
, sent
|wparam
, 15},
285 { WM_PAINT
, sent
|defwinproc
},
286 { TBM_GETNUMTICS
, sent
},
287 { TBM_GETNUMTICS
, sent
},
291 static const struct message parent_tic_settings_test_seq
[] = {
292 { WM_CTLCOLORSTATIC
, sent
},
294 { WM_CTLCOLORSTATIC
, sent
},
296 { WM_CTLCOLORSTATIC
, sent
},
298 { WM_CTLCOLORSTATIC
, sent
},
303 static const struct message thumb_length_test_seq
[] = {
304 { TBM_SETTHUMBLENGTH
, sent
|wparam
|lparam
, 15, 0},
305 { WM_PAINT
, sent
|defwinproc
},
306 { TBM_GETTHUMBLENGTH
, sent
},
307 { TBM_SETTHUMBLENGTH
, sent
|wparam
|lparam
, 20, 0},
308 { WM_PAINT
, sent
|defwinproc
},
309 { TBM_GETTHUMBLENGTH
, sent
},
310 { TBM_GETTHUMBLENGTH
, sent
},
312 { WM_PAINT
, sent
|defwinproc
},
313 { TBM_GETTHUMBLENGTH
, sent
},
315 { WM_PAINT
, sent
|defwinproc
},
316 { TBM_GETTHUMBLENGTH
, sent
},
320 static const struct message parent_thumb_length_test_seq
[] = {
321 { WM_CTLCOLORSTATIC
, sent
},
323 { WM_CTLCOLORSTATIC
, sent
},
325 { WM_CTLCOLORSTATIC
, sent
},
327 { WM_CTLCOLORSTATIC
, sent
},
332 static const struct message tic_placement_test_seq
[] = {
333 { TBM_GETPTICS
, sent
},
334 { TBM_GETTIC
, sent
|wparam
, 0},
335 { TBM_GETTIC
, sent
|wparam
, 2},
336 { TBM_GETTIC
, sent
|wparam
, 4},
337 { TBM_GETTICPOS
, sent
|wparam
, 0},
338 { TBM_GETTICPOS
, sent
|wparam
, 2},
342 static const struct message tool_tips_test_seq
[] = {
343 { TBM_SETTIPSIDE
, sent
|wparam
, TBTS_TOP
},
344 { TBM_SETTIPSIDE
, sent
|wparam
, TBTS_LEFT
},
345 { TBM_SETTIPSIDE
, sent
|wparam
, TBTS_BOTTOM
},
346 { TBM_SETTIPSIDE
, sent
|wparam
, TBTS_RIGHT
},
347 { TBM_SETTOOLTIPS
, sent
},
348 { TBM_GETTOOLTIPS
, sent
},
349 { TBM_SETTOOLTIPS
, sent
},
350 { TBM_GETTOOLTIPS
, sent
},
351 { TBM_SETTOOLTIPS
, sent
},
352 { TBM_GETTOOLTIPS
, sent
},
353 { TBM_GETTOOLTIPS
, sent
},
357 static const struct message unicode_test_seq
[] = {
358 { TBM_SETUNICODEFORMAT
, sent
|wparam
, TRUE
},
359 { TBM_SETUNICODEFORMAT
, sent
|wparam
, FALSE
},
360 { TBM_GETUNICODEFORMAT
, sent
},
364 static const struct message ignore_selection_test_seq
[] = {
365 { TBM_SETSEL
, sent
|wparam
|lparam
, TRUE
, MAKELONG(0,10)},
366 { TBM_GETSELEND
, sent
},
367 { TBM_GETSELSTART
, sent
},
368 { TBM_SETSEL
, sent
|wparam
|lparam
, FALSE
, MAKELONG(0,10)},
369 { TBM_GETSELEND
, sent
},
370 { TBM_GETSELSTART
, sent
},
371 { TBM_SETSELEND
, sent
|wparam
|lparam
, TRUE
,0},
372 { TBM_GETSELEND
, sent
},
373 { TBM_SETSELEND
, sent
|wparam
|lparam
, TRUE
, 10},
374 { TBM_GETSELEND
, sent
},
375 { TBM_SETSELEND
, sent
|wparam
|lparam
, FALSE
,0},
376 { TBM_GETSELEND
, sent
},
377 { TBM_SETSELSTART
, sent
|wparam
|lparam
, TRUE
,0},
378 { TBM_GETSELSTART
, sent
},
379 { TBM_SETSELSTART
, sent
|wparam
|lparam
, TRUE
, 10},
380 { TBM_GETSELSTART
, sent
},
381 { TBM_SETSELSTART
, sent
|wparam
|lparam
, FALSE
,0},
382 { TBM_GETSELSTART
, sent
},
386 static LRESULT WINAPI
parent_wnd_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
){
387 static LONG defwndproc_counter
= 0;
391 /* log system messages, except for painting */
392 if (message
< WM_USER
&&
393 message
!= WM_PAINT
&&
394 message
!= WM_ERASEBKGND
&&
395 message
!= WM_NCPAINT
&&
396 message
!= WM_NCHITTEST
&&
397 message
!= WM_GETTEXT
&&
398 message
!= WM_GETICON
&&
399 message
!= WM_DEVICECHANGE
)
401 msg
.message
= message
;
402 msg
.flags
= sent
|wparam
|lparam
;
403 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
407 add_message(sequences
, PARENT_SEQ_INDEX
, &msg
);
410 defwndproc_counter
++;
411 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
412 defwndproc_counter
--;
417 static BOOL
register_parent_wnd_class(void){
421 cls
.lpfnWndProc
= parent_wnd_proc
;
424 cls
.hInstance
= GetModuleHandleA(NULL
);
426 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
427 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
428 cls
.lpszMenuName
= NULL
;
429 cls
.lpszClassName
= "Trackbar test parent class";
430 return RegisterClassA(&cls
);
433 static HWND
create_parent_window(void){
434 if (!register_parent_wnd_class())
437 return CreateWindowA("Trackbar test parent class", "Trackbar test parent window",
438 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
| WS_VISIBLE
,
439 0, 0, 100, 100, GetDesktopWindow(), NULL
, GetModuleHandleA(NULL
), NULL
);
442 static LRESULT WINAPI
trackbar_subclass_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
){
443 WNDPROC oldproc
= (WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_USERDATA
);
444 static LONG defwndproc_counter
= 0;
448 msg
.message
= message
;
449 msg
.flags
= sent
|wparam
|lparam
;
450 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
454 add_message(sequences
, TRACKBAR_SEQ_INDEX
, &msg
);
456 defwndproc_counter
++;
457 ret
= CallWindowProcA(oldproc
, hwnd
, message
, wParam
, lParam
);
458 defwndproc_counter
--;
463 static HWND
create_trackbar(DWORD style
, HWND parent
){
468 GetClientRect(parent
, &rect
);
469 hWndTrack
= CreateWindowA(TRACKBAR_CLASSA
, "Trackbar Control", style
,
470 rect
.right
, rect
.bottom
, 100, 50,
471 parent
, NULL
, GetModuleHandleA(NULL
), NULL
);
473 if (!hWndTrack
) return NULL
;
475 oldproc
= (WNDPROC
)SetWindowLongPtrA(hWndTrack
, GWLP_WNDPROC
, (LONG_PTR
)trackbar_subclass_proc
);
476 SetWindowLongPtrA(hWndTrack
, GWLP_USERDATA
, (LONG_PTR
)oldproc
);
481 static HWND
create_trackbar2(DWORD style
, HWND parent
)
484 GetClientRect(parent
, &rect
);
485 return CreateWindowA(TRACKBAR_CLASSA
, "Trackbar Control", style
,
486 rect
.right
, rect
.bottom
, 100, 50,
487 parent
, NULL
, GetModuleHandleA(NULL
), NULL
);
490 /* test functions for setters, getters, and sequences */
492 static void test_trackbar_buddy(void)
494 HWND hWndLeftBuddy
, hWndTrackbar
;
496 HWND hWndCurrentBuddy
;
499 hWndTrackbar
= create_trackbar(defaultstyle
, hWndParent
);
500 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
502 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
504 hWndLeftBuddy
= CreateWindowA(STATUSCLASSNAMEA
, NULL
, 0, 0, 0, 300, 20, NULL
, NULL
, NULL
, NULL
);
505 ok(hWndLeftBuddy
!= NULL
, "Expected non NULL value\n");
507 if (hWndLeftBuddy
!= NULL
){
508 hWndCurrentBuddy
= (HWND
) SendMessageA(hWndTrackbar
, TBM_GETBUDDY
, TRUE
, 0);
509 rTest
= (HWND
) SendMessageA(hWndTrackbar
, TBM_SETBUDDY
, FALSE
, (LPARAM
) hWndLeftBuddy
);
510 ok(rTest
== hWndCurrentBuddy
, "Expected hWndCurrentBuddy\n");
511 rTest
= (HWND
) SendMessageA(hWndTrackbar
, TBM_SETBUDDY
, FALSE
, (LPARAM
) hWndLeftBuddy
);
512 ok(rTest
== hWndLeftBuddy
, "Expected hWndLeftBuddy\n");
514 skip ("left buddy control not present?\n");
516 hWndRightBuddy
= CreateWindowA(STATUSCLASSNAMEA
, NULL
, 0, 0, 0, 300, 20, NULL
, NULL
, NULL
, NULL
);
518 ok(hWndRightBuddy
!= NULL
, "expected non NULL value\n");
520 /* test TBM_SETBUDDY */
521 if (hWndRightBuddy
!= NULL
){
522 hWndCurrentBuddy
= (HWND
) SendMessageA(hWndTrackbar
, TBM_GETBUDDY
, TRUE
, 0);
523 rTest
= (HWND
) SendMessageA(hWndTrackbar
, TBM_SETBUDDY
, TRUE
, (LPARAM
) hWndRightBuddy
);
524 ok(rTest
== hWndCurrentBuddy
, "Expected hWndCurrentBuddy\n");
525 rTest
= (HWND
) SendMessageA(hWndTrackbar
, TBM_SETBUDDY
, TRUE
, (LPARAM
) hWndRightBuddy
);
526 ok(rTest
== hWndRightBuddy
, "Expected hWndRightbuddy\n");
528 skip("Right buddy control not present?\n");
530 /* test TBM_GETBUDDY */
531 if (hWndLeftBuddy
!= NULL
){
532 rTest
= (HWND
) SendMessageA(hWndTrackbar
, TBM_GETBUDDY
, FALSE
, 0);
533 ok(rTest
== hWndLeftBuddy
, "Expected hWndLeftBuddy\n");
534 DestroyWindow(hWndLeftBuddy
);
536 if (hWndRightBuddy
!= NULL
){
537 rTest
= (HWND
) SendMessageA(hWndTrackbar
, TBM_GETBUDDY
, TRUE
,0);
538 ok(rTest
== hWndRightBuddy
, "Expected hWndRightBuddy\n");
539 DestroyWindow(hWndRightBuddy
);
542 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, buddy_window_test_seq
, "buddy test sequence", TRUE
);
543 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_buddy_window_test_seq
, "parent buddy test seq", TRUE
);
545 DestroyWindow(hWndTrackbar
);
548 static void test_line_size(void)
553 hWndTrackbar
= create_trackbar(defaultstyle
, hWndParent
);
554 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
556 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
558 /* test TBM_SETLINESIZE */
559 r
= SendMessageA(hWndTrackbar
, TBM_SETLINESIZE
, 0, 10);
561 r
= SendMessageA(hWndTrackbar
, TBM_SETLINESIZE
, 0, 4);
564 /* test TBM_GETLINESIZE */
565 r
= SendMessageA(hWndTrackbar
, TBM_GETLINESIZE
, 0,0);
568 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, line_size_test_seq
, "linesize test sequence", FALSE
);
569 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
, "parent line test sequence", FALSE
);
571 DestroyWindow(hWndTrackbar
);
575 static void test_page_size(void)
580 hWndTrackbar
= create_trackbar(defaultstyle
, hWndParent
);
581 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
583 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
585 /* test TBM_SETPAGESIZE */
586 r
= SendMessageA(hWndTrackbar
, TBM_SETPAGESIZE
, 0, 10);
588 r
= SendMessageA(hWndTrackbar
, TBM_SETPAGESIZE
, 0, -1);
591 /* test TBM_GETPAGESIZE */
592 r
= SendMessageA(hWndTrackbar
, TBM_GETPAGESIZE
, 0,0);
595 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, page_size_test_seq
, "page size test sequence", FALSE
);
596 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
, "parent page size test sequence", FALSE
);
598 /* check for zero page size */
599 r
= SendMessageA(hWndTrackbar
, TBM_SETPAGESIZE
, 0, 0);
601 r
= SendMessageA(hWndTrackbar
, TBM_GETPAGESIZE
, 0, 0);
603 /* revert to default */
604 r
= SendMessageA(hWndTrackbar
, TBM_SETPAGESIZE
, 0, -1);
606 r
= SendMessageA(hWndTrackbar
, TBM_GETPAGESIZE
, 0, 0);
609 r
= SendMessageA(hWndTrackbar
, TBM_SETPAGESIZE
, 0, -2);
611 r
= SendMessageA(hWndTrackbar
, TBM_GETPAGESIZE
, 0, 0);
614 DestroyWindow(hWndTrackbar
);
617 static void test_position(void)
624 hWndTrackbar
= create_trackbar(defaultstyle
, hWndParent
);
625 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
627 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
629 /* test TBM_SETPOS */
630 SendMessageA(hWndTrackbar
, TBM_SETPOS
, TRUE
, -1);
631 r
= SendMessageA(hWndTrackbar
, TBM_GETPOS
, 0, 0);
633 SendMessageA(hWndTrackbar
, TBM_SETPOS
, TRUE
, 5);
634 r
= SendMessageA(hWndTrackbar
, TBM_GETPOS
, 0,0);
636 SendMessageA(hWndTrackbar
, TBM_SETPOS
, TRUE
, 5);
637 SendMessageA(hWndTrackbar
, TBM_SETPOS
, TRUE
, 1000);
638 r
= SendMessageA(hWndTrackbar
, TBM_GETPOS
, 0,0);
640 SendMessageA(hWndTrackbar
, TBM_SETPOS
, FALSE
, 20);
641 r
= SendMessageA(hWndTrackbar
, TBM_GETPOS
, 0,0);
643 SendMessageA(hWndTrackbar
, TBM_SETPOS
, TRUE
, 20);
645 /* test TBM_GETPOS */
646 r
= SendMessageA(hWndTrackbar
, TBM_GETPOS
, 0,0);
649 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, position_test_seq
, "position test sequence", TRUE
);
650 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_position_test_seq
, "parent position test sequence", TRUE
);
652 DestroyWindow(hWndTrackbar
);
654 hWndTrackbar
= create_trackbar2(defaultstyle
, hWndParent
);
655 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
657 /* subclassing procedure blocks WM_PAINT */
658 oldproc
= (WNDPROC
)SetWindowLongPtrA(hWndTrackbar
, GWLP_WNDPROC
, (LONG_PTR
)trackbar_no_wmpaint_proc
);
659 SetWindowLongPtrA(hWndTrackbar
, GWLP_USERDATA
, (LONG_PTR
)oldproc
);
662 SetRectEmpty(&rect2
);
664 SendMessageA(hWndTrackbar
, TBM_GETTHUMBRECT
, 0, (LPARAM
)&rect
);
666 /* without repaint */
667 SendMessageA(hWndTrackbar
, TBM_SETPOS
, FALSE
, 25);
668 r
= SendMessageA(hWndTrackbar
, TBM_GETPOS
, 0, 0);
669 ok(r
== 25, "got %d\n", r
);
670 SendMessageA(hWndTrackbar
, TBM_GETTHUMBRECT
, 0, (LPARAM
)&rect2
);
671 ok(rect
.left
== rect2
.left
, "got %d\n", rect
.left
);
674 SendMessageA(hWndTrackbar
, TBM_SETPOS
, TRUE
, 30);
675 r
= SendMessageA(hWndTrackbar
, TBM_GETPOS
, 0, 0);
676 ok(r
== 30, "got %d\n", r
);
677 SendMessageA(hWndTrackbar
, TBM_GETTHUMBRECT
, 0, (LPARAM
)&rect2
);
678 ok(rect
.left
!= rect2
.left
, "got %d, expected %d\n", rect2
.left
, rect
.left
);
680 /* now move it with keys */
681 SendMessageA(hWndTrackbar
, WM_KEYDOWN
, VK_END
, 0);
682 r
= SendMessageA(hWndTrackbar
, TBM_GETPOS
, 0, 0);
683 ok(r
== 100, "got %d\n", r
);
684 SendMessageA(hWndTrackbar
, TBM_GETTHUMBRECT
, 0, (LPARAM
)&rect
);
685 ok(rect
.left
!= rect2
.left
, "got %d, expected %d\n", rect
.left
, rect2
.left
);
687 DestroyWindow(hWndTrackbar
);
690 static void test_range(void)
696 hWndTrackbar
= create_trackbar(defaultstyle
, hWndParent
);
697 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
699 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
701 /* test TBM_SETRANGE */
702 SendMessageA(hWndTrackbar
, TBM_SETRANGE
, TRUE
, MAKELONG(0, 10));
703 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMAX
, 0,0);
705 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMIN
, 0,0);
707 SendMessageA(hWndTrackbar
, TBM_SETRANGE
, TRUE
, MAKELONG(-1, 1000));
708 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMAX
, 0,0);
710 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMIN
, 0,0);
712 SendMessageA(hWndTrackbar
, TBM_SETRANGE
, TRUE
, MAKELONG(10, 0));
713 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMAX
, 0,0);
715 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMIN
, 0,0);
717 SendMessageA(hWndTrackbar
, TBM_SETRANGE
, FALSE
, MAKELONG(0,10));
718 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMAX
, 0,0);
720 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMIN
, 0,0);
723 /*test TBM_SETRANGEMAX */
724 SendMessageA(hWndTrackbar
, TBM_SETRANGEMAX
, TRUE
, 10);
725 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMAX
, 0,0);
727 SendMessageA(hWndTrackbar
, TBM_SETRANGEMAX
, TRUE
, -1);
728 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMAX
, 0,0);
730 SendMessageA(hWndTrackbar
, TBM_SETRANGEMAX
, FALSE
, 10);
731 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMAX
, 0,0);
734 /* testing TBM_SETRANGEMIN */
735 SendMessageA(hWndTrackbar
, TBM_SETRANGEMIN
, TRUE
, 0);
736 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMIN
, 0,0);
738 SendMessageA(hWndTrackbar
, TBM_SETRANGEMIN
, TRUE
, 10);
739 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMIN
, 0,0);
741 SendMessageA(hWndTrackbar
, TBM_SETRANGEMIN
, TRUE
, -10);
742 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMIN
, 0,0);
744 SendMessageA(hWndTrackbar
, TBM_SETRANGEMIN
, FALSE
, 5);
745 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMIN
, 0,0);
748 /* test TBM_GETRANGEMAX */
749 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMAX
, 0,0);
752 /* test TBM_GETRANGEMIN */
753 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMIN
, 0,0);
756 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, range_test_seq
, "range test sequence", TRUE
);
757 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_range_test_seq
, "parent range test sequence", TRUE
);
759 /* TBM_SETRANGE updates thumb visual position (rectangle) if needed */
760 r
= SendMessageA(hWndTrackbar
, TBM_SETRANGE
, TRUE
, MAKELONG(-10, 0));
761 ok(r
== 0, "got %d\n", r
);
762 SendMessageA(hWndTrackbar
, TBM_SETPOS
, TRUE
, 0);
764 RedrawWindow(hWndTrackbar
, NULL
, 0, RDW_UPDATENOW
);
765 SendMessageA(hWndTrackbar
, TBM_GETTHUMBRECT
, 0, (LPARAM
)&rect1
);
767 r
= SendMessageA(hWndTrackbar
, TBM_SETRANGE
, TRUE
, MAKELONG(-10, 10));
768 ok(r
== 0, "got %d\n", r
);
769 RedrawWindow(hWndTrackbar
, NULL
, 0, RDW_UPDATENOW
);
771 SendMessageA(hWndTrackbar
, TBM_GETTHUMBRECT
, 0, (LPARAM
)&rect2
);
772 ok(!EqualRect(&rect1
, &rect2
), "thumb rectangle not updated\n");
774 /* change range back, don't force repaint */
775 r
= SendMessageA(hWndTrackbar
, TBM_SETRANGE
, FALSE
, MAKELONG(-10, 0));
776 ok(r
== 0, "got %d\n", r
);
778 SendMessageA(hWndTrackbar
, TBM_GETTHUMBRECT
, 0, (LPARAM
)&rect1
);
779 ok(EqualRect(&rect1
, &rect2
), "thumb rectangle not updated\n");
781 /* test position update on range change */
783 /* set to [20, 50], position at 30, reduce range to [20,25] */
784 SendMessageA(hWndTrackbar
, TBM_SETRANGEMIN
, FALSE
, 20);
785 SendMessageA(hWndTrackbar
, TBM_SETRANGEMAX
, FALSE
, 50);
786 SendMessageA(hWndTrackbar
, TBM_SETPOS
, FALSE
, 30);
787 SendMessageA(hWndTrackbar
, TBM_SETRANGEMAX
, FALSE
, 25);
788 r
= SendMessageA(hWndTrackbar
, TBM_GETPOS
, 0, 0);
789 ok(r
== 25, "Unexpected position %d\n", r
);
791 /* set to [20, 50], position at 30, flip max to 10 */
792 SendMessageA(hWndTrackbar
, TBM_SETRANGEMIN
, FALSE
, 20);
793 SendMessageA(hWndTrackbar
, TBM_SETRANGEMAX
, FALSE
, 50);
794 SendMessageA(hWndTrackbar
, TBM_SETPOS
, FALSE
, 30);
795 SendMessageA(hWndTrackbar
, TBM_SETRANGEMAX
, FALSE
, 10);
796 r
= SendMessageA(hWndTrackbar
, TBM_GETPOS
, 0, 0);
797 ok(r
== 20, "Unexpected position %d\n", r
);
799 /* set to [20, 50], position at 30, flip min to 70 */
800 SendMessageA(hWndTrackbar
, TBM_SETRANGEMIN
, FALSE
, 20);
801 SendMessageA(hWndTrackbar
, TBM_SETRANGEMAX
, FALSE
, 50);
802 SendMessageA(hWndTrackbar
, TBM_SETPOS
, FALSE
, 30);
803 SendMessageA(hWndTrackbar
, TBM_SETRANGEMIN
, FALSE
, 70);
804 r
= SendMessageA(hWndTrackbar
, TBM_GETPOS
, 0, 0);
805 ok(r
== 70, "Unexpected position %d\n", r
);
807 DestroyWindow(hWndTrackbar
);
810 static void test_selection(void)
815 hWndTrackbar
= create_trackbar(defaultstyle
, hWndParent
);
816 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
818 SendMessageA(hWndTrackbar
, TBM_SETRANGEMIN
, FALSE
, 5);
819 SendMessageA(hWndTrackbar
, TBM_SETRANGEMAX
, FALSE
, 10);
821 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
823 /* test TBM_SETSEL */
824 SendMessageA(hWndTrackbar
, TBM_SETSEL
, TRUE
, MAKELONG(0,10));
825 r
= SendMessageA(hWndTrackbar
, TBM_GETSELEND
, 0,0);
827 r
= SendMessageA(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
829 SendMessageA(hWndTrackbar
, TBM_SETSEL
, TRUE
, MAKELONG(5, 20));
830 r
= SendMessageA(hWndTrackbar
, TBM_GETSELEND
, 0,0);
832 r
= SendMessageA(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
834 SendMessageA(hWndTrackbar
, TBM_SETSEL
, FALSE
, MAKELONG(5, 10));
835 r
= SendMessageA(hWndTrackbar
, TBM_GETSELEND
, 0,0);
837 r
= SendMessageA(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
840 /* test TBM_SETSELEND */
841 SendMessageA(hWndTrackbar
, TBM_SETSELEND
, TRUE
, 10);
842 r
= SendMessageA(hWndTrackbar
, TBM_GETSELEND
, 0,0);
844 SendMessageA(hWndTrackbar
, TBM_SETSELEND
, TRUE
, 20);
845 r
= SendMessageA(hWndTrackbar
, TBM_GETSELEND
, 0,0);
847 SendMessageA(hWndTrackbar
, TBM_SETSELEND
, TRUE
, 4);
848 r
= SendMessageA(hWndTrackbar
, TBM_GETSELEND
, 0,0);
850 SendMessageA(hWndTrackbar
, TBM_SETSELEND
, FALSE
, 2);
851 r
= SendMessageA(hWndTrackbar
, TBM_GETSELEND
, 0,0);
854 /* test TBM_GETSELEND */
855 r
= SendMessageA(hWndTrackbar
, TBM_GETSELEND
, 0,0);
858 /* testing TBM_SETSELSTART */
859 SendMessageA(hWndTrackbar
, TBM_SETSELSTART
, TRUE
, 5);
860 r
= SendMessageA(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
862 SendMessageA(hWndTrackbar
, TBM_SETSELSTART
, TRUE
, 0);
863 r
= SendMessageA(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
865 SendMessageA(hWndTrackbar
, TBM_SETSELSTART
, TRUE
, 20);
866 r
= SendMessageA(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
868 SendMessageA(hWndTrackbar
, TBM_SETSELSTART
, FALSE
, 8);
869 r
= SendMessageA(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
872 /* test TBM_GETSELSTART */
873 r
= SendMessageA(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
876 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, selection_test_seq
, "selection test sequence", TRUE
);
877 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_selection_test_seq
, "parent selection test sequence", TRUE
);
879 DestroyWindow(hWndTrackbar
);
882 static void test_thumb_length(void)
887 hWndTrackbar
= create_trackbar(defaultstyle
, hWndParent
);
888 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
890 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
892 /* testing TBM_SETTHUMBLENGTH */
893 SendMessageA(hWndTrackbar
, TBM_SETTHUMBLENGTH
, 15, 0);
894 r
= SendMessageA(hWndTrackbar
, TBM_GETTHUMBLENGTH
, 0,0);
896 SendMessageA(hWndTrackbar
, TBM_SETTHUMBLENGTH
, 20, 0);
897 r
= SendMessageA(hWndTrackbar
, TBM_GETTHUMBLENGTH
, 0,0);
900 /* test TBM_GETTHUMBLENGTH */
901 r
= SendMessageA(hWndTrackbar
, TBM_GETTHUMBLENGTH
, 0,0);
904 r
= SendMessageA(hWndTrackbar
, WM_SIZE
, 0,0);
906 r
= SendMessageA(hWndTrackbar
, TBM_GETTHUMBLENGTH
, 0,0);
908 r
= SendMessageA(hWndTrackbar
, WM_SIZE
, 0, MAKELPARAM(50, 50) );
910 r
= SendMessageA(hWndTrackbar
, TBM_GETTHUMBLENGTH
, 0,0);
913 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, thumb_length_test_seq
, "thumb length test sequence", TRUE
);
914 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_thumb_length_test_seq
, "parent thumb length test sequence", TRUE
);
916 DestroyWindow(hWndTrackbar
);
919 static void test_tic_settings(void)
924 hWndTrackbar
= create_trackbar(defaultstyle
, hWndParent
);
925 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
927 SendMessageA(hWndTrackbar
, TBM_SETRANGEMIN
, FALSE
, 5);
928 SendMessageA(hWndTrackbar
, TBM_SETRANGEMAX
, FALSE
, 10);
930 /* testing TBM_SETTIC */
931 /* Set tics at 5 and 10 */
932 /* 0 and 20 are out of range and should not be set */
933 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMAX
, 0, 0);
935 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMIN
, 0, 0);
938 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
939 r
= SendMessageA(hWndTrackbar
, TBM_SETTIC
, 0, 0);
940 ok(r
== FALSE
, "Expected FALSE, got %d\n", r
);
941 r
= SendMessageA(hWndTrackbar
, TBM_SETTIC
, 0, 5);
942 ok(r
== TRUE
, "Expected TRUE, got %d\n", r
);
943 r
= SendMessageA(hWndTrackbar
, TBM_SETTIC
, 0, 10);
944 ok(r
== TRUE
, "Expected TRUE, got %d\n", r
);
946 r
= SendMessageA(hWndTrackbar
, TBM_SETTIC
, 0, 20);
947 ok(r
== FALSE
, "Expected FALSE, got %d\n", r
);
949 /* test TBM_SETTICFREQ */
950 SendMessageA(hWndTrackbar
, TBM_SETRANGE
, TRUE
, MAKELONG(0, 10));
951 SendMessageA(hWndTrackbar
, TBM_SETTICFREQ
, 2, 0);
952 r
= SendMessageA(hWndTrackbar
, TBM_GETNUMTICS
, 0, 0);
954 SendMessageA(hWndTrackbar
, TBM_SETTICFREQ
, 5, 0);
955 r
= SendMessageA(hWndTrackbar
, TBM_GETNUMTICS
, 0, 0);
957 SendMessageA(hWndTrackbar
, TBM_SETTICFREQ
, 15, 0);
958 r
= SendMessageA(hWndTrackbar
, TBM_GETNUMTICS
, 0, 0);
961 /* test TBM_GETNUMTICS */
962 /* since TIC FREQ is 15, there should be only 2 tics now */
963 r
= SendMessageA(hWndTrackbar
, TBM_GETNUMTICS
, 0, 0);
966 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, tic_settings_test_seq
, "tic settings test sequence", TRUE
);
967 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_tic_settings_test_seq
, "parent tic settings test sequence", TRUE
);
969 /* range [0,0], freq = 1 */
970 SendMessageA(hWndTrackbar
, TBM_SETRANGEMAX
, TRUE
, 0);
971 SendMessageA(hWndTrackbar
, TBM_SETRANGEMIN
, TRUE
, 0);
972 SendMessageA(hWndTrackbar
, TBM_SETTICFREQ
, 1, 0);
973 r
= SendMessageA(hWndTrackbar
, TBM_GETNUMTICS
, 0, 0);
975 /* range [0,1], freq = 1 */
976 SendMessageA(hWndTrackbar
, TBM_SETRANGEMAX
, TRUE
, 1);
977 SendMessageA(hWndTrackbar
, TBM_SETRANGEMIN
, TRUE
, 0);
978 SendMessageA(hWndTrackbar
, TBM_SETTICFREQ
, 1, 0);
979 r
= SendMessageA(hWndTrackbar
, TBM_GETNUMTICS
, 0, 0);
981 /* range [0,2], freq = 1 */
982 SendMessageA(hWndTrackbar
, TBM_SETRANGEMAX
, TRUE
, 2);
983 SendMessageA(hWndTrackbar
, TBM_SETRANGEMIN
, TRUE
, 0);
984 SendMessageA(hWndTrackbar
, TBM_SETTICFREQ
, 1, 0);
985 r
= SendMessageA(hWndTrackbar
, TBM_GETNUMTICS
, 0, 0);
988 DestroyWindow(hWndTrackbar
);
990 /* Test to show that TBM_SETTICFREQ updates thumb */
991 for (i
= 0; i
< 2; i
++)
993 DWORD style
= i
? defaultstyle
: defaultstyle
& ~TBS_AUTOTICKS
;
997 hWndTrackbar
= create_trackbar2(style
, hWndParent
);
998 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
1000 oldproc
= (WNDPROC
)SetWindowLongPtrA(hWndTrackbar
, GWLP_WNDPROC
, (LONG_PTR
)trackbar_no_wmpaint_proc
);
1001 SetWindowLongPtrA(hWndTrackbar
, GWLP_USERDATA
, (LONG_PTR
)oldproc
);
1003 SendMessageA(hWndTrackbar
, TBM_GETTHUMBRECT
, 0, (LPARAM
)&rect
);
1004 SendMessageA(hWndTrackbar
, TBM_SETPOS
, FALSE
, 0);
1005 SendMessageA(hWndTrackbar
, TBM_GETTHUMBRECT
, 0, (LPARAM
)&rect1
);
1006 ok(EqualRect(&rect
, &rect1
), "Unexpected thumb rectangle %s, previous %s\n",
1007 wine_dbgstr_rect(&rect1
), wine_dbgstr_rect(&rect
));
1009 SendMessageA(hWndTrackbar
, TBM_GETTHUMBRECT
, 0, (LPARAM
)&rect
);
1010 SendMessageA(hWndTrackbar
, TBM_SETRANGE
, FALSE
, MAKELONG(-100, 100));
1011 SendMessageA(hWndTrackbar
, TBM_GETTHUMBRECT
, 0, (LPARAM
)&rect1
);
1012 ok(EqualRect(&rect
, &rect1
), "Unexpected thumb rectangle %s, previous %s\n",
1013 wine_dbgstr_rect(&rect1
), wine_dbgstr_rect(&rect
));
1014 /* Old position is also 0, but thumb position will be different after range change */
1015 SendMessageA(hWndTrackbar
, TBM_GETTHUMBRECT
, 0, (LPARAM
)&rect
);
1016 SendMessageA(hWndTrackbar
, TBM_SETPOS
, TRUE
, 0);
1017 SendMessageA(hWndTrackbar
, TBM_GETTHUMBRECT
, 0, (LPARAM
)&rect1
);
1018 ok(EqualRect(&rect
, &rect1
), "Unexpected thumb rectangle %s, previous %s\n",
1019 wine_dbgstr_rect(&rect1
), wine_dbgstr_rect(&rect
));
1020 /* Previous frequency is also 1, yet thumb is updated */
1021 SendMessageA(hWndTrackbar
, TBM_GETTHUMBRECT
, 0, (LPARAM
)&rect
);
1022 SendMessageA(hWndTrackbar
, TBM_SETTICFREQ
, 1, 0);
1023 SendMessageA(hWndTrackbar
, TBM_GETTHUMBRECT
, 0, (LPARAM
)&rect1
);
1024 ok(!EqualRect(&rect
, &rect1
), "Unexpected thumb rectangle %s, previous %s\n",
1025 wine_dbgstr_rect(&rect1
), wine_dbgstr_rect(&rect
));
1027 SetWindowLongPtrA(hWndTrackbar
, GWLP_WNDPROC
, (LONG_PTR
)oldproc
);
1029 DestroyWindow(hWndTrackbar
);
1033 static void test_tic_placement(void)
1040 hWndTrackbar
= create_trackbar(defaultstyle
, hWndParent
);
1041 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
1043 SendMessageA(hWndTrackbar
, TBM_SETRANGE
, TRUE
, MAKELONG(1, 6));
1044 SendMessageA(hWndTrackbar
, TBM_SETTICFREQ
, 1, 0);
1046 numtics
= SendMessageA(hWndTrackbar
, TBM_GETNUMTICS
, 0, 0);
1047 ok(numtics
== 6, "Expected 6, got %d\n", numtics
);
1049 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
1050 /* test TBM_GETPTICS */
1051 rPTics
= (DWORD
*) SendMessageA(hWndTrackbar
, TBM_GETPTICS
, 0,0);
1052 expect(2, rPTics
[0]);
1053 expect(3, rPTics
[1]);
1054 expect(4, rPTics
[2]);
1055 expect(5, rPTics
[3]);
1057 /* test TBM_GETTIC */
1058 r
= SendMessageA(hWndTrackbar
, TBM_GETTIC
, 0,0);
1060 r
= SendMessageA(hWndTrackbar
, TBM_GETTIC
, 2,0);
1062 r
= SendMessageA(hWndTrackbar
, TBM_GETTIC
, 4,0);
1065 /* test TBM_GETTICPIC */
1066 r
= SendMessageA(hWndTrackbar
, TBM_GETTICPOS
, 0, 0);
1067 ok(r
> 0, "Expected r > 0, got %d\n", r
);
1068 r
= SendMessageA(hWndTrackbar
, TBM_GETTICPOS
, 2, 0);
1069 ok(r
> 0, "Expected r > 0, got %d\n", r
);
1071 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, tic_placement_test_seq
, "get tic placement test sequence", FALSE
);
1072 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
, "parent get tic placement test sequence", FALSE
);
1074 DestroyWindow(hWndTrackbar
);
1077 static void test_tool_tips(void)
1079 HWND hWndTooltip
, hWndTrackbar
;
1083 hWndTrackbar
= create_trackbar(defaultstyle
, hWndParent
);
1084 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
1086 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
1088 /* testing TBM_SETTIPSIDE */
1089 r
= SendMessageA(hWndTrackbar
, TBM_SETTIPSIDE
, TBTS_TOP
, 0);
1090 expect(TBTS_TOP
, r
);
1091 r
= SendMessageA(hWndTrackbar
, TBM_SETTIPSIDE
, TBTS_LEFT
, 0);
1092 expect(TBTS_TOP
, r
);
1093 r
= SendMessageA(hWndTrackbar
, TBM_SETTIPSIDE
, TBTS_BOTTOM
, 0);
1094 expect(TBTS_LEFT
, r
);
1095 r
= SendMessageA(hWndTrackbar
, TBM_SETTIPSIDE
, TBTS_RIGHT
, 0);
1096 expect(TBTS_BOTTOM
, r
);
1098 /* testing TBM_SETTOOLTIPS */
1099 hWndTooltip
= CreateWindowExA(WS_EX_TOPMOST
, TOOLTIPS_CLASSA
, NULL
, 0,
1100 CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
,
1101 NULL
, NULL
, NULL
, NULL
);
1103 ok(hWndTooltip
!= NULL
, "Expected non NULL value\n");
1104 if (hWndTooltip
!= NULL
){
1105 SendMessageA(hWndTrackbar
, TBM_SETTOOLTIPS
, (LPARAM
) hWndTooltip
, 0);
1106 rTest
= (HWND
) SendMessageA(hWndTrackbar
, TBM_GETTOOLTIPS
, 0,0);
1107 ok(rTest
== hWndTooltip
, "Expected hWndToolTip, got\n");
1108 SendMessageA(hWndTrackbar
, TBM_SETTOOLTIPS
, 0, 0);
1109 rTest
= (HWND
) SendMessageA(hWndTrackbar
, TBM_GETTOOLTIPS
, 0,0);
1110 ok(rTest
== NULL
, "Expected NULL\n");
1111 SendMessageA(hWndTrackbar
, TBM_SETTOOLTIPS
, (LPARAM
) hWndTooltip
, 5);
1112 rTest
= (HWND
) SendMessageA(hWndTrackbar
, TBM_GETTOOLTIPS
, 0,0);
1113 ok(rTest
== hWndTooltip
, "Expected hWndTooltip, got\n");
1115 skip("tool tip control not present?\n");
1117 /* test TBM_GETTOOLTIPS */
1118 rTest
= (HWND
) SendMessageA(hWndTrackbar
, TBM_GETTOOLTIPS
, 0,0);
1119 ok(rTest
== hWndTooltip
, "Expected hWndTooltip\n");
1121 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, tool_tips_test_seq
, "tool tips test sequence", FALSE
);
1122 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
, "parent tool tips test sequence", FALSE
);
1124 DestroyWindow(hWndTrackbar
);
1128 static void test_unicode(void)
1133 hWndTrackbar
= create_trackbar(defaultstyle
, hWndParent
);
1134 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
1136 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
1138 /* testing TBM_SETUNICODEFORMAT */
1139 r
= SendMessageA(hWndTrackbar
, TBM_SETUNICODEFORMAT
, TRUE
, 0);
1140 ok(r
== FALSE
, "Expected FALSE, got %d\n",r
);
1141 r
= SendMessageA(hWndTrackbar
, TBM_SETUNICODEFORMAT
, FALSE
, 0);
1142 ok(r
== TRUE
, "Expected TRUE, got %d\n",r
);
1144 /* test TBM_GETUNICODEFORMAT */
1145 r
= SendMessageA(hWndTrackbar
, TBM_GETUNICODEFORMAT
, 0,0);
1146 ok(r
== FALSE
, "Expected FALSE, got %d\n",r
);
1148 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, unicode_test_seq
, "unicode test sequence", FALSE
);
1149 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
, "parent unicode test sequence", FALSE
);
1151 DestroyWindow(hWndTrackbar
);
1154 static void test_ignore_selection(void)
1159 hWndTrackbar
= create_trackbar(0, hWndParent
);
1160 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
1162 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
1163 /* test TBM_SETSEL ensure that it is ignored */
1164 SendMessageA(hWndTrackbar
, TBM_SETSEL
, TRUE
, MAKELONG(0,10));
1165 r
= SendMessageA(hWndTrackbar
, TBM_GETSELEND
, 0,0);
1167 r
= SendMessageA(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
1169 SendMessageA(hWndTrackbar
, TBM_SETSEL
, FALSE
, MAKELONG(0,10));
1170 r
= SendMessageA(hWndTrackbar
, TBM_GETSELEND
, 0,0);
1172 r
= SendMessageA(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
1175 /* test TBM_SETSELEND, ensure that it is ignored */
1176 SendMessageA(hWndTrackbar
, TBM_SETSELEND
, TRUE
, 0);
1177 r
= SendMessageA(hWndTrackbar
, TBM_GETSELEND
, 0,0);
1179 SendMessageA(hWndTrackbar
, TBM_SETSELEND
, TRUE
, 10);
1180 r
= SendMessageA(hWndTrackbar
, TBM_GETSELEND
, 0,0);
1182 SendMessageA(hWndTrackbar
, TBM_SETSELEND
, FALSE
, 0);
1183 r
= SendMessageA(hWndTrackbar
, TBM_GETSELEND
, 0,0);
1186 /* test TBM_SETSELSTART, ensure that it is ignored */
1187 SendMessageA(hWndTrackbar
, TBM_SETSELSTART
, TRUE
, 0);
1188 r
= SendMessageA(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
1190 SendMessageA(hWndTrackbar
, TBM_SETSELSTART
, TRUE
, 10);
1191 r
= SendMessageA(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
1193 SendMessageA(hWndTrackbar
, TBM_SETSELSTART
, FALSE
, 0);
1194 r
= SendMessageA(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
1197 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, ignore_selection_test_seq
, "ignore selection setting test sequence", FALSE
);
1198 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
, "parent ignore selection setting test sequence", FALSE
);
1200 DestroyWindow(hWndTrackbar
);
1203 static void test_initial_state(void)
1208 hWnd
= create_trackbar(0, hWndParent
);
1210 ret
= SendMessageA(hWnd
, TBM_GETNUMTICS
, 0, 0);
1212 ret
= SendMessageA(hWnd
, TBM_GETTIC
, 0, 0);
1214 ret
= SendMessageA(hWnd
, TBM_GETTICPOS
, 0, 0);
1216 ret
= SendMessageA(hWnd
, TBM_GETRANGEMIN
, 0, 0);
1218 ret
= SendMessageA(hWnd
, TBM_GETRANGEMAX
, 0, 0);
1221 ret
= SendMessageA(hWnd
, TBM_SETRANGEMAX
, TRUE
, 200);
1224 ret
= SendMessageA(hWnd
, TBM_GETNUMTICS
, 0, 0);
1227 ret
= SendMessageA(hWnd
, TBM_SETRANGEMIN
, TRUE
, 10);
1230 ret
= SendMessageA(hWnd
, TBM_GETNUMTICS
, 0, 0);
1233 DestroyWindow(hWnd
);
1236 static void test_TBS_AUTOTICKS(void)
1241 hWnd
= create_trackbar(TBS_AUTOTICKS
, hWndParent
);
1243 ret
= SendMessageA(hWnd
, TBM_GETNUMTICS
, 0, 0);
1245 ret
= SendMessageA(hWnd
, TBM_GETTIC
, 0, 0);
1247 ret
= SendMessageA(hWnd
, TBM_GETTICPOS
, 0, 0);
1249 ret
= SendMessageA(hWnd
, TBM_GETRANGEMIN
, 0, 0);
1251 ret
= SendMessageA(hWnd
, TBM_GETRANGEMAX
, 0, 0);
1254 /* TBM_SETRANGEMAX rebuilds tics */
1255 ret
= SendMessageA(hWnd
, TBM_SETRANGEMAX
, TRUE
, 200);
1257 ret
= SendMessageA(hWnd
, TBM_GETNUMTICS
, 0, 0);
1260 /* TBM_SETRANGEMIN rebuilds tics */
1261 ret
= SendMessageA(hWnd
, TBM_SETRANGEMAX
, TRUE
, 100);
1263 ret
= SendMessageA(hWnd
, TBM_SETRANGEMIN
, TRUE
, 10);
1265 ret
= SendMessageA(hWnd
, TBM_GETNUMTICS
, 0, 0);
1268 ret
= SendMessageA(hWnd
, TBM_SETRANGEMIN
, TRUE
, 0);
1271 /* TBM_SETRANGE rebuilds tics */
1272 ret
= SendMessageA(hWnd
, TBM_SETRANGE
, TRUE
, MAKELONG(10, 200));
1274 ret
= SendMessageA(hWnd
, TBM_GETNUMTICS
, 0, 0);
1277 DestroyWindow(hWnd
);
1280 static void test_create(void)
1284 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
1286 hWndTrackbar
= create_trackbar(defaultstyle
, hWndParent
);
1287 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
1288 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, empty_seq
, "create Trackbar Window", FALSE
);
1289 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_create_trackbar_wnd_seq
, "parent trackbar window", TRUE
);
1291 DestroyWindow(hWndTrackbar
);
1294 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
1295 hWndTrackbar
= create_trackbar(0, hWndParent
);
1296 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
1297 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_new_window_test_seq
, "new trackbar window test sequence", TRUE
);
1298 DestroyWindow(hWndTrackbar
);
1301 START_TEST(trackbar
)
1303 init_msg_sequences(sequences
, NUM_MSG_SEQUENCE
);
1304 InitCommonControls();
1306 /* create parent window */
1307 hWndParent
= create_parent_window();
1308 ok(hWndParent
!= NULL
, "Failed to create parent Window!\n");
1311 skip("parent window not present\n");
1316 test_trackbar_buddy();
1322 test_thumb_length();
1323 test_tic_settings();
1324 test_tic_placement();
1327 test_TBS_AUTOTICKS();
1328 test_ignore_selection();
1329 test_initial_state();
1331 DestroyWindow(hWndParent
);