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
22 #define expect(expected, got) ok(got == expected, "Expected %d, got %d\n", expected, got)
23 #define NUM_MSG_SEQUENCE 2
24 #define PARENT_SEQ_INDEX 0
25 #define TRACKBAR_SEQ_INDEX 1
27 static const DWORD defaultstyle
= WS_VISIBLE
| TBS_TOOLTIPS
| TBS_ENABLESELRANGE
| TBS_FIXEDLENGTH
| TBS_AUTOTICKS
;
28 static HWND hWndParent
;
30 static LRESULT WINAPI
trackbar_no_wmpaint_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
32 WNDPROC oldproc
= (WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_USERDATA
);
34 if (message
== WM_PAINT
)
37 return CallWindowProcA(oldproc
, hwnd
, message
, wParam
, lParam
);
40 static struct msg_sequence
*sequences
[NUM_MSG_SEQUENCE
];
42 static const struct message empty_seq
[] = {
46 static const struct message parent_create_trackbar_wnd_seq
[] = {
47 { WM_NOTIFYFORMAT
, sent
},
48 { WM_QUERYUISTATE
, sent
|optional
},
49 { WM_WINDOWPOSCHANGING
, sent
},
50 { WM_NCACTIVATE
, sent
},
51 { PBT_APMRESUMECRITICAL
, sent
},
52 { WM_WINDOWPOSCHANGING
, sent
},
53 { PBT_APMRESUMESTANDBY
, sent
},
54 { WM_IME_SETCONTEXT
, sent
|optional
},
55 { WM_IME_NOTIFY
, sent
|optional
},
56 { WM_CTLCOLORSTATIC
, sent
},
61 static const struct message parent_new_window_test_seq
[] = {
62 { WM_QUERYNEWPALETTE
, sent
|optional
},
63 { WM_WINDOWPOSCHANGING
, sent
|optional
},
64 { WM_NCACTIVATE
, sent
|optional
},
65 { PBT_APMRESUMECRITICAL
, sent
|optional
},
66 { WM_IME_SETCONTEXT
, sent
|defwinproc
|optional
},
67 { WM_IME_NOTIFY
, sent
|defwinproc
|optional
},
68 { WM_SETFOCUS
, sent
|defwinproc
|optional
},
69 { WM_NOTIFYFORMAT
, sent
},
70 { WM_QUERYUISTATE
, sent
|optional
},
74 static const struct message buddy_window_test_seq
[] = {
75 { TBM_GETBUDDY
, sent
|wparam
, TRUE
},
76 { TBM_SETBUDDY
, sent
|wparam
, FALSE
},
77 { WM_PAINT
, sent
|defwinproc
},
78 { TBM_SETBUDDY
, sent
|wparam
, FALSE
},
79 { WM_PAINT
, sent
|defwinproc
},
80 { TBM_GETBUDDY
, sent
|wparam
, TRUE
},
81 { TBM_SETBUDDY
, sent
|wparam
, TRUE
},
82 { WM_PAINT
, sent
|defwinproc
},
83 { TBM_SETBUDDY
, sent
|wparam
, TRUE
},
84 { WM_PAINT
, sent
|defwinproc
},
85 { TBM_GETBUDDY
, sent
|wparam
, FALSE
},
86 { TBM_GETBUDDY
, sent
|wparam
, TRUE
},
90 static const struct message parent_buddy_window_test_seq
[] = {
91 { WM_CTLCOLORSTATIC
, sent
},
93 { WM_CTLCOLORSTATIC
, sent
},
95 { WM_CTLCOLORSTATIC
, sent
},
97 { WM_CTLCOLORSTATIC
, sent
},
102 static const struct message line_size_test_seq
[] = {
103 { TBM_SETLINESIZE
, sent
|lparam
, 0, 10},
104 { TBM_SETLINESIZE
, sent
|lparam
, 0, 4},
105 { TBM_GETLINESIZE
, sent
},
109 static const struct message page_size_test_seq
[] = {
110 { TBM_SETPAGESIZE
, sent
|lparam
, 0, 10},
111 { TBM_SETPAGESIZE
, sent
|lparam
, 0, -1},
112 { TBM_GETPAGESIZE
, sent
},
116 static const struct message position_test_seq
[] = {
117 { TBM_SETPOS
, sent
|wparam
|lparam
, TRUE
, -1},
118 { WM_PAINT
, sent
|defwinproc
},
120 { TBM_SETPOS
, sent
|wparam
|lparam
, TRUE
, 5},
121 { WM_PAINT
, sent
|defwinproc
},
123 { TBM_SETPOS
, sent
|wparam
|lparam
, TRUE
, 5},
124 { TBM_SETPOS
, sent
|wparam
|lparam
, TRUE
, 1000},
125 { WM_PAINT
, sent
|defwinproc
},
127 { TBM_SETPOS
, sent
|wparam
|lparam
, FALSE
, 20},
129 { TBM_SETPOS
, sent
|wparam
|lparam
, TRUE
, 20},
134 static const struct message parent_position_test_seq
[] = {
135 { WM_CTLCOLORSTATIC
, sent
},
137 { WM_CTLCOLORSTATIC
, sent
},
139 { WM_CTLCOLORSTATIC
, sent
},
144 static const struct message range_test_seq
[] = {
145 { TBM_SETRANGE
, sent
|wparam
|lparam
, TRUE
, MAKELONG(0, 10)},
146 { WM_PAINT
, sent
|defwinproc
},
147 { TBM_GETRANGEMAX
, sent
},
148 { TBM_GETRANGEMIN
, sent
},
149 { TBM_SETRANGE
, sent
|wparam
|lparam
, TRUE
, MAKELONG(-1, 1000)},
150 { WM_PAINT
, sent
|defwinproc
},
151 { TBM_GETRANGEMAX
, sent
},
152 { TBM_GETRANGEMIN
, sent
},
153 { TBM_SETRANGE
, sent
|wparam
|lparam
, TRUE
, MAKELONG(10, 0)},
154 { WM_PAINT
, sent
|defwinproc
},
155 { TBM_GETRANGEMAX
, sent
},
156 { TBM_GETRANGEMIN
, sent
},
157 { TBM_SETRANGE
, sent
|wparam
|lparam
, FALSE
, MAKELONG(0, 10)},
158 { TBM_GETRANGEMAX
, sent
},
159 { TBM_GETRANGEMIN
, sent
},
160 { TBM_SETRANGEMAX
, sent
|wparam
|lparam
, TRUE
, 10},
161 { WM_PAINT
, sent
|defwinproc
},
162 { TBM_GETRANGEMAX
, sent
},
163 { TBM_SETRANGEMAX
, sent
|wparam
|lparam
, TRUE
, -1},
164 { WM_PAINT
, sent
|defwinproc
},
165 { TBM_GETRANGEMAX
, sent
},
166 { TBM_SETRANGEMAX
, sent
|wparam
|lparam
, FALSE
, 10},
167 { TBM_GETRANGEMAX
, sent
},
168 { TBM_SETRANGEMIN
, sent
|wparam
|lparam
, TRUE
, 0},
169 { WM_PAINT
, sent
|defwinproc
},
170 { TBM_GETRANGEMIN
, sent
},
171 { TBM_SETRANGEMIN
, sent
|wparam
|lparam
, TRUE
, 10},
172 { WM_PAINT
, sent
|defwinproc
},
173 { TBM_GETRANGEMIN
, sent
},
174 { TBM_SETRANGEMIN
, sent
|wparam
|lparam
, TRUE
, -10},
175 { WM_PAINT
, sent
|defwinproc
},
176 { TBM_GETRANGEMIN
, sent
},
177 { TBM_SETRANGEMIN
, sent
|wparam
|lparam
, FALSE
, 5},
178 { TBM_GETRANGEMIN
, sent
},
179 { TBM_GETRANGEMAX
, sent
},
180 { TBM_GETRANGEMIN
, sent
},
184 static const struct message parent_range_test_seq
[] = {
185 { WM_CTLCOLORSTATIC
, sent
},
187 { WM_CTLCOLORSTATIC
, sent
},
189 { WM_CTLCOLORSTATIC
, sent
},
191 { WM_CTLCOLORSTATIC
, sent
},
193 { WM_CTLCOLORSTATIC
, sent
},
195 { WM_CTLCOLORSTATIC
, sent
},
197 { WM_CTLCOLORSTATIC
, sent
},
199 { WM_CTLCOLORSTATIC
, sent
},
204 static const struct message selection_test_seq
[] = {
205 { TBM_SETSEL
, sent
|wparam
|lparam
, TRUE
, MAKELONG(0, 10)},
206 { WM_PAINT
, sent
|defwinproc
},
207 { TBM_GETSELEND
, sent
},
208 { TBM_GETSELSTART
, sent
},
209 { TBM_SETSEL
, sent
|wparam
|lparam
, TRUE
, MAKELONG(5, 20)},
210 { WM_PAINT
, sent
|defwinproc
},
211 { TBM_GETSELEND
, sent
},
212 { TBM_GETSELSTART
, sent
},
213 { TBM_SETSEL
, sent
|wparam
|lparam
, FALSE
, MAKELONG(5, 10)},
214 { TBM_GETSELEND
, sent
},
215 { TBM_GETSELSTART
, sent
},
216 { TBM_SETSELEND
, sent
|wparam
|lparam
, TRUE
, 10},
217 { WM_PAINT
, sent
|defwinproc
},
218 { TBM_GETSELEND
, sent
},
219 { TBM_SETSELEND
, sent
|wparam
|lparam
, TRUE
, 20},
220 { WM_PAINT
, sent
|defwinproc
},
221 { TBM_GETSELEND
, sent
},
222 { TBM_SETSELEND
, sent
|wparam
|lparam
, TRUE
, 4},
223 { WM_PAINT
, sent
|defwinproc
},
224 { TBM_GETSELEND
, sent
},
225 { TBM_SETSELEND
, sent
|wparam
|lparam
, FALSE
, 2},
226 { TBM_GETSELEND
, sent
},
227 { TBM_GETSELEND
, sent
},
228 { TBM_SETSELSTART
, sent
|wparam
|lparam
, TRUE
, 5},
229 { WM_PAINT
, sent
|defwinproc
},
230 { TBM_GETSELSTART
, sent
},
231 { TBM_SETSELSTART
, sent
|wparam
|lparam
, TRUE
, 0},
232 { WM_PAINT
, sent
|defwinproc
},
233 { TBM_GETSELSTART
, sent
},
234 { TBM_SETSELSTART
, sent
|wparam
|lparam
, TRUE
, 20},
235 { WM_PAINT
, sent
|defwinproc
},
236 { TBM_GETSELSTART
, sent
},
237 { TBM_SETSELSTART
, sent
|wparam
|lparam
, FALSE
, 8},
238 { TBM_GETSELSTART
, sent
},
239 { TBM_GETSELSTART
, sent
},
243 static const struct message parent_selection_test_seq
[] = {
244 { WM_CTLCOLORSTATIC
, sent
},
246 { WM_CTLCOLORSTATIC
, sent
},
248 { WM_CTLCOLORSTATIC
, sent
},
250 { WM_CTLCOLORSTATIC
, sent
},
252 { WM_CTLCOLORSTATIC
, sent
},
254 { WM_CTLCOLORSTATIC
, sent
},
256 { WM_CTLCOLORSTATIC
, sent
},
258 { WM_CTLCOLORSTATIC
, sent
},
263 static const struct message tic_settings_test_seq
[] = {
264 { TBM_SETTIC
, sent
|lparam
, 0, 0},
265 { TBM_SETTIC
, sent
|lparam
, 0, 5},
266 { TBM_SETTIC
, sent
|lparam
, 0, 10},
267 { TBM_SETTIC
, sent
|lparam
, 0, 20},
268 { TBM_SETRANGE
, sent
|wparam
|lparam
, TRUE
, MAKELONG(0,10)},
269 { WM_PAINT
, sent
|defwinproc
},
270 { TBM_SETTICFREQ
, sent
|wparam
, 2},
271 { WM_PAINT
, sent
|defwinproc
},
272 { TBM_GETNUMTICS
, sent
},
273 { TBM_SETTICFREQ
, sent
|wparam
, 5},
274 { WM_PAINT
, sent
|defwinproc
},
275 { TBM_GETNUMTICS
, sent
},
276 { TBM_SETTICFREQ
, sent
|wparam
, 15},
277 { WM_PAINT
, sent
|defwinproc
},
278 { TBM_GETNUMTICS
, sent
},
279 { TBM_GETNUMTICS
, sent
},
283 static const struct message parent_tic_settings_test_seq
[] = {
284 { WM_CTLCOLORSTATIC
, sent
},
286 { WM_CTLCOLORSTATIC
, sent
},
288 { WM_CTLCOLORSTATIC
, sent
},
290 { WM_CTLCOLORSTATIC
, sent
},
295 static const struct message thumb_length_test_seq
[] = {
296 { TBM_SETTHUMBLENGTH
, sent
|wparam
|lparam
, 15, 0},
297 { WM_PAINT
, sent
|defwinproc
},
298 { TBM_GETTHUMBLENGTH
, sent
},
299 { TBM_SETTHUMBLENGTH
, sent
|wparam
|lparam
, 20, 0},
300 { WM_PAINT
, sent
|defwinproc
},
301 { TBM_GETTHUMBLENGTH
, sent
},
302 { TBM_GETTHUMBLENGTH
, sent
},
304 { WM_PAINT
, sent
|defwinproc
},
305 { TBM_GETTHUMBLENGTH
, sent
},
307 { WM_PAINT
, sent
|defwinproc
},
308 { TBM_GETTHUMBLENGTH
, sent
},
312 static const struct message parent_thumb_length_test_seq
[] = {
313 { WM_CTLCOLORSTATIC
, sent
},
315 { WM_CTLCOLORSTATIC
, sent
},
317 { WM_CTLCOLORSTATIC
, sent
},
319 { WM_CTLCOLORSTATIC
, sent
},
324 static const struct message tic_placement_test_seq
[] = {
325 { TBM_GETPTICS
, sent
},
326 { TBM_GETTIC
, sent
|wparam
, 0},
327 { TBM_GETTIC
, sent
|wparam
, 2},
328 { TBM_GETTIC
, sent
|wparam
, 4},
329 { TBM_GETTICPOS
, sent
|wparam
, 0},
330 { TBM_GETTICPOS
, sent
|wparam
, 2},
334 static const struct message tool_tips_test_seq
[] = {
335 { TBM_SETTIPSIDE
, sent
|wparam
, TBTS_TOP
},
336 { TBM_SETTIPSIDE
, sent
|wparam
, TBTS_LEFT
},
337 { TBM_SETTIPSIDE
, sent
|wparam
, TBTS_BOTTOM
},
338 { TBM_SETTIPSIDE
, sent
|wparam
, TBTS_RIGHT
},
339 { TBM_SETTOOLTIPS
, sent
},
340 { TBM_GETTOOLTIPS
, sent
},
341 { TBM_SETTOOLTIPS
, sent
},
342 { TBM_GETTOOLTIPS
, sent
},
343 { TBM_SETTOOLTIPS
, sent
},
344 { TBM_GETTOOLTIPS
, sent
},
345 { TBM_GETTOOLTIPS
, sent
},
349 static const struct message unicode_test_seq
[] = {
350 { TBM_SETUNICODEFORMAT
, sent
|wparam
, TRUE
},
351 { TBM_SETUNICODEFORMAT
, sent
|wparam
, FALSE
},
352 { TBM_GETUNICODEFORMAT
, sent
},
356 static const struct message ignore_selection_test_seq
[] = {
357 { TBM_SETSEL
, sent
|wparam
|lparam
, TRUE
, MAKELONG(0,10)},
358 { TBM_GETSELEND
, sent
},
359 { TBM_GETSELSTART
, sent
},
360 { TBM_SETSEL
, sent
|wparam
|lparam
, FALSE
, MAKELONG(0,10)},
361 { TBM_GETSELEND
, sent
},
362 { TBM_GETSELSTART
, sent
},
363 { TBM_SETSELEND
, sent
|wparam
|lparam
, TRUE
,0},
364 { TBM_GETSELEND
, sent
},
365 { TBM_SETSELEND
, sent
|wparam
|lparam
, TRUE
, 10},
366 { TBM_GETSELEND
, sent
},
367 { TBM_SETSELEND
, sent
|wparam
|lparam
, FALSE
,0},
368 { TBM_GETSELEND
, sent
},
369 { TBM_SETSELSTART
, sent
|wparam
|lparam
, TRUE
,0},
370 { TBM_GETSELSTART
, sent
},
371 { TBM_SETSELSTART
, sent
|wparam
|lparam
, TRUE
, 10},
372 { TBM_GETSELSTART
, sent
},
373 { TBM_SETSELSTART
, sent
|wparam
|lparam
, FALSE
,0},
374 { TBM_GETSELSTART
, sent
},
378 static LRESULT WINAPI
parent_wnd_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
){
379 static LONG defwndproc_counter
= 0;
383 /* log system messages, except for painting */
384 if (message
< WM_USER
&&
385 message
!= WM_PAINT
&&
386 message
!= WM_ERASEBKGND
&&
387 message
!= WM_NCPAINT
&&
388 message
!= WM_NCHITTEST
&&
389 message
!= WM_GETTEXT
&&
390 message
!= WM_GETICON
&&
391 message
!= WM_DEVICECHANGE
)
393 msg
.message
= message
;
394 msg
.flags
= sent
|wparam
|lparam
;
395 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
399 add_message(sequences
, PARENT_SEQ_INDEX
, &msg
);
402 defwndproc_counter
++;
403 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
404 defwndproc_counter
--;
409 static BOOL
register_parent_wnd_class(void){
413 cls
.lpfnWndProc
= parent_wnd_proc
;
416 cls
.hInstance
= GetModuleHandleA(NULL
);
418 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
419 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
420 cls
.lpszMenuName
= NULL
;
421 cls
.lpszClassName
= "Trackbar test parent class";
422 return RegisterClassA(&cls
);
425 static HWND
create_parent_window(void){
426 if (!register_parent_wnd_class())
429 return CreateWindowA("Trackbar test parent class", "Trackbar test parent window",
430 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
| WS_VISIBLE
,
431 0, 0, 100, 100, GetDesktopWindow(), NULL
, GetModuleHandleA(NULL
), NULL
);
434 static LRESULT WINAPI
trackbar_subclass_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
){
435 WNDPROC oldproc
= (WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_USERDATA
);
436 static LONG defwndproc_counter
= 0;
437 struct message msg
= { 0 };
440 msg
.message
= message
;
441 msg
.flags
= sent
|wparam
|lparam
;
442 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
445 add_message(sequences
, TRACKBAR_SEQ_INDEX
, &msg
);
447 defwndproc_counter
++;
448 ret
= CallWindowProcA(oldproc
, hwnd
, message
, wParam
, lParam
);
449 defwndproc_counter
--;
454 static HWND
create_trackbar(DWORD style
, HWND parent
){
459 GetClientRect(parent
, &rect
);
460 hWndTrack
= CreateWindowA(TRACKBAR_CLASSA
, "Trackbar Control", style
,
461 rect
.right
, rect
.bottom
, 100, 50,
462 parent
, NULL
, GetModuleHandleA(NULL
), NULL
);
464 if (!hWndTrack
) return NULL
;
466 oldproc
= (WNDPROC
)SetWindowLongPtrA(hWndTrack
, GWLP_WNDPROC
, (LONG_PTR
)trackbar_subclass_proc
);
467 SetWindowLongPtrA(hWndTrack
, GWLP_USERDATA
, (LONG_PTR
)oldproc
);
472 static HWND
create_trackbar2(DWORD style
, HWND parent
)
475 GetClientRect(parent
, &rect
);
476 return CreateWindowA(TRACKBAR_CLASSA
, "Trackbar Control", style
,
477 rect
.right
, rect
.bottom
, 100, 50,
478 parent
, NULL
, GetModuleHandleA(NULL
), NULL
);
481 /* test functions for setters, getters, and sequences */
483 static void test_trackbar_buddy(void)
485 HWND hWndLeftBuddy
, hWndTrackbar
;
487 HWND hWndCurrentBuddy
;
490 hWndTrackbar
= create_trackbar(defaultstyle
, hWndParent
);
491 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
493 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
495 hWndLeftBuddy
= CreateWindowA(STATUSCLASSNAMEA
, NULL
, 0, 0, 0, 300, 20, NULL
, NULL
, NULL
, NULL
);
496 ok(hWndLeftBuddy
!= NULL
, "Expected non NULL value\n");
498 if (hWndLeftBuddy
!= NULL
){
499 hWndCurrentBuddy
= (HWND
) SendMessageA(hWndTrackbar
, TBM_GETBUDDY
, TRUE
, 0);
500 rTest
= (HWND
) SendMessageA(hWndTrackbar
, TBM_SETBUDDY
, FALSE
, (LPARAM
) hWndLeftBuddy
);
501 ok(rTest
== hWndCurrentBuddy
, "Expected hWndCurrentBuddy\n");
502 rTest
= (HWND
) SendMessageA(hWndTrackbar
, TBM_SETBUDDY
, FALSE
, (LPARAM
) hWndLeftBuddy
);
503 ok(rTest
== hWndLeftBuddy
, "Expected hWndLeftBuddy\n");
505 skip ("left buddy control not present?\n");
507 hWndRightBuddy
= CreateWindowA(STATUSCLASSNAMEA
, NULL
, 0, 0, 0, 300, 20, NULL
, NULL
, NULL
, NULL
);
509 ok(hWndRightBuddy
!= NULL
, "expected non NULL value\n");
511 /* test TBM_SETBUDDY */
512 if (hWndRightBuddy
!= NULL
){
513 hWndCurrentBuddy
= (HWND
) SendMessageA(hWndTrackbar
, TBM_GETBUDDY
, TRUE
, 0);
514 rTest
= (HWND
) SendMessageA(hWndTrackbar
, TBM_SETBUDDY
, TRUE
, (LPARAM
) hWndRightBuddy
);
515 ok(rTest
== hWndCurrentBuddy
, "Expected hWndCurrentBuddy\n");
516 rTest
= (HWND
) SendMessageA(hWndTrackbar
, TBM_SETBUDDY
, TRUE
, (LPARAM
) hWndRightBuddy
);
517 ok(rTest
== hWndRightBuddy
, "Expected hWndRightbuddy\n");
519 skip("Right buddy control not present?\n");
521 /* test TBM_GETBUDDY */
522 if (hWndLeftBuddy
!= NULL
){
523 rTest
= (HWND
) SendMessageA(hWndTrackbar
, TBM_GETBUDDY
, FALSE
, 0);
524 ok(rTest
== hWndLeftBuddy
, "Expected hWndLeftBuddy\n");
525 DestroyWindow(hWndLeftBuddy
);
527 if (hWndRightBuddy
!= NULL
){
528 rTest
= (HWND
) SendMessageA(hWndTrackbar
, TBM_GETBUDDY
, TRUE
,0);
529 ok(rTest
== hWndRightBuddy
, "Expected hWndRightBuddy\n");
530 DestroyWindow(hWndRightBuddy
);
533 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, buddy_window_test_seq
, "buddy test sequence", TRUE
);
534 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_buddy_window_test_seq
, "parent buddy test seq", TRUE
);
536 DestroyWindow(hWndTrackbar
);
539 static void test_line_size(void)
544 hWndTrackbar
= create_trackbar(defaultstyle
, hWndParent
);
545 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
547 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
549 /* test TBM_SETLINESIZE */
550 r
= SendMessageA(hWndTrackbar
, TBM_SETLINESIZE
, 0, 10);
552 r
= SendMessageA(hWndTrackbar
, TBM_SETLINESIZE
, 0, 4);
555 /* test TBM_GETLINESIZE */
556 r
= SendMessageA(hWndTrackbar
, TBM_GETLINESIZE
, 0,0);
559 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, line_size_test_seq
, "linesize test sequence", FALSE
);
560 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
, "parent line test sequence", FALSE
);
562 DestroyWindow(hWndTrackbar
);
566 static void test_page_size(void)
571 hWndTrackbar
= create_trackbar(defaultstyle
, hWndParent
);
572 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
574 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
576 /* test TBM_SETPAGESIZE */
577 r
= SendMessageA(hWndTrackbar
, TBM_SETPAGESIZE
, 0, 10);
579 r
= SendMessageA(hWndTrackbar
, TBM_SETPAGESIZE
, 0, -1);
582 /* test TBM_GETPAGESIZE */
583 r
= SendMessageA(hWndTrackbar
, TBM_GETPAGESIZE
, 0,0);
586 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, page_size_test_seq
, "page size test sequence", FALSE
);
587 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
, "parent page size test sequence", FALSE
);
589 /* check for zero page size */
590 r
= SendMessageA(hWndTrackbar
, TBM_SETPAGESIZE
, 0, 0);
592 r
= SendMessageA(hWndTrackbar
, TBM_GETPAGESIZE
, 0, 0);
594 /* revert to default */
595 r
= SendMessageA(hWndTrackbar
, TBM_SETPAGESIZE
, 0, -1);
597 r
= SendMessageA(hWndTrackbar
, TBM_GETPAGESIZE
, 0, 0);
600 r
= SendMessageA(hWndTrackbar
, TBM_SETPAGESIZE
, 0, -2);
602 r
= SendMessageA(hWndTrackbar
, TBM_GETPAGESIZE
, 0, 0);
605 DestroyWindow(hWndTrackbar
);
608 static void test_position(void)
615 hWndTrackbar
= create_trackbar(defaultstyle
, hWndParent
);
616 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
618 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
620 /* test TBM_SETPOS */
621 SendMessageA(hWndTrackbar
, TBM_SETPOS
, TRUE
, -1);
622 r
= SendMessageA(hWndTrackbar
, TBM_GETPOS
, 0, 0);
624 SendMessageA(hWndTrackbar
, TBM_SETPOS
, TRUE
, 5);
625 r
= SendMessageA(hWndTrackbar
, TBM_GETPOS
, 0,0);
627 SendMessageA(hWndTrackbar
, TBM_SETPOS
, TRUE
, 5);
628 SendMessageA(hWndTrackbar
, TBM_SETPOS
, TRUE
, 1000);
629 r
= SendMessageA(hWndTrackbar
, TBM_GETPOS
, 0,0);
631 SendMessageA(hWndTrackbar
, TBM_SETPOS
, FALSE
, 20);
632 r
= SendMessageA(hWndTrackbar
, TBM_GETPOS
, 0,0);
634 SendMessageA(hWndTrackbar
, TBM_SETPOS
, TRUE
, 20);
636 /* test TBM_GETPOS */
637 r
= SendMessageA(hWndTrackbar
, TBM_GETPOS
, 0,0);
640 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, position_test_seq
, "position test sequence", TRUE
);
641 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_position_test_seq
, "parent position test sequence", TRUE
);
643 DestroyWindow(hWndTrackbar
);
645 hWndTrackbar
= create_trackbar2(defaultstyle
, hWndParent
);
646 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
648 /* subclassing procedure blocks WM_PAINT */
649 oldproc
= (WNDPROC
)SetWindowLongPtrA(hWndTrackbar
, GWLP_WNDPROC
, (LONG_PTR
)trackbar_no_wmpaint_proc
);
650 SetWindowLongPtrA(hWndTrackbar
, GWLP_USERDATA
, (LONG_PTR
)oldproc
);
653 SetRectEmpty(&rect2
);
655 SendMessageA(hWndTrackbar
, TBM_GETTHUMBRECT
, 0, (LPARAM
)&rect
);
657 /* without repaint */
658 SendMessageA(hWndTrackbar
, TBM_SETPOS
, FALSE
, 25);
659 r
= SendMessageA(hWndTrackbar
, TBM_GETPOS
, 0, 0);
660 ok(r
== 25, "got %d\n", r
);
661 SendMessageA(hWndTrackbar
, TBM_GETTHUMBRECT
, 0, (LPARAM
)&rect2
);
662 ok(rect
.left
== rect2
.left
, "got %d\n", rect
.left
);
665 SendMessageA(hWndTrackbar
, TBM_SETPOS
, TRUE
, 30);
666 r
= SendMessageA(hWndTrackbar
, TBM_GETPOS
, 0, 0);
667 ok(r
== 30, "got %d\n", r
);
668 SendMessageA(hWndTrackbar
, TBM_GETTHUMBRECT
, 0, (LPARAM
)&rect2
);
669 ok(rect
.left
!= rect2
.left
, "got %d, expected %d\n", rect2
.left
, rect
.left
);
671 /* now move it with keys */
672 SendMessageA(hWndTrackbar
, WM_KEYDOWN
, VK_END
, 0);
673 r
= SendMessageA(hWndTrackbar
, TBM_GETPOS
, 0, 0);
674 ok(r
== 100, "got %d\n", r
);
675 SendMessageA(hWndTrackbar
, TBM_GETTHUMBRECT
, 0, (LPARAM
)&rect
);
676 ok(rect
.left
!= rect2
.left
, "got %d, expected %d\n", rect
.left
, rect2
.left
);
678 DestroyWindow(hWndTrackbar
);
681 static void test_range(void)
687 hWndTrackbar
= create_trackbar(defaultstyle
, hWndParent
);
688 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
690 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
692 /* test TBM_SETRANGE */
693 SendMessageA(hWndTrackbar
, TBM_SETRANGE
, TRUE
, MAKELONG(0, 10));
694 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMAX
, 0,0);
696 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMIN
, 0,0);
698 SendMessageA(hWndTrackbar
, TBM_SETRANGE
, TRUE
, MAKELONG(-1, 1000));
699 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMAX
, 0,0);
701 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMIN
, 0,0);
703 SendMessageA(hWndTrackbar
, TBM_SETRANGE
, TRUE
, MAKELONG(10, 0));
704 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMAX
, 0,0);
706 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMIN
, 0,0);
708 SendMessageA(hWndTrackbar
, TBM_SETRANGE
, FALSE
, MAKELONG(0,10));
709 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMAX
, 0,0);
711 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMIN
, 0,0);
714 /*test TBM_SETRANGEMAX */
715 SendMessageA(hWndTrackbar
, TBM_SETRANGEMAX
, TRUE
, 10);
716 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMAX
, 0,0);
718 SendMessageA(hWndTrackbar
, TBM_SETRANGEMAX
, TRUE
, -1);
719 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMAX
, 0,0);
721 SendMessageA(hWndTrackbar
, TBM_SETRANGEMAX
, FALSE
, 10);
722 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMAX
, 0,0);
725 /* testing TBM_SETRANGEMIN */
726 SendMessageA(hWndTrackbar
, TBM_SETRANGEMIN
, TRUE
, 0);
727 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMIN
, 0,0);
729 SendMessageA(hWndTrackbar
, TBM_SETRANGEMIN
, TRUE
, 10);
730 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMIN
, 0,0);
732 SendMessageA(hWndTrackbar
, TBM_SETRANGEMIN
, TRUE
, -10);
733 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMIN
, 0,0);
735 SendMessageA(hWndTrackbar
, TBM_SETRANGEMIN
, FALSE
, 5);
736 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMIN
, 0,0);
739 /* test TBM_GETRANGEMAX */
740 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMAX
, 0,0);
743 /* test TBM_GETRANGEMIN */
744 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMIN
, 0,0);
747 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, range_test_seq
, "range test sequence", TRUE
);
748 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_range_test_seq
, "parent range test sequence", TRUE
);
750 /* TBM_SETRANGE updates thumb visual position (rectangle) if needed */
751 r
= SendMessageA(hWndTrackbar
, TBM_SETRANGE
, TRUE
, MAKELONG(-10, 0));
752 ok(r
== 0, "got %d\n", r
);
753 SendMessageA(hWndTrackbar
, TBM_SETPOS
, TRUE
, 0);
755 RedrawWindow(hWndTrackbar
, NULL
, 0, RDW_UPDATENOW
);
756 SendMessageA(hWndTrackbar
, TBM_GETTHUMBRECT
, 0, (LPARAM
)&rect1
);
758 r
= SendMessageA(hWndTrackbar
, TBM_SETRANGE
, TRUE
, MAKELONG(-10, 10));
759 ok(r
== 0, "got %d\n", r
);
760 RedrawWindow(hWndTrackbar
, NULL
, 0, RDW_UPDATENOW
);
762 SendMessageA(hWndTrackbar
, TBM_GETTHUMBRECT
, 0, (LPARAM
)&rect2
);
763 ok(!EqualRect(&rect1
, &rect2
), "thumb rectangle not updated\n");
765 /* change range back, don't force repaint */
766 r
= SendMessageA(hWndTrackbar
, TBM_SETRANGE
, FALSE
, MAKELONG(-10, 0));
767 ok(r
== 0, "got %d\n", r
);
769 SendMessageA(hWndTrackbar
, TBM_GETTHUMBRECT
, 0, (LPARAM
)&rect1
);
770 ok(EqualRect(&rect1
, &rect2
), "thumb rectangle not updated\n");
772 /* test position update on range change */
774 /* set to [20, 50], position at 30, reduce range to [20,25] */
775 SendMessageA(hWndTrackbar
, TBM_SETRANGEMIN
, FALSE
, 20);
776 SendMessageA(hWndTrackbar
, TBM_SETRANGEMAX
, FALSE
, 50);
777 SendMessageA(hWndTrackbar
, TBM_SETPOS
, FALSE
, 30);
778 SendMessageA(hWndTrackbar
, TBM_SETRANGEMAX
, FALSE
, 25);
779 r
= SendMessageA(hWndTrackbar
, TBM_GETPOS
, 0, 0);
780 ok(r
== 25, "Unexpected position %d\n", r
);
782 /* set to [20, 50], position at 30, flip max to 10 */
783 SendMessageA(hWndTrackbar
, TBM_SETRANGEMIN
, FALSE
, 20);
784 SendMessageA(hWndTrackbar
, TBM_SETRANGEMAX
, FALSE
, 50);
785 SendMessageA(hWndTrackbar
, TBM_SETPOS
, FALSE
, 30);
786 SendMessageA(hWndTrackbar
, TBM_SETRANGEMAX
, FALSE
, 10);
787 r
= SendMessageA(hWndTrackbar
, TBM_GETPOS
, 0, 0);
788 ok(r
== 20, "Unexpected position %d\n", r
);
790 /* set to [20, 50], position at 30, flip min to 70 */
791 SendMessageA(hWndTrackbar
, TBM_SETRANGEMIN
, FALSE
, 20);
792 SendMessageA(hWndTrackbar
, TBM_SETRANGEMAX
, FALSE
, 50);
793 SendMessageA(hWndTrackbar
, TBM_SETPOS
, FALSE
, 30);
794 SendMessageA(hWndTrackbar
, TBM_SETRANGEMIN
, FALSE
, 70);
795 r
= SendMessageA(hWndTrackbar
, TBM_GETPOS
, 0, 0);
796 ok(r
== 70, "Unexpected position %d\n", r
);
798 DestroyWindow(hWndTrackbar
);
801 static void test_selection(void)
806 hWndTrackbar
= create_trackbar(defaultstyle
, hWndParent
);
807 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
809 SendMessageA(hWndTrackbar
, TBM_SETRANGEMIN
, FALSE
, 5);
810 SendMessageA(hWndTrackbar
, TBM_SETRANGEMAX
, FALSE
, 10);
812 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
814 /* test TBM_SETSEL */
815 SendMessageA(hWndTrackbar
, TBM_SETSEL
, TRUE
, MAKELONG(0,10));
816 r
= SendMessageA(hWndTrackbar
, TBM_GETSELEND
, 0,0);
818 r
= SendMessageA(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
820 SendMessageA(hWndTrackbar
, TBM_SETSEL
, TRUE
, MAKELONG(5, 20));
821 r
= SendMessageA(hWndTrackbar
, TBM_GETSELEND
, 0,0);
823 r
= SendMessageA(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
825 SendMessageA(hWndTrackbar
, TBM_SETSEL
, FALSE
, MAKELONG(5, 10));
826 r
= SendMessageA(hWndTrackbar
, TBM_GETSELEND
, 0,0);
828 r
= SendMessageA(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
831 /* test TBM_SETSELEND */
832 SendMessageA(hWndTrackbar
, TBM_SETSELEND
, TRUE
, 10);
833 r
= SendMessageA(hWndTrackbar
, TBM_GETSELEND
, 0,0);
835 SendMessageA(hWndTrackbar
, TBM_SETSELEND
, TRUE
, 20);
836 r
= SendMessageA(hWndTrackbar
, TBM_GETSELEND
, 0,0);
838 SendMessageA(hWndTrackbar
, TBM_SETSELEND
, TRUE
, 4);
839 r
= SendMessageA(hWndTrackbar
, TBM_GETSELEND
, 0,0);
841 SendMessageA(hWndTrackbar
, TBM_SETSELEND
, FALSE
, 2);
842 r
= SendMessageA(hWndTrackbar
, TBM_GETSELEND
, 0,0);
845 /* test TBM_GETSELEND */
846 r
= SendMessageA(hWndTrackbar
, TBM_GETSELEND
, 0,0);
849 /* testing TBM_SETSELSTART */
850 SendMessageA(hWndTrackbar
, TBM_SETSELSTART
, TRUE
, 5);
851 r
= SendMessageA(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
853 SendMessageA(hWndTrackbar
, TBM_SETSELSTART
, TRUE
, 0);
854 r
= SendMessageA(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
856 SendMessageA(hWndTrackbar
, TBM_SETSELSTART
, TRUE
, 20);
857 r
= SendMessageA(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
859 SendMessageA(hWndTrackbar
, TBM_SETSELSTART
, FALSE
, 8);
860 r
= SendMessageA(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
863 /* test TBM_GETSELSTART */
864 r
= SendMessageA(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
867 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, selection_test_seq
, "selection test sequence", TRUE
);
868 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_selection_test_seq
, "parent selection test sequence", TRUE
);
870 DestroyWindow(hWndTrackbar
);
873 static void test_thumb_length(void)
878 hWndTrackbar
= create_trackbar(defaultstyle
, hWndParent
);
879 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
881 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
883 /* testing TBM_SETTHUMBLENGTH */
884 SendMessageA(hWndTrackbar
, TBM_SETTHUMBLENGTH
, 15, 0);
885 r
= SendMessageA(hWndTrackbar
, TBM_GETTHUMBLENGTH
, 0,0);
887 SendMessageA(hWndTrackbar
, TBM_SETTHUMBLENGTH
, 20, 0);
888 r
= SendMessageA(hWndTrackbar
, TBM_GETTHUMBLENGTH
, 0,0);
891 /* test TBM_GETTHUMBLENGTH */
892 r
= SendMessageA(hWndTrackbar
, TBM_GETTHUMBLENGTH
, 0,0);
895 r
= SendMessageA(hWndTrackbar
, WM_SIZE
, 0,0);
897 r
= SendMessageA(hWndTrackbar
, TBM_GETTHUMBLENGTH
, 0,0);
899 r
= SendMessageA(hWndTrackbar
, WM_SIZE
, 0, MAKELPARAM(50, 50) );
901 r
= SendMessageA(hWndTrackbar
, TBM_GETTHUMBLENGTH
, 0,0);
904 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, thumb_length_test_seq
, "thumb length test sequence", TRUE
);
905 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_thumb_length_test_seq
, "parent thumb length test sequence", TRUE
);
907 DestroyWindow(hWndTrackbar
);
910 static void test_tic_settings(void)
915 hWndTrackbar
= create_trackbar(defaultstyle
, hWndParent
);
916 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
918 SendMessageA(hWndTrackbar
, TBM_SETRANGEMIN
, FALSE
, 5);
919 SendMessageA(hWndTrackbar
, TBM_SETRANGEMAX
, FALSE
, 10);
921 /* testing TBM_SETTIC */
922 /* Set tics at 5 and 10 */
923 /* 0 and 20 are out of range and should not be set */
924 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMAX
, 0, 0);
926 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMIN
, 0, 0);
929 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
930 r
= SendMessageA(hWndTrackbar
, TBM_SETTIC
, 0, 0);
931 ok(r
== FALSE
, "Expected FALSE, got %d\n", r
);
932 r
= SendMessageA(hWndTrackbar
, TBM_SETTIC
, 0, 5);
933 ok(r
== TRUE
, "Expected TRUE, got %d\n", r
);
934 r
= SendMessageA(hWndTrackbar
, TBM_SETTIC
, 0, 10);
935 ok(r
== TRUE
, "Expected TRUE, got %d\n", r
);
937 r
= SendMessageA(hWndTrackbar
, TBM_SETTIC
, 0, 20);
938 ok(r
== FALSE
, "Expected FALSE, got %d\n", r
);
940 /* test TBM_SETTICFREQ */
941 SendMessageA(hWndTrackbar
, TBM_SETRANGE
, TRUE
, MAKELONG(0, 10));
942 SendMessageA(hWndTrackbar
, TBM_SETTICFREQ
, 2, 0);
943 r
= SendMessageA(hWndTrackbar
, TBM_GETNUMTICS
, 0, 0);
945 SendMessageA(hWndTrackbar
, TBM_SETTICFREQ
, 5, 0);
946 r
= SendMessageA(hWndTrackbar
, TBM_GETNUMTICS
, 0, 0);
948 SendMessageA(hWndTrackbar
, TBM_SETTICFREQ
, 15, 0);
949 r
= SendMessageA(hWndTrackbar
, TBM_GETNUMTICS
, 0, 0);
952 /* test TBM_GETNUMTICS */
953 /* since TIC FREQ is 15, there should be only 2 tics now */
954 r
= SendMessageA(hWndTrackbar
, TBM_GETNUMTICS
, 0, 0);
957 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, tic_settings_test_seq
, "tic settings test sequence", TRUE
);
958 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_tic_settings_test_seq
, "parent tic settings test sequence", TRUE
);
960 /* range [0,0], freq = 1 */
961 SendMessageA(hWndTrackbar
, TBM_SETRANGEMAX
, TRUE
, 0);
962 SendMessageA(hWndTrackbar
, TBM_SETRANGEMIN
, TRUE
, 0);
963 SendMessageA(hWndTrackbar
, TBM_SETTICFREQ
, 1, 0);
964 r
= SendMessageA(hWndTrackbar
, TBM_GETNUMTICS
, 0, 0);
966 /* range [0,1], freq = 1 */
967 SendMessageA(hWndTrackbar
, TBM_SETRANGEMAX
, TRUE
, 1);
968 SendMessageA(hWndTrackbar
, TBM_SETRANGEMIN
, TRUE
, 0);
969 SendMessageA(hWndTrackbar
, TBM_SETTICFREQ
, 1, 0);
970 r
= SendMessageA(hWndTrackbar
, TBM_GETNUMTICS
, 0, 0);
972 /* range [0,2], freq = 1 */
973 SendMessageA(hWndTrackbar
, TBM_SETRANGEMAX
, TRUE
, 2);
974 SendMessageA(hWndTrackbar
, TBM_SETRANGEMIN
, TRUE
, 0);
975 SendMessageA(hWndTrackbar
, TBM_SETTICFREQ
, 1, 0);
976 r
= SendMessageA(hWndTrackbar
, TBM_GETNUMTICS
, 0, 0);
979 DestroyWindow(hWndTrackbar
);
981 /* Test to show that TBM_SETTICFREQ updates thumb */
982 for (i
= 0; i
< 2; i
++)
984 DWORD style
= i
? defaultstyle
: defaultstyle
& ~TBS_AUTOTICKS
;
988 hWndTrackbar
= create_trackbar2(style
, hWndParent
);
989 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
991 oldproc
= (WNDPROC
)SetWindowLongPtrA(hWndTrackbar
, GWLP_WNDPROC
, (LONG_PTR
)trackbar_no_wmpaint_proc
);
992 SetWindowLongPtrA(hWndTrackbar
, GWLP_USERDATA
, (LONG_PTR
)oldproc
);
994 SendMessageA(hWndTrackbar
, TBM_GETTHUMBRECT
, 0, (LPARAM
)&rect
);
995 SendMessageA(hWndTrackbar
, TBM_SETPOS
, FALSE
, 0);
996 SendMessageA(hWndTrackbar
, TBM_GETTHUMBRECT
, 0, (LPARAM
)&rect1
);
997 ok(EqualRect(&rect
, &rect1
), "Unexpected thumb rectangle %s, previous %s\n",
998 wine_dbgstr_rect(&rect1
), wine_dbgstr_rect(&rect
));
1000 SendMessageA(hWndTrackbar
, TBM_GETTHUMBRECT
, 0, (LPARAM
)&rect
);
1001 SendMessageA(hWndTrackbar
, TBM_SETRANGE
, FALSE
, MAKELONG(-100, 100));
1002 SendMessageA(hWndTrackbar
, TBM_GETTHUMBRECT
, 0, (LPARAM
)&rect1
);
1003 ok(EqualRect(&rect
, &rect1
), "Unexpected thumb rectangle %s, previous %s\n",
1004 wine_dbgstr_rect(&rect1
), wine_dbgstr_rect(&rect
));
1005 /* Old position is also 0, but thumb position will be different after range change */
1006 SendMessageA(hWndTrackbar
, TBM_GETTHUMBRECT
, 0, (LPARAM
)&rect
);
1007 SendMessageA(hWndTrackbar
, TBM_SETPOS
, TRUE
, 0);
1008 SendMessageA(hWndTrackbar
, TBM_GETTHUMBRECT
, 0, (LPARAM
)&rect1
);
1009 ok(EqualRect(&rect
, &rect1
), "Unexpected thumb rectangle %s, previous %s\n",
1010 wine_dbgstr_rect(&rect1
), wine_dbgstr_rect(&rect
));
1011 /* Previous frequency is also 1, yet thumb is updated */
1012 SendMessageA(hWndTrackbar
, TBM_GETTHUMBRECT
, 0, (LPARAM
)&rect
);
1013 SendMessageA(hWndTrackbar
, TBM_SETTICFREQ
, 1, 0);
1014 SendMessageA(hWndTrackbar
, TBM_GETTHUMBRECT
, 0, (LPARAM
)&rect1
);
1015 ok(!EqualRect(&rect
, &rect1
), "Unexpected thumb rectangle %s, previous %s\n",
1016 wine_dbgstr_rect(&rect1
), wine_dbgstr_rect(&rect
));
1018 SetWindowLongPtrA(hWndTrackbar
, GWLP_WNDPROC
, (LONG_PTR
)oldproc
);
1020 DestroyWindow(hWndTrackbar
);
1024 static void test_tic_placement(void)
1031 hWndTrackbar
= create_trackbar(defaultstyle
, hWndParent
);
1032 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
1034 SendMessageA(hWndTrackbar
, TBM_SETRANGE
, TRUE
, MAKELONG(1, 6));
1035 SendMessageA(hWndTrackbar
, TBM_SETTICFREQ
, 1, 0);
1037 numtics
= SendMessageA(hWndTrackbar
, TBM_GETNUMTICS
, 0, 0);
1038 ok(numtics
== 6, "Expected 6, got %d\n", numtics
);
1040 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
1041 /* test TBM_GETPTICS */
1042 rPTics
= (DWORD
*) SendMessageA(hWndTrackbar
, TBM_GETPTICS
, 0,0);
1043 expect(2, rPTics
[0]);
1044 expect(3, rPTics
[1]);
1045 expect(4, rPTics
[2]);
1046 expect(5, rPTics
[3]);
1048 /* test TBM_GETTIC */
1049 r
= SendMessageA(hWndTrackbar
, TBM_GETTIC
, 0,0);
1051 r
= SendMessageA(hWndTrackbar
, TBM_GETTIC
, 2,0);
1053 r
= SendMessageA(hWndTrackbar
, TBM_GETTIC
, 4,0);
1056 /* test TBM_GETTICPIC */
1057 r
= SendMessageA(hWndTrackbar
, TBM_GETTICPOS
, 0, 0);
1058 ok(r
> 0, "Expected r > 0, got %d\n", r
);
1059 r
= SendMessageA(hWndTrackbar
, TBM_GETTICPOS
, 2, 0);
1060 ok(r
> 0, "Expected r > 0, got %d\n", r
);
1062 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, tic_placement_test_seq
, "get tic placement test sequence", FALSE
);
1063 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
, "parent get tic placement test sequence", FALSE
);
1065 DestroyWindow(hWndTrackbar
);
1068 static void test_tool_tips(void)
1070 HWND hWndTooltip
, hWndTrackbar
;
1074 hWndTrackbar
= create_trackbar(defaultstyle
, hWndParent
);
1075 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
1077 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
1079 /* testing TBM_SETTIPSIDE */
1080 r
= SendMessageA(hWndTrackbar
, TBM_SETTIPSIDE
, TBTS_TOP
, 0);
1081 expect(TBTS_TOP
, r
);
1082 r
= SendMessageA(hWndTrackbar
, TBM_SETTIPSIDE
, TBTS_LEFT
, 0);
1083 expect(TBTS_TOP
, r
);
1084 r
= SendMessageA(hWndTrackbar
, TBM_SETTIPSIDE
, TBTS_BOTTOM
, 0);
1085 expect(TBTS_LEFT
, r
);
1086 r
= SendMessageA(hWndTrackbar
, TBM_SETTIPSIDE
, TBTS_RIGHT
, 0);
1087 expect(TBTS_BOTTOM
, r
);
1089 /* testing TBM_SETTOOLTIPS */
1090 hWndTooltip
= CreateWindowExA(WS_EX_TOPMOST
, TOOLTIPS_CLASSA
, NULL
, 0,
1091 CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
,
1092 NULL
, NULL
, NULL
, NULL
);
1094 ok(hWndTooltip
!= NULL
, "Expected non NULL value\n");
1095 if (hWndTooltip
!= NULL
){
1096 SendMessageA(hWndTrackbar
, TBM_SETTOOLTIPS
, (LPARAM
) hWndTooltip
, 0);
1097 rTest
= (HWND
) SendMessageA(hWndTrackbar
, TBM_GETTOOLTIPS
, 0,0);
1098 ok(rTest
== hWndTooltip
, "Expected hWndToolTip, got\n");
1099 SendMessageA(hWndTrackbar
, TBM_SETTOOLTIPS
, 0, 0);
1100 rTest
= (HWND
) SendMessageA(hWndTrackbar
, TBM_GETTOOLTIPS
, 0,0);
1101 ok(rTest
== NULL
, "Expected NULL\n");
1102 SendMessageA(hWndTrackbar
, TBM_SETTOOLTIPS
, (LPARAM
) hWndTooltip
, 5);
1103 rTest
= (HWND
) SendMessageA(hWndTrackbar
, TBM_GETTOOLTIPS
, 0,0);
1104 ok(rTest
== hWndTooltip
, "Expected hWndTooltip, got\n");
1106 skip("tool tip control not present?\n");
1108 /* test TBM_GETTOOLTIPS */
1109 rTest
= (HWND
) SendMessageA(hWndTrackbar
, TBM_GETTOOLTIPS
, 0,0);
1110 ok(rTest
== hWndTooltip
, "Expected hWndTooltip\n");
1112 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, tool_tips_test_seq
, "tool tips test sequence", FALSE
);
1113 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
, "parent tool tips test sequence", FALSE
);
1115 DestroyWindow(hWndTrackbar
);
1119 static void test_unicode(void)
1124 hWndTrackbar
= create_trackbar(defaultstyle
, hWndParent
);
1125 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
1127 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
1129 /* testing TBM_SETUNICODEFORMAT */
1130 r
= SendMessageA(hWndTrackbar
, TBM_SETUNICODEFORMAT
, TRUE
, 0);
1131 ok(r
== FALSE
, "Expected FALSE, got %d\n",r
);
1132 r
= SendMessageA(hWndTrackbar
, TBM_SETUNICODEFORMAT
, FALSE
, 0);
1133 ok(r
== TRUE
, "Expected TRUE, got %d\n",r
);
1135 /* test TBM_GETUNICODEFORMAT */
1136 r
= SendMessageA(hWndTrackbar
, TBM_GETUNICODEFORMAT
, 0,0);
1137 ok(r
== FALSE
, "Expected FALSE, got %d\n",r
);
1139 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, unicode_test_seq
, "unicode test sequence", FALSE
);
1140 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
, "parent unicode test sequence", FALSE
);
1142 DestroyWindow(hWndTrackbar
);
1145 static void test_ignore_selection(void)
1150 hWndTrackbar
= create_trackbar(0, hWndParent
);
1151 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
1153 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
1154 /* test TBM_SETSEL ensure that it is ignored */
1155 SendMessageA(hWndTrackbar
, TBM_SETSEL
, TRUE
, MAKELONG(0,10));
1156 r
= SendMessageA(hWndTrackbar
, TBM_GETSELEND
, 0,0);
1158 r
= SendMessageA(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
1160 SendMessageA(hWndTrackbar
, TBM_SETSEL
, FALSE
, MAKELONG(0,10));
1161 r
= SendMessageA(hWndTrackbar
, TBM_GETSELEND
, 0,0);
1163 r
= SendMessageA(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
1166 /* test TBM_SETSELEND, ensure that it is ignored */
1167 SendMessageA(hWndTrackbar
, TBM_SETSELEND
, TRUE
, 0);
1168 r
= SendMessageA(hWndTrackbar
, TBM_GETSELEND
, 0,0);
1170 SendMessageA(hWndTrackbar
, TBM_SETSELEND
, TRUE
, 10);
1171 r
= SendMessageA(hWndTrackbar
, TBM_GETSELEND
, 0,0);
1173 SendMessageA(hWndTrackbar
, TBM_SETSELEND
, FALSE
, 0);
1174 r
= SendMessageA(hWndTrackbar
, TBM_GETSELEND
, 0,0);
1177 /* test TBM_SETSELSTART, ensure that it is ignored */
1178 SendMessageA(hWndTrackbar
, TBM_SETSELSTART
, TRUE
, 0);
1179 r
= SendMessageA(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
1181 SendMessageA(hWndTrackbar
, TBM_SETSELSTART
, TRUE
, 10);
1182 r
= SendMessageA(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
1184 SendMessageA(hWndTrackbar
, TBM_SETSELSTART
, FALSE
, 0);
1185 r
= SendMessageA(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
1188 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, ignore_selection_test_seq
, "ignore selection setting test sequence", FALSE
);
1189 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
, "parent ignore selection setting test sequence", FALSE
);
1191 DestroyWindow(hWndTrackbar
);
1194 static void test_initial_state(void)
1199 hWnd
= create_trackbar(0, hWndParent
);
1201 ret
= SendMessageA(hWnd
, TBM_GETNUMTICS
, 0, 0);
1203 ret
= SendMessageA(hWnd
, TBM_GETTIC
, 0, 0);
1205 ret
= SendMessageA(hWnd
, TBM_GETTICPOS
, 0, 0);
1207 ret
= SendMessageA(hWnd
, TBM_GETRANGEMIN
, 0, 0);
1209 ret
= SendMessageA(hWnd
, TBM_GETRANGEMAX
, 0, 0);
1212 ret
= SendMessageA(hWnd
, TBM_SETRANGEMAX
, TRUE
, 200);
1215 ret
= SendMessageA(hWnd
, TBM_GETNUMTICS
, 0, 0);
1218 ret
= SendMessageA(hWnd
, TBM_SETRANGEMIN
, TRUE
, 10);
1221 ret
= SendMessageA(hWnd
, TBM_GETNUMTICS
, 0, 0);
1224 DestroyWindow(hWnd
);
1227 static void test_TBS_AUTOTICKS(void)
1232 hWnd
= create_trackbar(TBS_AUTOTICKS
, hWndParent
);
1234 ret
= SendMessageA(hWnd
, TBM_GETNUMTICS
, 0, 0);
1236 ret
= SendMessageA(hWnd
, TBM_GETTIC
, 0, 0);
1238 ret
= SendMessageA(hWnd
, TBM_GETTICPOS
, 0, 0);
1240 ret
= SendMessageA(hWnd
, TBM_GETRANGEMIN
, 0, 0);
1242 ret
= SendMessageA(hWnd
, TBM_GETRANGEMAX
, 0, 0);
1245 /* TBM_SETRANGEMAX rebuilds tics */
1246 ret
= SendMessageA(hWnd
, TBM_SETRANGEMAX
, TRUE
, 200);
1248 ret
= SendMessageA(hWnd
, TBM_GETNUMTICS
, 0, 0);
1251 /* TBM_SETRANGEMIN rebuilds tics */
1252 ret
= SendMessageA(hWnd
, TBM_SETRANGEMAX
, TRUE
, 100);
1254 ret
= SendMessageA(hWnd
, TBM_SETRANGEMIN
, TRUE
, 10);
1256 ret
= SendMessageA(hWnd
, TBM_GETNUMTICS
, 0, 0);
1259 ret
= SendMessageA(hWnd
, TBM_SETRANGEMIN
, TRUE
, 0);
1262 /* TBM_SETRANGE rebuilds tics */
1263 ret
= SendMessageA(hWnd
, TBM_SETRANGE
, TRUE
, MAKELONG(10, 200));
1265 ret
= SendMessageA(hWnd
, TBM_GETNUMTICS
, 0, 0);
1268 DestroyWindow(hWnd
);
1271 static void test_create(void)
1275 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
1277 hWndTrackbar
= create_trackbar(defaultstyle
, hWndParent
);
1278 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
1279 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, empty_seq
, "create Trackbar Window", FALSE
);
1280 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_create_trackbar_wnd_seq
, "parent trackbar window", TRUE
);
1282 DestroyWindow(hWndTrackbar
);
1285 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
1286 hWndTrackbar
= create_trackbar(0, hWndParent
);
1287 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
1288 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_new_window_test_seq
, "new trackbar window test sequence", TRUE
);
1289 DestroyWindow(hWndTrackbar
);
1292 START_TEST(trackbar
)
1294 init_msg_sequences(sequences
, NUM_MSG_SEQUENCE
);
1295 InitCommonControls();
1297 /* create parent window */
1298 hWndParent
= create_parent_window();
1299 ok(hWndParent
!= NULL
, "Failed to create parent Window!\n");
1302 skip("parent window not present\n");
1307 test_trackbar_buddy();
1313 test_thumb_length();
1314 test_tic_settings();
1315 test_tic_placement();
1318 test_TBS_AUTOTICKS();
1319 test_ignore_selection();
1320 test_initial_state();
1322 DestroyWindow(hWndParent
);