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
25 #include "wine/test.h"
28 #define expect(expected, got) ok(got == expected, "Expected %d, got %d\n", expected, got)
29 #define NUM_MSG_SEQUENCE 2
30 #define PARENT_SEQ_INDEX 0
31 #define TRACKBAR_SEQ_INDEX 1
34 static struct msg_sequence
*sequences
[NUM_MSG_SEQUENCE
];
36 static const struct message create_parent_wnd_seq
[] = {
37 { WM_GETMINMAXINFO
, sent
},
38 { WM_NCCREATE
, sent
},
39 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
41 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
42 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
43 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
44 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
45 { WM_NCACTIVATE
, sent
|wparam
, 1 },
46 { WM_ACTIVATE
, sent
|wparam
, 1 },
47 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
48 { WM_IME_NOTIFY
, sent
|defwinproc
|optional
},
49 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
50 /* Win9x adds SWP_NOZORDER below */
51 { WM_WINDOWPOSCHANGED
, sent
, /*|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE*/ },
52 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
58 static const struct message create_trackbar_wnd_seq
[] = {
62 static const struct message parent_empty_test_seq
[] = {
66 static const struct message parent_create_trackbar_wnd_seq
[] = {
67 { WM_NOTIFYFORMAT
, sent
},
68 { 0x0129, sent
}, /* should be WM_QUERYUISTATE instead of 0x0129 */
69 { WM_WINDOWPOSCHANGING
, sent
},
70 { WM_NCACTIVATE
, sent
},
71 { PBT_APMRESUMECRITICAL
, sent
},
72 { WM_WINDOWPOSCHANGING
, sent
},
73 { PBT_APMRESUMESTANDBY
, sent
},
74 { WM_IME_SETCONTEXT
, sent
|optional
},
75 { WM_IME_NOTIFY
, sent
|optional
},
76 { WM_CTLCOLORSTATIC
, sent
},
81 static const struct message parent_new_window_test_seq
[] = {
82 { WM_WINDOWPOSCHANGING
, sent
},
83 { WM_NCACTIVATE
, sent
},
84 { PBT_APMRESUMECRITICAL
, sent
},
85 { WM_IME_SETCONTEXT
, sent
|defwinproc
|optional
},
86 { WM_IME_NOTIFY
, sent
|defwinproc
|optional
},
87 { WM_SETFOCUS
, sent
|defwinproc
},
88 { WM_NOTIFYFORMAT
, sent
},
89 { 0x0129, sent
}, /* should be WM_QUERYUISTATE instead of 0x0129*/
93 static const struct message buddy_window_test_seq
[] = {
94 { TBM_GETBUDDY
, sent
|wparam
, TRUE
},
95 { TBM_SETBUDDY
, sent
|wparam
, FALSE
},
96 { WM_PAINT
, sent
|defwinproc
},
97 { TBM_SETBUDDY
, sent
|wparam
, FALSE
},
98 { WM_PAINT
, sent
|defwinproc
},
99 { TBM_GETBUDDY
, sent
|wparam
, TRUE
},
100 { TBM_SETBUDDY
, sent
|wparam
, TRUE
},
101 { WM_PAINT
, sent
|defwinproc
},
102 { TBM_SETBUDDY
, sent
|wparam
, TRUE
},
103 { WM_PAINT
, sent
|defwinproc
},
104 { TBM_GETBUDDY
, sent
|wparam
, FALSE
},
105 { TBM_GETBUDDY
, sent
|wparam
, TRUE
},
109 static const struct message parent_buddy_window_test_seq
[] = {
110 { WM_CTLCOLORSTATIC
, sent
},
112 { WM_CTLCOLORSTATIC
, sent
},
114 { WM_CTLCOLORSTATIC
, sent
},
116 { WM_CTLCOLORSTATIC
, sent
},
121 static const struct message line_size_test_seq
[] = {
122 { TBM_SETLINESIZE
, sent
|lparam
, 0, 10},
123 { TBM_SETLINESIZE
, sent
|lparam
, 0, 4},
124 { TBM_GETLINESIZE
, sent
},
128 static const struct message page_size_test_seq
[] = {
129 { TBM_SETPAGESIZE
, sent
|lparam
, 0, 10},
130 { TBM_SETPAGESIZE
, sent
|lparam
, 0, -1},
131 { TBM_GETPAGESIZE
, sent
},
135 static const struct message position_test_seq
[] = {
136 { TBM_SETPOS
, sent
|wparam
|lparam
, TRUE
, -1},
137 { WM_PAINT
, sent
|defwinproc
},
139 { TBM_SETPOS
, sent
|wparam
|lparam
, TRUE
, 5},
140 { WM_PAINT
, sent
|defwinproc
},
142 { TBM_SETPOS
, sent
|wparam
|lparam
, TRUE
, 1000},
143 { WM_PAINT
, sent
|defwinproc
},
145 { TBM_SETPOS
, sent
|wparam
|lparam
, FALSE
, 20},
151 static const struct message parent_position_test_seq
[] = {
152 { WM_CTLCOLORSTATIC
, sent
},
154 { WM_CTLCOLORSTATIC
, sent
},
156 { WM_CTLCOLORSTATIC
, sent
},
161 static const struct message range_test_seq
[] = {
162 { TBM_SETRANGE
, sent
|wparam
|lparam
, TRUE
, MAKELONG(0, 10)},
163 { WM_PAINT
, sent
|defwinproc
},
164 { TBM_GETRANGEMAX
, sent
},
165 { TBM_GETRANGEMIN
, sent
},
166 { TBM_SETRANGE
, sent
|wparam
|lparam
, TRUE
, MAKELONG(-1, 1000)},
167 { WM_PAINT
, sent
|defwinproc
},
168 { TBM_GETRANGEMAX
, sent
},
169 { TBM_GETRANGEMIN
, sent
},
170 { TBM_SETRANGE
, sent
|wparam
|lparam
, TRUE
, MAKELONG(10, 0)},
171 { WM_PAINT
, sent
|defwinproc
},
172 { TBM_GETRANGEMAX
, sent
},
173 { TBM_GETRANGEMIN
, sent
},
174 { TBM_SETRANGE
, sent
|wparam
|lparam
, FALSE
, MAKELONG(0, 10)},
175 { TBM_GETRANGEMAX
, sent
},
176 { TBM_GETRANGEMIN
, sent
},
177 { TBM_SETRANGEMAX
, sent
|wparam
|lparam
, TRUE
, 10},
178 { WM_PAINT
, sent
|defwinproc
},
179 { TBM_GETRANGEMAX
, sent
},
180 { TBM_SETRANGEMAX
, sent
|wparam
|lparam
, TRUE
, -1},
181 { WM_PAINT
, sent
|defwinproc
},
182 { TBM_GETRANGEMAX
, sent
},
183 { TBM_SETRANGEMAX
, sent
|wparam
|lparam
, FALSE
, 10},
184 { TBM_GETRANGEMAX
, sent
},
185 { TBM_SETRANGEMIN
, sent
|wparam
|lparam
, TRUE
, 0},
186 { WM_PAINT
, sent
|defwinproc
},
187 { TBM_GETRANGEMIN
, sent
},
188 { TBM_SETRANGEMIN
, sent
|wparam
|lparam
, TRUE
, 10},
189 { WM_PAINT
, sent
|defwinproc
},
190 { TBM_GETRANGEMIN
, sent
},
191 { TBM_SETRANGEMIN
, sent
|wparam
|lparam
, TRUE
, -10},
192 { WM_PAINT
, sent
|defwinproc
},
193 { TBM_GETRANGEMIN
, sent
},
194 { TBM_SETRANGEMIN
, sent
|wparam
|lparam
, FALSE
, 5},
195 { TBM_GETRANGEMIN
, sent
},
196 { TBM_GETRANGEMAX
, sent
},
197 { TBM_GETRANGEMIN
, sent
},
201 static const struct message parent_range_test_seq
[] = {
202 { WM_CTLCOLORSTATIC
, sent
},
204 { WM_CTLCOLORSTATIC
, sent
},
206 { WM_CTLCOLORSTATIC
, sent
},
208 { WM_CTLCOLORSTATIC
, sent
},
210 { WM_CTLCOLORSTATIC
, sent
},
212 { WM_CTLCOLORSTATIC
, sent
},
214 { WM_CTLCOLORSTATIC
, sent
},
216 { WM_CTLCOLORSTATIC
, sent
},
221 static const struct message selection_test_seq
[] = {
222 { TBM_SETSEL
, sent
|wparam
|lparam
, TRUE
, MAKELONG(0, 10)},
223 { WM_PAINT
, sent
|defwinproc
},
224 { TBM_GETSELEND
, sent
},
225 { TBM_GETSELSTART
, sent
},
226 { TBM_SETSEL
, sent
|wparam
|lparam
, TRUE
, MAKELONG(5, 20)},
227 { WM_PAINT
, sent
|defwinproc
},
228 { TBM_GETSELEND
, sent
},
229 { TBM_GETSELSTART
, sent
},
230 { TBM_SETSEL
, sent
|wparam
|lparam
, FALSE
, MAKELONG(5, 10)},
231 { TBM_GETSELEND
, sent
},
232 { TBM_GETSELSTART
, sent
},
233 { TBM_SETSELEND
, sent
|wparam
|lparam
, TRUE
, 10},
234 { WM_PAINT
, sent
|defwinproc
},
235 { TBM_GETSELEND
, sent
},
236 { TBM_SETSELEND
, sent
|wparam
|lparam
, TRUE
, 20},
237 { WM_PAINT
, sent
|defwinproc
},
238 { TBM_GETSELEND
, sent
},
239 { TBM_SETSELEND
, sent
|wparam
|lparam
, TRUE
, 4},
240 { WM_PAINT
, sent
|defwinproc
},
241 { TBM_GETSELEND
, sent
},
242 { TBM_SETSELEND
, sent
|wparam
|lparam
, FALSE
, 2},
243 { TBM_GETSELEND
, sent
},
244 { TBM_GETSELEND
, sent
},
245 { TBM_SETSELSTART
, sent
|wparam
|lparam
, TRUE
, 5},
246 { WM_PAINT
, sent
|defwinproc
},
247 { TBM_GETSELSTART
, sent
},
248 { TBM_SETSELSTART
, sent
|wparam
|lparam
, TRUE
, 0},
249 { WM_PAINT
, sent
|defwinproc
},
250 { TBM_GETSELSTART
, sent
},
251 { TBM_SETSELSTART
, sent
|wparam
|lparam
, TRUE
, 20},
252 { WM_PAINT
, sent
|defwinproc
},
253 { TBM_GETSELSTART
, sent
},
254 { TBM_SETSELSTART
, sent
|wparam
|lparam
, FALSE
, 8},
255 { TBM_GETSELSTART
, sent
},
256 { TBM_GETSELSTART
, sent
},
260 static const struct message parent_selection_test_seq
[] = {
261 { WM_CTLCOLORSTATIC
, sent
},
263 { WM_CTLCOLORSTATIC
, sent
},
265 { WM_CTLCOLORSTATIC
, sent
},
267 { WM_CTLCOLORSTATIC
, sent
},
269 { WM_CTLCOLORSTATIC
, sent
},
271 { WM_CTLCOLORSTATIC
, sent
},
273 { WM_CTLCOLORSTATIC
, sent
},
275 { WM_CTLCOLORSTATIC
, sent
},
280 static const struct message tic_settings_test_seq
[] = {
281 { TBM_SETTIC
, sent
|lparam
, 0, 0},
282 { TBM_SETTIC
, sent
|lparam
, 0, 5},
283 { TBM_SETTIC
, sent
|lparam
, 0, 10},
284 { TBM_SETTIC
, sent
|lparam
, 0, 20},
285 { TBM_SETRANGE
, sent
|wparam
|lparam
, TRUE
, MAKELONG(0,10)},
286 { WM_PAINT
, sent
|defwinproc
},
287 { TBM_SETTICFREQ
, sent
|wparam
, 2},
288 { WM_PAINT
, sent
|defwinproc
},
289 { TBM_GETNUMTICS
, sent
},
290 { TBM_SETTICFREQ
, sent
|wparam
, 5},
291 { WM_PAINT
, sent
|defwinproc
},
292 { TBM_GETNUMTICS
, sent
},
293 { TBM_SETTICFREQ
, sent
|wparam
, 15},
294 { WM_PAINT
, sent
|defwinproc
},
295 { TBM_GETNUMTICS
, sent
},
296 { TBM_GETNUMTICS
, sent
},
300 static const struct message parent_tic_settings_test_seq
[] = {
301 { WM_CTLCOLORSTATIC
, sent
},
303 { WM_CTLCOLORSTATIC
, sent
},
305 { WM_CTLCOLORSTATIC
, sent
},
307 { WM_CTLCOLORSTATIC
, sent
},
312 static const struct message thumb_length_test_seq
[] = {
313 { TBM_SETTHUMBLENGTH
, sent
|wparam
|lparam
, 15, 0},
314 { WM_PAINT
, sent
|defwinproc
},
315 { TBM_GETTHUMBLENGTH
, sent
},
316 { TBM_SETTHUMBLENGTH
, sent
|wparam
|lparam
, 20, 0},
317 { WM_PAINT
, sent
|defwinproc
},
318 { TBM_GETTHUMBLENGTH
, sent
},
319 { TBM_GETTHUMBLENGTH
, sent
},
323 static const struct message parent_thumb_length_test_seq
[] = {
324 { WM_CTLCOLORSTATIC
, sent
},
326 { WM_CTLCOLORSTATIC
, sent
},
331 static const struct message tic_placement_test_seq
[] = {
332 { TBM_GETPTICS
, sent
},
333 { TBM_GETTIC
, sent
|wparam
, 0},
334 { TBM_GETTIC
, sent
|wparam
, 2},
335 { TBM_GETTIC
, sent
|wparam
, 4},
336 { TBM_GETTICPOS
, sent
|wparam
, 0},
337 { TBM_GETTICPOS
, sent
|wparam
, 2},
341 static const struct message tool_tips_test_seq
[] = {
342 { TBM_SETTIPSIDE
, sent
|wparam
, TBTS_TOP
},
343 { TBM_SETTIPSIDE
, sent
|wparam
, TBTS_LEFT
},
344 { TBM_SETTIPSIDE
, sent
|wparam
, TBTS_BOTTOM
},
345 { TBM_SETTIPSIDE
, sent
|wparam
, TBTS_RIGHT
},
346 { TBM_SETTOOLTIPS
, sent
},
347 { TBM_GETTOOLTIPS
, sent
},
348 { TBM_SETTOOLTIPS
, sent
},
349 { TBM_GETTOOLTIPS
, sent
},
350 { TBM_SETTOOLTIPS
, sent
},
351 { TBM_GETTOOLTIPS
, sent
},
352 { TBM_GETTOOLTIPS
, sent
},
356 static const struct message unicode_test_seq
[] = {
357 { TBM_SETUNICODEFORMAT
, sent
|wparam
, TRUE
},
358 { TBM_SETUNICODEFORMAT
, sent
|wparam
, FALSE
},
359 { TBM_GETUNICODEFORMAT
, sent
},
363 static const struct message ignore_selection_test_seq
[] = {
364 { TBM_SETSEL
, sent
|wparam
|lparam
, TRUE
, MAKELONG(0,10)},
365 { TBM_GETSELEND
, sent
},
366 { TBM_GETSELSTART
, sent
},
367 { TBM_SETSEL
, sent
|wparam
|lparam
, FALSE
, MAKELONG(0,10)},
368 { TBM_GETSELEND
, sent
},
369 { TBM_GETSELSTART
, sent
},
370 { TBM_SETSELEND
, sent
|wparam
|lparam
, TRUE
,0},
371 { TBM_GETSELEND
, sent
},
372 { TBM_SETSELEND
, sent
|wparam
|lparam
, TRUE
, 10},
373 { TBM_GETSELEND
, sent
},
374 { TBM_SETSELEND
, sent
|wparam
|lparam
, FALSE
,0},
375 { TBM_GETSELEND
, sent
},
376 { TBM_SETSELSTART
, sent
|wparam
|lparam
, TRUE
,0},
377 { TBM_GETSELSTART
, sent
},
378 { TBM_SETSELSTART
, sent
|wparam
|lparam
, TRUE
, 10},
379 { TBM_GETSELSTART
, sent
},
380 { TBM_SETSELSTART
, sent
|wparam
|lparam
, FALSE
,0},
381 { TBM_GETSELSTART
, sent
},
390 static LRESULT WINAPI
parent_wnd_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
){
391 static long defwndproc_counter
= 0;
395 /* do not log painting messages */
396 if (message
!= WM_PAINT
&&
397 message
!= WM_ERASEBKGND
&&
398 message
!= WM_NCPAINT
&&
399 message
!= WM_NCHITTEST
&&
400 message
!= WM_GETTEXT
&&
401 message
!= WM_GETICON
&&
402 message
!= WM_DEVICECHANGE
)
404 trace("parent: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
406 msg
.message
= message
;
407 msg
.flags
= sent
|wparam
|lparam
;
408 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
411 add_message(sequences
, PARENT_SEQ_INDEX
, &msg
);
414 defwndproc_counter
++;
415 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
416 defwndproc_counter
--;
421 static BOOL
register_parent_wnd_class(void){
425 cls
.lpfnWndProc
= parent_wnd_proc
;
428 cls
.hInstance
= GetModuleHandleA(NULL
);
430 cls
.hCursor
= LoadCursorA(0, (LPSTR
)IDC_ARROW
);
431 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
432 cls
.lpszMenuName
= NULL
;
433 cls
.lpszClassName
= "Trackbar test parent class";
434 return RegisterClassA(&cls
);
437 static HWND
create_parent_window(void){
438 if (!register_parent_wnd_class())
441 return CreateWindowEx(0, "Trackbar test parent class",
442 "Trackbar test parent window",
443 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
444 WS_MAXIMIZEBOX
| WS_VISIBLE
,
446 GetDesktopWindow(), NULL
, GetModuleHandleA(NULL
), NULL
);
449 static LRESULT WINAPI
trackbar_subclass_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
){
450 struct subclass_info
*info
= (struct subclass_info
*) GetWindowLongPtrA(hwnd
, GWLP_USERDATA
);
451 static long defwndproc_counter
= 0;
455 trace("trackbar: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
457 msg
.message
= message
;
458 msg
.flags
= sent
|wparam
|lparam
;
459 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
462 add_message(sequences
, TRACKBAR_SEQ_INDEX
, &msg
);
464 defwndproc_counter
++;
465 ret
= CallWindowProcA(info
->oldproc
, hwnd
, message
, wParam
, lParam
);
466 defwndproc_counter
--;
471 static HWND
create_trackbar(DWORD style
, HWND parent
){
472 struct subclass_info
*info
;
476 info
= HeapAlloc(GetProcessHeap(), 0, sizeof(struct subclass_info
));
480 GetClientRect(parent
, &rect
);
481 hWndTrack
= CreateWindowEx(
482 0, TRACKBAR_CLASS
,"Trackbar Control", style
,
483 rect
.right
,rect
.bottom
, 100, 50,
484 parent
, NULL
,GetModuleHandleA(NULL
) ,NULL
);
488 HeapFree(GetProcessHeap(), 0, info
);
492 info
->oldproc
= (WNDPROC
)SetWindowLongPtrA(hWndTrack
, GWLP_WNDPROC
, (LONG_PTR
)trackbar_subclass_proc
);
494 SetWindowLongPtrA(hWndTrack
, GWLP_USERDATA
, (LONG_PTR
)info
);
499 /* test functions for setters, getters, and sequences */
501 static void test_trackbar_buddy(HWND hWndTrackbar
){
504 HWND hWndCurrentBuddy
;
507 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
509 hWndLeftBuddy
= (HWND
) CreateWindowEx(0, STATUSCLASSNAME
, NULL
, 0,
510 0,0,300,20, NULL
, NULL
, NULL
, NULL
);
511 ok(hWndLeftBuddy
!= NULL
, "Expected non NULL value\n");
513 if (hWndLeftBuddy
!= NULL
){
514 hWndCurrentBuddy
= (HWND
) SendMessage(hWndTrackbar
, TBM_GETBUDDY
, TRUE
, 0);
515 rTest
= (HWND
) SendMessage(hWndTrackbar
, TBM_SETBUDDY
, FALSE
, (LPARAM
) hWndLeftBuddy
);
516 ok(rTest
== hWndCurrentBuddy
, "Expected hWndCurrentBuddy\n");
517 rTest
= (HWND
) SendMessage(hWndTrackbar
, TBM_SETBUDDY
, FALSE
, (LPARAM
) hWndLeftBuddy
);
518 ok(rTest
== hWndLeftBuddy
, "Expected hWndLeftBuddy\n");
520 skip ("left buddy control not present?\n");
522 hWndRightBuddy
= (HWND
) CreateWindowEx(0, STATUSCLASSNAME
, NULL
, 0,
523 0,0,300,20,NULL
,NULL
, NULL
, NULL
);
525 ok(hWndRightBuddy
!= NULL
, "expected non NULL value\n");
527 /* test TBM_SETBUDDY */
528 if (hWndRightBuddy
!= NULL
){
529 hWndCurrentBuddy
= (HWND
) SendMessage(hWndTrackbar
, TBM_GETBUDDY
, TRUE
, 0);
530 rTest
= (HWND
) SendMessage(hWndTrackbar
, TBM_SETBUDDY
, TRUE
, (LPARAM
) hWndRightBuddy
);
531 ok(rTest
== hWndCurrentBuddy
, "Expected hWndCurrentBuddy\n");
532 rTest
= (HWND
) SendMessage(hWndTrackbar
, TBM_SETBUDDY
, TRUE
, (LPARAM
) hWndRightBuddy
);
533 ok(rTest
== hWndRightBuddy
, "Expected hWndRightbuddy\n");
535 skip("Right buddy control not present?\n");
537 /* test TBM_GETBUDDY */
538 if (hWndLeftBuddy
!= NULL
){
539 rTest
= (HWND
) SendMessage(hWndTrackbar
, TBM_GETBUDDY
, FALSE
, 0);
540 ok(rTest
== hWndLeftBuddy
, "Expected hWndLeftBuddy\n");
541 DestroyWindow(hWndLeftBuddy
);
543 if (hWndRightBuddy
!= NULL
){
544 rTest
= (HWND
) SendMessage(hWndTrackbar
, TBM_GETBUDDY
, TRUE
,0);
545 ok(rTest
== hWndRightBuddy
, "Expected hWndRightBuddy\n");
546 DestroyWindow(hWndRightBuddy
);
549 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, buddy_window_test_seq
, "buddy test sequence", TRUE
);
550 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_buddy_window_test_seq
, "parent buddy test seq", TRUE
);
554 static void test_line_size(HWND hWndTrackbar
){
557 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
559 /* test TBM_SETLINESIZE */
560 r
= SendMessage(hWndTrackbar
, TBM_SETLINESIZE
, 0, 10);
561 r
= SendMessage(hWndTrackbar
, TBM_SETLINESIZE
, 0, 4);
564 /* test TBM_GETLINESIZE */
565 r
= SendMessage(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
, parent_empty_test_seq
, "parent line test sequence", FALSE
);
573 static void test_page_size(HWND hWndTrackbar
){
576 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
578 /* test TBM_SETPAGESIZE */
579 r
= SendMessage(hWndTrackbar
, TBM_SETPAGESIZE
, 0, 10);
581 r
= SendMessage(hWndTrackbar
, TBM_SETPAGESIZE
, 0, -1);
584 /* test TBM_GETPAGESIZE */
585 r
= SendMessage(hWndTrackbar
, TBM_GETPAGESIZE
, 0,0);
590 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, page_size_test_seq
, "page size test sequence", FALSE
);
591 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_empty_test_seq
, "parent page size test sequence", FALSE
);
594 static void test_position(HWND hWndTrackbar
){
597 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
598 /* test TBM_SETPOS */
599 SendMessage(hWndTrackbar
, TBM_SETPOS
, TRUE
, -1);
600 r
= SendMessage(hWndTrackbar
, TBM_GETPOS
, 0, 0);
602 SendMessage(hWndTrackbar
, TBM_SETPOS
, TRUE
, 5);
603 r
= SendMessage(hWndTrackbar
, TBM_GETPOS
, 0,0);
605 SendMessage(hWndTrackbar
, TBM_SETPOS
, TRUE
, 1000);
606 r
= SendMessage(hWndTrackbar
, TBM_GETPOS
, 0,0);
608 SendMessage(hWndTrackbar
, TBM_SETPOS
, FALSE
, 20);
609 r
= SendMessage(hWndTrackbar
, TBM_GETPOS
, 0,0);
612 /* test TBM_GETPOS */
613 r
= SendMessage(hWndTrackbar
, TBM_GETPOS
, 0,0);
616 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, position_test_seq
, "position test sequence", TRUE
);
617 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_position_test_seq
, "parent position test sequence", TRUE
);
620 static void test_range(HWND hWndTrackbar
){
623 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
624 /* test TBM_SETRANGE */
625 SendMessage(hWndTrackbar
, TBM_SETRANGE
, TRUE
, MAKELONG(0, 10));
626 r
= SendMessage(hWndTrackbar
, TBM_GETRANGEMAX
, 0,0);
628 r
= SendMessage(hWndTrackbar
, TBM_GETRANGEMIN
, 0,0);
630 SendMessage(hWndTrackbar
, TBM_SETRANGE
, TRUE
, MAKELONG(-1, 1000));
631 r
= SendMessage(hWndTrackbar
, TBM_GETRANGEMAX
, 0,0);
633 r
= SendMessage(hWndTrackbar
, TBM_GETRANGEMIN
, 0,0);
635 SendMessage(hWndTrackbar
, TBM_SETRANGE
, TRUE
, MAKELONG(10, 0));
636 r
= SendMessage(hWndTrackbar
, TBM_GETRANGEMAX
, 0,0);
638 r
= SendMessage(hWndTrackbar
, TBM_GETRANGEMIN
, 0,0);
640 SendMessage(hWndTrackbar
, TBM_SETRANGE
, FALSE
, MAKELONG(0,10));
641 r
= SendMessage(hWndTrackbar
, TBM_GETRANGEMAX
, 0,0);
643 r
= SendMessage(hWndTrackbar
, TBM_GETRANGEMIN
, 0,0);
646 /*test TBM_SETRANGEMAX */
647 SendMessage(hWndTrackbar
, TBM_SETRANGEMAX
, TRUE
, 10);
648 r
= SendMessage(hWndTrackbar
, TBM_GETRANGEMAX
, 0,0);
650 SendMessage(hWndTrackbar
, TBM_SETRANGEMAX
, TRUE
, -1);
651 r
= SendMessage(hWndTrackbar
, TBM_GETRANGEMAX
, 0,0);
653 SendMessage(hWndTrackbar
, TBM_SETRANGEMAX
, FALSE
, 10);
654 r
= SendMessage(hWndTrackbar
, TBM_GETRANGEMAX
, 0,0);
657 /* testing TBM_SETRANGEMIN */
658 SendMessage(hWndTrackbar
, TBM_SETRANGEMIN
, TRUE
, 0);
659 r
= SendMessage(hWndTrackbar
, TBM_GETRANGEMIN
, 0,0);
661 SendMessage(hWndTrackbar
, TBM_SETRANGEMIN
, TRUE
, 10);
662 r
= SendMessage(hWndTrackbar
, TBM_GETRANGEMIN
, 0,0);
664 SendMessage(hWndTrackbar
, TBM_SETRANGEMIN
, TRUE
, -10);
665 r
= SendMessage(hWndTrackbar
, TBM_GETRANGEMIN
, 0,0);
667 SendMessage(hWndTrackbar
, TBM_SETRANGEMIN
, FALSE
, 5);
668 r
= SendMessage(hWndTrackbar
, TBM_GETRANGEMIN
, 0,0);
671 /* test TBM_GETRANGEMAX */
672 r
= SendMessage(hWndTrackbar
, TBM_GETRANGEMAX
, 0,0);
675 /* test TBM_GETRANGEMIN */
676 r
= SendMessage(hWndTrackbar
, TBM_GETRANGEMIN
, 0,0);
679 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, range_test_seq
, "range test sequence", TRUE
);
680 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_range_test_seq
, "parent range test sequence", TRUE
);
683 static void test_selection(HWND hWndTrackbar
){
686 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
687 /* test TBM_SETSEL */
688 SendMessage(hWndTrackbar
, TBM_SETSEL
, TRUE
, MAKELONG(0,10));
689 r
= SendMessage(hWndTrackbar
, TBM_GETSELEND
, 0,0);
691 r
= SendMessage(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
693 SendMessage(hWndTrackbar
, TBM_SETSEL
, TRUE
, MAKELONG(5, 20));
694 r
= SendMessage(hWndTrackbar
, TBM_GETSELEND
, 0,0);
696 r
= SendMessage(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
698 SendMessage(hWndTrackbar
, TBM_SETSEL
, FALSE
, MAKELONG(5, 10));
699 r
= SendMessage(hWndTrackbar
, TBM_GETSELEND
, 0,0);
701 r
= SendMessage(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
704 /* test TBM_SETSELEND */
705 SendMessage(hWndTrackbar
, TBM_SETSELEND
, TRUE
, 10);
706 r
= SendMessage(hWndTrackbar
, TBM_GETSELEND
, 0,0);
708 SendMessage(hWndTrackbar
, TBM_SETSELEND
, TRUE
, 20);
709 r
= SendMessage(hWndTrackbar
, TBM_GETSELEND
, 0,0);
711 SendMessage(hWndTrackbar
, TBM_SETSELEND
, TRUE
, 4);
712 r
= SendMessage(hWndTrackbar
, TBM_GETSELEND
, 0,0);
714 SendMessage(hWndTrackbar
, TBM_SETSELEND
, FALSE
, 2);
715 r
= SendMessage(hWndTrackbar
, TBM_GETSELEND
, 0,0);
718 /* test TBM_GETSELEND */
719 r
= SendMessage(hWndTrackbar
, TBM_GETSELEND
, 0,0);
722 /* testing TBM_SETSELSTART */
723 SendMessage(hWndTrackbar
, TBM_SETSELSTART
, TRUE
, 5);
724 r
= SendMessage(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
726 SendMessage(hWndTrackbar
, TBM_SETSELSTART
, TRUE
, 0);
727 r
= SendMessage(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
729 SendMessage(hWndTrackbar
, TBM_SETSELSTART
, TRUE
, 20);
730 r
= SendMessage(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
732 SendMessage(hWndTrackbar
, TBM_SETSELSTART
, FALSE
, 8);
733 r
= SendMessage(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
736 /* test TBM_GETSELSTART */
737 r
= SendMessage(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
740 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, selection_test_seq
, "selection test sequence", TRUE
);
741 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_selection_test_seq
, "parent selection test seqence", TRUE
);
744 static void test_thumb_length(HWND hWndTrackbar
){
747 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
748 /* testing TBM_SETTHUMBLENGTH */
749 SendMessage(hWndTrackbar
, TBM_SETTHUMBLENGTH
, 15, 0);
750 r
= SendMessage(hWndTrackbar
, TBM_GETTHUMBLENGTH
, 0,0);
752 SendMessage(hWndTrackbar
, TBM_SETTHUMBLENGTH
, 20, 0);
753 r
= SendMessage(hWndTrackbar
, TBM_GETTHUMBLENGTH
, 0,0);
756 /* test TBM_GETTHUMBLENGTH */
757 r
= SendMessage(hWndTrackbar
, TBM_GETTHUMBLENGTH
, 0,0);
760 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, thumb_length_test_seq
, "thumb length test sequence", TRUE
);
761 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_thumb_length_test_seq
, "parent thumb lenth test sequence", TRUE
);
764 static void test_tic_settings(HWND hWndTrackbar
){
767 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
768 /* testing TBM_SETTIC */
769 /* Set tics at 5 and 10 */
770 /* 0 and 20 are out of range and should not be set */
771 r
= SendMessage(hWndTrackbar
, TBM_SETTIC
, 0, 0);
772 ok(r
== FALSE
, "Expected FALSE, got %d\n", r
);
773 r
= SendMessage(hWndTrackbar
, TBM_SETTIC
, 0, 5);
775 ok(r
== TRUE
, "Expected TRUE, got %d\n", r
);
776 r
= SendMessage(hWndTrackbar
, TBM_SETTIC
, 0, 10);
777 ok(r
== TRUE
, "Expected TRUE, got %d\n", r
);
779 r
= SendMessage(hWndTrackbar
, TBM_SETTIC
, 0, 20);
780 ok(r
== FALSE
, "Expected False, got %d\n", r
);
782 /* test TBM_SETTICFREQ */
783 SendMessage(hWndTrackbar
, TBM_SETRANGE
, TRUE
, MAKELONG(0, 10));
784 SendMessage(hWndTrackbar
, TBM_SETTICFREQ
, 2, 0);
785 r
= SendMessage(hWndTrackbar
, TBM_GETNUMTICS
, 0,0);
787 SendMessage(hWndTrackbar
, TBM_SETTICFREQ
, 5, 0);
788 r
= SendMessage(hWndTrackbar
, TBM_GETNUMTICS
, 0,0);
790 SendMessage(hWndTrackbar
, TBM_SETTICFREQ
, 15, 0);
791 r
= SendMessage(hWndTrackbar
, TBM_GETNUMTICS
, 0,0);
794 /* test TBM_GETNUMTICS */
795 /* since TIC FREQ is 15, there should be only 2 tics now */
796 r
= SendMessage(hWndTrackbar
, TBM_GETNUMTICS
, 0,0);
799 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, tic_settings_test_seq
, "tic settings test sequence", TRUE
);
800 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_tic_settings_test_seq
, "parent tic settings test sequence", TRUE
);
803 static void test_tic_placement(HWND hWndTrackbar
){
808 SendMessage(hWndTrackbar
, TBM_SETRANGE
, TRUE
, MAKELONG(1, 6));
809 SendMessage(hWndTrackbar
, TBM_SETTICFREQ
, 1, 0);
811 numtics
= SendMessage(hWndTrackbar
, TBM_GETNUMTICS
, 0, 0);
812 ok(numtics
== 6, "Expected 6, got %d\n", numtics
);
814 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
815 /* test TBM_GETPTICS */
816 rPTics
= (DWORD
*) SendMessage(hWndTrackbar
, TBM_GETPTICS
, 0,0);
817 expect(2, rPTics
[0]);
818 expect(3, rPTics
[1]);
819 expect(4, rPTics
[2]);
820 expect(5, rPTics
[3]);
822 /* test TBM_GETTIC */
823 r
= SendMessage(hWndTrackbar
, TBM_GETTIC
, 0,0);
825 r
= SendMessage(hWndTrackbar
, TBM_GETTIC
, 2,0);
827 r
= SendMessage(hWndTrackbar
, TBM_GETTIC
, 4,0);
832 /* test TBM_GETTICPIC */
833 r
= SendMessage(hWndTrackbar
, TBM_GETTICPOS
, 0, 0);
834 ok(r
> 0, "Expected r > 0, got %d\n", r
);
835 r
= SendMessage(hWndTrackbar
, TBM_GETTICPOS
, 2, 0);
836 ok(r
> 0, "Expected r > 0, got %d\n", r
);
838 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, tic_placement_test_seq
, "get tic placement test sequence", FALSE
);
839 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_empty_test_seq
, "parent get tic placement test sequence", FALSE
);
843 static void test_tool_tips(HWND hWndTrackbar
){
848 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
849 /* testing TBM_SETTIPSIDE */
850 r
= SendMessage(hWndTrackbar
, TBM_SETTIPSIDE
, TBTS_TOP
, 0);
854 r
= SendMessage(hWndTrackbar
, TBM_SETTIPSIDE
, TBTS_LEFT
, 0);
856 r
= SendMessage(hWndTrackbar
, TBM_SETTIPSIDE
, TBTS_BOTTOM
, 0);
858 r
= SendMessage(hWndTrackbar
, TBM_SETTIPSIDE
, TBTS_RIGHT
, 0);
861 /* testing TBM_SETTOOLTIPS */
862 hWndTooltip
= CreateWindowEx(WS_EX_TOPMOST
, TOOLTIPS_CLASS
, NULL
, 0,
863 CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
,
864 NULL
, NULL
, NULL
, NULL
);
866 ok(hWndTooltip
!= NULL
, "Expected non NULL value\n");
867 if (hWndTooltip
!= NULL
){
868 SendMessage(hWndTrackbar
, TBM_SETTOOLTIPS
, (LPARAM
) hWndTooltip
, 0);
869 rTest
= (HWND
) SendMessage(hWndTrackbar
, TBM_GETTOOLTIPS
, 0,0);
870 ok(rTest
== hWndTooltip
, "Expected hWndToolTip, got\n");
871 SendMessage(hWndTrackbar
, TBM_SETTOOLTIPS
, (LPARAM
) NULL
, 0);
872 rTest
= (HWND
) SendMessage(hWndTrackbar
, TBM_GETTOOLTIPS
, 0,0);
873 ok(rTest
== NULL
, "Expected NULL\n");
874 SendMessage(hWndTrackbar
, TBM_SETTOOLTIPS
, (LPARAM
) hWndTooltip
, 5);
875 rTest
= (HWND
) SendMessage(hWndTrackbar
, TBM_GETTOOLTIPS
, 0,0);
876 ok(rTest
== hWndTooltip
, "Expected hWndTooltip, got\n");
878 skip("tool tip control not present?\n");
880 /* test TBM_GETTOOLTIPS */
881 rTest
= (HWND
) SendMessage(hWndTrackbar
, TBM_GETTOOLTIPS
, 0,0);
882 ok(rTest
== hWndTooltip
, "Expected hWndTooltip\n");
884 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, tool_tips_test_seq
, "tool tips test sequence", FALSE
);
885 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_empty_test_seq
, "parent tool tips test sequence", FALSE
);
889 static void test_unicode(HWND hWndTrackbar
){
892 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
893 /* testing TBM_SETUNICODEFORMAT */
894 r
= SendMessage(hWndTrackbar
, TBM_SETUNICODEFORMAT
, TRUE
, 0);
895 ok(r
== FALSE
, "Expected FALSE, got %d\n",r
);
896 r
= SendMessage(hWndTrackbar
, TBM_SETUNICODEFORMAT
, FALSE
, 0);
897 ok(r
== TRUE
, "Expected TRUE, got %d\n",r
);
899 /* test TBM_GETUNICODEFORMAT */
900 r
= SendMessage(hWndTrackbar
, TBM_GETUNICODEFORMAT
, 0,0);
901 ok(r
== FALSE
, "Expected FALSE, got %d\n",r
);
903 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, unicode_test_seq
, "unicode test sequence", FALSE
);
904 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_empty_test_seq
, "parent unicode test sequence", FALSE
);
907 static void test_ignore_selection(HWND hWndTrackbar
){
910 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
911 /* test TBM_SETSEL ensure that it is ignored */
912 SendMessage(hWndTrackbar
, TBM_SETSEL
, TRUE
, MAKELONG(0,10));
913 r
= SendMessage(hWndTrackbar
, TBM_GETSELEND
, 0,0);
915 r
= SendMessage(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
917 SendMessage(hWndTrackbar
, TBM_SETSEL
, FALSE
, MAKELONG(0,10));
918 r
= SendMessage(hWndTrackbar
, TBM_GETSELEND
, 0,0);
920 r
= SendMessage(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
923 /* test TBM_SETSELEND, ensure that it is ignored */
924 SendMessage(hWndTrackbar
, TBM_SETSELEND
, TRUE
, 0);
925 r
= SendMessage(hWndTrackbar
, TBM_GETSELEND
, 0,0);
927 SendMessage(hWndTrackbar
, TBM_SETSELEND
, TRUE
, 10);
928 r
= SendMessage(hWndTrackbar
, TBM_GETSELEND
, 0,0);
930 SendMessage(hWndTrackbar
, TBM_SETSELEND
, FALSE
, 0);
931 r
= SendMessage(hWndTrackbar
, TBM_GETSELEND
, 0,0);
934 /* test TBM_SETSELSTART, ensure that it is ignored */
935 SendMessage(hWndTrackbar
, TBM_SETSELSTART
, TRUE
, 0);
936 r
= SendMessage(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
938 SendMessage(hWndTrackbar
, TBM_SETSELSTART
, TRUE
, 10);
939 r
= SendMessage(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
941 SendMessage(hWndTrackbar
, TBM_SETSELSTART
, FALSE
, 0);
942 r
= SendMessage(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
945 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, ignore_selection_test_seq
, "ignore selection setting test sequence", FALSE
);
946 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_empty_test_seq
, "parent ignore selection setting test sequence", FALSE
);
951 DWORD style
= WS_VISIBLE
| TBS_TOOLTIPS
| TBS_ENABLESELRANGE
| TBS_FIXEDLENGTH
| TBS_AUTOTICKS
;
955 init_msg_sequences(sequences
, NUM_MSG_SEQUENCE
);
956 InitCommonControls();
958 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
960 /* create parent window */
961 hWndParent
= create_parent_window();
962 ok(hWndParent
!= NULL
, "Failed to create parent Window!\n");
965 skip("parent window not present\n");
969 ok_sequence(sequences
, PARENT_SEQ_INDEX
, create_parent_wnd_seq
, "create Parent Window", TRUE
);
970 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
972 /* create trackbar with set styles */
973 hWndTrackbar
= create_trackbar(style
, hWndParent
);
975 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
978 skip("trackbar control not present?\n");
982 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, create_trackbar_wnd_seq
, "create Trackbar Window", FALSE
);
983 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_create_trackbar_wnd_seq
, "parent trackbar window", TRUE
);
984 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
986 /* TEST OF ALL SETTER and GETTER MESSAGES with required styles turned on*/
987 test_trackbar_buddy(hWndTrackbar
);
988 test_line_size(hWndTrackbar
);
989 test_page_size(hWndTrackbar
);
990 test_position(hWndTrackbar
);
991 test_range(hWndTrackbar
);
992 test_selection(hWndTrackbar
);
993 test_thumb_length(hWndTrackbar
);
994 test_tic_settings(hWndTrackbar
);
995 test_tic_placement(hWndTrackbar
);
996 test_tool_tips(hWndTrackbar
);
997 test_unicode(hWndTrackbar
);
999 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
1000 DestroyWindow(hWndTrackbar
);
1002 /* test getters and setters without styles set */
1003 hWndTrackbar
= create_trackbar(0, hWndParent
);
1005 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
1008 skip("trackbar control not present?\n");
1012 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_new_window_test_seq
, "new trackbar window test sequence", TRUE
);
1014 test_ignore_selection(hWndTrackbar
);
1016 DestroyWindow(hWndTrackbar
);
1018 DestroyWindow(hWndParent
);