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
24 #include "wine/test.h"
27 #define expect(expected, got) ok(got == expected, "Expected %d, got %d\n", expected, got)
28 #define NUM_MSG_SEQUENCE 2
29 #define PARENT_SEQ_INDEX 0
30 #define TRACKBAR_SEQ_INDEX 1
32 static HWND hWndParent;
34 static struct msg_sequence *sequences[NUM_MSG_SEQUENCE];
36 static const struct message empty_seq[] = {
40 static const struct message parent_create_trackbar_wnd_seq[] = {
41 { WM_NOTIFYFORMAT, sent},
42 { WM_QUERYUISTATE, sent|optional},
43 { WM_WINDOWPOSCHANGING, sent},
44 { WM_NCACTIVATE, sent},
45 { PBT_APMRESUMECRITICAL, sent},
46 { WM_WINDOWPOSCHANGING, sent},
47 { PBT_APMRESUMESTANDBY, sent},
48 { WM_IME_SETCONTEXT, sent|optional},
49 { WM_IME_NOTIFY, sent|optional},
50 { WM_CTLCOLORSTATIC, sent},
55 static const struct message parent_new_window_test_seq[] = {
56 { WM_QUERYNEWPALETTE, sent|optional },
57 { WM_WINDOWPOSCHANGING, sent|optional},
58 { WM_NCACTIVATE, sent|optional},
59 { PBT_APMRESUMECRITICAL, sent|optional},
60 { WM_IME_SETCONTEXT, sent|defwinproc|optional},
61 { WM_IME_NOTIFY, sent|defwinproc|optional},
62 { WM_SETFOCUS, sent|defwinproc|optional},
63 { WM_NOTIFYFORMAT, sent},
64 { WM_QUERYUISTATE, sent|optional},
68 static const struct message buddy_window_test_seq[] = {
69 { TBM_GETBUDDY, sent|wparam, TRUE},
70 { TBM_SETBUDDY, sent|wparam, FALSE},
71 { WM_PAINT, sent|defwinproc},
72 { TBM_SETBUDDY, sent|wparam, FALSE},
73 { WM_PAINT, sent|defwinproc},
74 { TBM_GETBUDDY, sent|wparam, TRUE},
75 { TBM_SETBUDDY, sent|wparam, TRUE},
76 { WM_PAINT, sent|defwinproc},
77 { TBM_SETBUDDY, sent|wparam, TRUE},
78 { WM_PAINT, sent|defwinproc},
79 { TBM_GETBUDDY, sent|wparam, FALSE},
80 { TBM_GETBUDDY, sent|wparam, TRUE},
84 static const struct message parent_buddy_window_test_seq[] = {
85 { WM_CTLCOLORSTATIC, sent},
87 { WM_CTLCOLORSTATIC, sent},
89 { WM_CTLCOLORSTATIC, sent},
91 { WM_CTLCOLORSTATIC, sent},
96 static const struct message line_size_test_seq[] = {
97 { TBM_SETLINESIZE, sent|lparam, 0, 10},
98 { TBM_SETLINESIZE, sent|lparam, 0, 4},
99 { TBM_GETLINESIZE, sent},
103 static const struct message page_size_test_seq[] = {
104 { TBM_SETPAGESIZE, sent|lparam, 0, 10},
105 { TBM_SETPAGESIZE, sent|lparam, 0, -1},
106 { TBM_GETPAGESIZE, sent},
110 static const struct message position_test_seq[] = {
111 { TBM_SETPOS, sent|wparam|lparam, TRUE, -1},
112 { WM_PAINT, sent|defwinproc},
114 { TBM_SETPOS, sent|wparam|lparam, TRUE, 5},
115 { WM_PAINT, sent|defwinproc},
117 { TBM_SETPOS, sent|wparam|lparam, TRUE, 5},
118 { TBM_SETPOS, sent|wparam|lparam, TRUE, 1000},
119 { WM_PAINT, sent|defwinproc},
121 { TBM_SETPOS, sent|wparam|lparam, FALSE, 20},
123 { TBM_SETPOS, sent|wparam|lparam, TRUE, 20},
128 static const struct message parent_position_test_seq[] = {
129 { WM_CTLCOLORSTATIC, sent},
131 { WM_CTLCOLORSTATIC, sent},
133 { WM_CTLCOLORSTATIC, sent},
138 static const struct message range_test_seq[] = {
139 { TBM_SETRANGE, sent|wparam|lparam, TRUE, MAKELONG(0, 10)},
140 { WM_PAINT, sent|defwinproc},
141 { TBM_GETRANGEMAX, sent},
142 { TBM_GETRANGEMIN, sent},
143 { TBM_SETRANGE, sent|wparam|lparam, TRUE, MAKELONG(-1, 1000)},
144 { WM_PAINT, sent|defwinproc},
145 { TBM_GETRANGEMAX, sent},
146 { TBM_GETRANGEMIN, sent},
147 { TBM_SETRANGE, sent|wparam|lparam, TRUE, MAKELONG(10, 0)},
148 { WM_PAINT, sent|defwinproc},
149 { TBM_GETRANGEMAX, sent},
150 { TBM_GETRANGEMIN, sent},
151 { TBM_SETRANGE, sent|wparam|lparam, FALSE, MAKELONG(0, 10)},
152 { TBM_GETRANGEMAX, sent},
153 { TBM_GETRANGEMIN, sent},
154 { TBM_SETRANGEMAX, sent|wparam|lparam, TRUE, 10},
155 { WM_PAINT, sent|defwinproc},
156 { TBM_GETRANGEMAX, sent},
157 { TBM_SETRANGEMAX, sent|wparam|lparam, TRUE, -1},
158 { WM_PAINT, sent|defwinproc},
159 { TBM_GETRANGEMAX, sent},
160 { TBM_SETRANGEMAX, sent|wparam|lparam, FALSE, 10},
161 { TBM_GETRANGEMAX, sent},
162 { TBM_SETRANGEMIN, sent|wparam|lparam, TRUE, 0},
163 { WM_PAINT, sent|defwinproc},
164 { TBM_GETRANGEMIN, sent},
165 { TBM_SETRANGEMIN, sent|wparam|lparam, TRUE, 10},
166 { WM_PAINT, sent|defwinproc},
167 { TBM_GETRANGEMIN, sent},
168 { TBM_SETRANGEMIN, sent|wparam|lparam, TRUE, -10},
169 { WM_PAINT, sent|defwinproc},
170 { TBM_GETRANGEMIN, sent},
171 { TBM_SETRANGEMIN, sent|wparam|lparam, FALSE, 5},
172 { TBM_GETRANGEMIN, sent},
173 { TBM_GETRANGEMAX, sent},
174 { TBM_GETRANGEMIN, sent},
178 static const struct message parent_range_test_seq[] = {
179 { WM_CTLCOLORSTATIC, sent},
181 { WM_CTLCOLORSTATIC, sent},
183 { WM_CTLCOLORSTATIC, sent},
185 { WM_CTLCOLORSTATIC, sent},
187 { WM_CTLCOLORSTATIC, sent},
189 { WM_CTLCOLORSTATIC, sent},
191 { WM_CTLCOLORSTATIC, sent},
193 { WM_CTLCOLORSTATIC, sent},
198 static const struct message selection_test_seq[] = {
199 { TBM_SETSEL, sent|wparam|lparam, TRUE, MAKELONG(0, 10)},
200 { WM_PAINT, sent|defwinproc},
201 { TBM_GETSELEND, sent},
202 { TBM_GETSELSTART, sent},
203 { TBM_SETSEL, sent|wparam|lparam, TRUE, MAKELONG(5, 20)},
204 { WM_PAINT, sent|defwinproc},
205 { TBM_GETSELEND, sent},
206 { TBM_GETSELSTART, sent},
207 { TBM_SETSEL, sent|wparam|lparam, FALSE, MAKELONG(5, 10)},
208 { TBM_GETSELEND, sent},
209 { TBM_GETSELSTART, sent},
210 { TBM_SETSELEND, sent|wparam|lparam, TRUE, 10},
211 { WM_PAINT, sent|defwinproc},
212 { TBM_GETSELEND, sent},
213 { TBM_SETSELEND, sent|wparam|lparam, TRUE, 20},
214 { WM_PAINT, sent|defwinproc},
215 { TBM_GETSELEND, sent},
216 { TBM_SETSELEND, sent|wparam|lparam, TRUE, 4},
217 { WM_PAINT, sent|defwinproc},
218 { TBM_GETSELEND, sent},
219 { TBM_SETSELEND, sent|wparam|lparam, FALSE, 2},
220 { TBM_GETSELEND, sent},
221 { TBM_GETSELEND, sent},
222 { TBM_SETSELSTART, sent|wparam|lparam, TRUE, 5},
223 { WM_PAINT, sent|defwinproc},
224 { TBM_GETSELSTART, sent},
225 { TBM_SETSELSTART, sent|wparam|lparam, TRUE, 0},
226 { WM_PAINT, sent|defwinproc},
227 { TBM_GETSELSTART, sent},
228 { TBM_SETSELSTART, sent|wparam|lparam, TRUE, 20},
229 { WM_PAINT, sent|defwinproc},
230 { TBM_GETSELSTART, sent},
231 { TBM_SETSELSTART, sent|wparam|lparam, FALSE, 8},
232 { TBM_GETSELSTART, sent},
233 { TBM_GETSELSTART, sent},
237 static const struct message parent_selection_test_seq[] = {
238 { WM_CTLCOLORSTATIC, sent},
240 { WM_CTLCOLORSTATIC, sent},
242 { WM_CTLCOLORSTATIC, sent},
244 { WM_CTLCOLORSTATIC, sent},
246 { WM_CTLCOLORSTATIC, sent},
248 { WM_CTLCOLORSTATIC, sent},
250 { WM_CTLCOLORSTATIC, sent},
252 { WM_CTLCOLORSTATIC, sent},
257 static const struct message tic_settings_test_seq[] = {
258 { TBM_SETTIC, sent|lparam, 0, 0},
259 { TBM_SETTIC, sent|lparam, 0, 5},
260 { TBM_SETTIC, sent|lparam, 0, 10},
261 { TBM_SETTIC, sent|lparam, 0, 20},
262 { TBM_SETRANGE, sent|wparam|lparam, TRUE, MAKELONG(0,10)},
263 { WM_PAINT, sent|defwinproc},
264 { TBM_SETTICFREQ, sent|wparam, 2},
265 { WM_PAINT, sent|defwinproc},
266 { TBM_GETNUMTICS, sent},
267 { TBM_SETTICFREQ, sent|wparam, 5},
268 { WM_PAINT, sent|defwinproc},
269 { TBM_GETNUMTICS, sent},
270 { TBM_SETTICFREQ, sent|wparam, 15},
271 { WM_PAINT, sent|defwinproc},
272 { TBM_GETNUMTICS, sent},
273 { TBM_GETNUMTICS, sent},
277 static const struct message parent_tic_settings_test_seq[] = {
278 { WM_CTLCOLORSTATIC, sent},
280 { WM_CTLCOLORSTATIC, sent},
282 { WM_CTLCOLORSTATIC, sent},
284 { WM_CTLCOLORSTATIC, sent},
289 static const struct message thumb_length_test_seq[] = {
290 { TBM_SETTHUMBLENGTH, sent|wparam|lparam, 15, 0},
291 { WM_PAINT, sent|defwinproc},
292 { TBM_GETTHUMBLENGTH, sent},
293 { TBM_SETTHUMBLENGTH, sent|wparam|lparam, 20, 0},
294 { WM_PAINT, sent|defwinproc},
295 { TBM_GETTHUMBLENGTH, sent},
296 { TBM_GETTHUMBLENGTH, sent},
298 { WM_PAINT, sent|defwinproc},
299 { TBM_GETTHUMBLENGTH, sent},
301 { WM_PAINT, sent|defwinproc},
302 { TBM_GETTHUMBLENGTH, sent},
306 static const struct message parent_thumb_length_test_seq[] = {
307 { WM_CTLCOLORSTATIC, sent},
309 { WM_CTLCOLORSTATIC, sent},
311 { WM_CTLCOLORSTATIC, sent},
313 { WM_CTLCOLORSTATIC, sent},
318 static const struct message tic_placement_test_seq[] = {
319 { TBM_GETPTICS, sent},
320 { TBM_GETTIC, sent|wparam, 0},
321 { TBM_GETTIC, sent|wparam, 2},
322 { TBM_GETTIC, sent|wparam, 4},
323 { TBM_GETTICPOS, sent|wparam, 0},
324 { TBM_GETTICPOS, sent|wparam, 2},
328 static const struct message tool_tips_test_seq[] = {
329 { TBM_SETTIPSIDE, sent|wparam, TBTS_TOP},
330 { TBM_SETTIPSIDE, sent|wparam, TBTS_LEFT},
331 { TBM_SETTIPSIDE, sent|wparam, TBTS_BOTTOM},
332 { TBM_SETTIPSIDE, sent|wparam, TBTS_RIGHT},
333 { TBM_SETTOOLTIPS, sent},
334 { TBM_GETTOOLTIPS, sent},
335 { TBM_SETTOOLTIPS, sent},
336 { TBM_GETTOOLTIPS, sent},
337 { TBM_SETTOOLTIPS, sent},
338 { TBM_GETTOOLTIPS, sent},
339 { TBM_GETTOOLTIPS, sent},
343 static const struct message unicode_test_seq[] = {
344 { TBM_SETUNICODEFORMAT, sent|wparam, TRUE},
345 { TBM_SETUNICODEFORMAT, sent|wparam, FALSE},
346 { TBM_GETUNICODEFORMAT, sent},
350 static const struct message ignore_selection_test_seq[] = {
351 { TBM_SETSEL, sent|wparam|lparam, TRUE, MAKELONG(0,10)},
352 { TBM_GETSELEND, sent},
353 { TBM_GETSELSTART, sent},
354 { TBM_SETSEL, sent|wparam|lparam, FALSE, MAKELONG(0,10)},
355 { TBM_GETSELEND, sent},
356 { TBM_GETSELSTART, sent},
357 { TBM_SETSELEND, sent|wparam|lparam, TRUE,0},
358 { TBM_GETSELEND, sent},
359 { TBM_SETSELEND, sent|wparam|lparam, TRUE, 10},
360 { TBM_GETSELEND, sent},
361 { TBM_SETSELEND, sent|wparam|lparam, FALSE,0},
362 { TBM_GETSELEND, sent},
363 { TBM_SETSELSTART, sent|wparam|lparam, TRUE,0},
364 { TBM_GETSELSTART, sent},
365 { TBM_SETSELSTART, sent|wparam|lparam, TRUE, 10},
366 { TBM_GETSELSTART, sent},
367 { TBM_SETSELSTART, sent|wparam|lparam, FALSE,0},
368 { TBM_GETSELSTART, sent},
372 static LRESULT WINAPI parent_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){
373 static LONG defwndproc_counter = 0;
377 /* log system messages, except for painting */
378 if (message < WM_USER &&
379 message != WM_PAINT &&
380 message != WM_ERASEBKGND &&
381 message != WM_NCPAINT &&
382 message != WM_NCHITTEST &&
383 message != WM_GETTEXT &&
384 message != WM_GETICON &&
385 message != WM_DEVICECHANGE)
387 trace("parent: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
389 msg.message = message;
390 msg.flags = sent|wparam|lparam;
391 if (defwndproc_counter) msg.flags |= defwinproc;
394 add_message(sequences, PARENT_SEQ_INDEX, &msg);
397 defwndproc_counter++;
398 ret = DefWindowProcA(hwnd, message, wParam, lParam);
399 defwndproc_counter--;
404 static BOOL register_parent_wnd_class(void){
408 cls.lpfnWndProc = parent_wnd_proc;
411 cls.hInstance = GetModuleHandleA(NULL);
413 cls.hCursor = LoadCursorA(0, IDC_ARROW);
414 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
415 cls.lpszMenuName = NULL;
416 cls.lpszClassName = "Trackbar test parent class";
417 return RegisterClassA(&cls);
420 static HWND create_parent_window(void){
421 if (!register_parent_wnd_class())
424 return CreateWindowEx(0, "Trackbar test parent class",
425 "Trackbar test parent window",
426 WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX |
427 WS_MAXIMIZEBOX | WS_VISIBLE,
429 GetDesktopWindow(), NULL, GetModuleHandleA(NULL), NULL);
432 static LRESULT WINAPI trackbar_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){
433 WNDPROC oldproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_USERDATA);
434 static LONG defwndproc_counter = 0;
438 trace("trackbar: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
440 msg.message = message;
441 msg.flags = sent|wparam|lparam;
442 if (defwndproc_counter) msg.flags |= defwinproc;
446 add_message(sequences, TRACKBAR_SEQ_INDEX, &msg);
448 defwndproc_counter++;
449 ret = CallWindowProcA(oldproc, hwnd, message, wParam, lParam);
450 defwndproc_counter--;
455 static HWND create_trackbar(DWORD style, HWND parent){
460 GetClientRect(parent, &rect);
461 hWndTrack = CreateWindowEx(
462 0, TRACKBAR_CLASS,"Trackbar Control", style,
463 rect.right,rect.bottom, 100, 50,
464 parent, NULL,GetModuleHandleA(NULL) ,NULL);
466 if (!hWndTrack) return NULL;
468 oldproc = (WNDPROC)SetWindowLongPtrA(hWndTrack, GWLP_WNDPROC, (LONG_PTR)trackbar_subclass_proc);
469 SetWindowLongPtrA(hWndTrack, GWLP_USERDATA, (LONG_PTR)oldproc);
474 /* test functions for setters, getters, and sequences */
476 static void test_trackbar_buddy(HWND hWndTrackbar){
479 HWND hWndCurrentBuddy;
482 flush_sequences(sequences, NUM_MSG_SEQUENCE);
484 hWndLeftBuddy = CreateWindowEx(0, STATUSCLASSNAME, NULL, 0,
485 0,0,300,20, NULL, NULL, NULL, NULL);
486 ok(hWndLeftBuddy != NULL, "Expected non NULL value\n");
488 if (hWndLeftBuddy != NULL){
489 hWndCurrentBuddy = (HWND) SendMessage(hWndTrackbar, TBM_GETBUDDY, TRUE, 0);
490 rTest = (HWND) SendMessage(hWndTrackbar, TBM_SETBUDDY, FALSE, (LPARAM) hWndLeftBuddy);
491 ok(rTest == hWndCurrentBuddy, "Expected hWndCurrentBuddy\n");
492 rTest = (HWND) SendMessage(hWndTrackbar, TBM_SETBUDDY, FALSE, (LPARAM) hWndLeftBuddy);
493 ok(rTest == hWndLeftBuddy, "Expected hWndLeftBuddy\n");
495 skip ("left buddy control not present?\n");
497 hWndRightBuddy = CreateWindowEx(0, STATUSCLASSNAME, NULL, 0,
498 0,0,300,20,NULL,NULL, NULL, NULL);
500 ok(hWndRightBuddy != NULL, "expected non NULL value\n");
502 /* test TBM_SETBUDDY */
503 if (hWndRightBuddy != NULL){
504 hWndCurrentBuddy = (HWND) SendMessage(hWndTrackbar, TBM_GETBUDDY, TRUE, 0);
505 rTest = (HWND) SendMessage(hWndTrackbar, TBM_SETBUDDY, TRUE, (LPARAM) hWndRightBuddy);
506 ok(rTest == hWndCurrentBuddy, "Expected hWndCurrentBuddy\n");
507 rTest = (HWND) SendMessage(hWndTrackbar, TBM_SETBUDDY, TRUE, (LPARAM) hWndRightBuddy);
508 ok(rTest == hWndRightBuddy, "Expected hWndRightbuddy\n");
510 skip("Right buddy control not present?\n");
512 /* test TBM_GETBUDDY */
513 if (hWndLeftBuddy != NULL){
514 rTest = (HWND) SendMessage(hWndTrackbar, TBM_GETBUDDY, FALSE, 0);
515 ok(rTest == hWndLeftBuddy, "Expected hWndLeftBuddy\n");
516 DestroyWindow(hWndLeftBuddy);
518 if (hWndRightBuddy != NULL){
519 rTest = (HWND) SendMessage(hWndTrackbar, TBM_GETBUDDY, TRUE,0);
520 ok(rTest == hWndRightBuddy, "Expected hWndRightBuddy\n");
521 DestroyWindow(hWndRightBuddy);
524 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, buddy_window_test_seq, "buddy test sequence", TRUE);
525 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_buddy_window_test_seq, "parent buddy test seq", TRUE);
529 static void test_line_size(HWND hWndTrackbar){
532 flush_sequences(sequences, NUM_MSG_SEQUENCE);
534 /* test TBM_SETLINESIZE */
535 r = SendMessage(hWndTrackbar, TBM_SETLINESIZE, 0, 10);
537 r = SendMessage(hWndTrackbar, TBM_SETLINESIZE, 0, 4);
540 /* test TBM_GETLINESIZE */
541 r = SendMessage(hWndTrackbar, TBM_GETLINESIZE, 0,0);
544 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, line_size_test_seq, "linesize test sequence", FALSE);
545 ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq, "parent line test sequence", FALSE);
549 static void test_page_size(HWND hWndTrackbar){
552 flush_sequences(sequences, NUM_MSG_SEQUENCE);
554 /* test TBM_SETPAGESIZE */
555 r = SendMessage(hWndTrackbar, TBM_SETPAGESIZE, 0, 10);
557 r = SendMessage(hWndTrackbar, TBM_SETPAGESIZE, 0, -1);
560 /* test TBM_GETPAGESIZE */
561 r = SendMessage(hWndTrackbar, TBM_GETPAGESIZE, 0,0);
564 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, page_size_test_seq, "page size test sequence", FALSE);
565 ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq, "parent page size test sequence", FALSE);
567 /* check for zero page size */
568 r = SendMessage(hWndTrackbar, TBM_SETPAGESIZE, 0, 0);
570 r = SendMessage(hWndTrackbar, TBM_GETPAGESIZE, 0, 0);
572 /* revert to default */
573 r = SendMessage(hWndTrackbar, TBM_SETPAGESIZE, 0, -1);
575 r = SendMessage(hWndTrackbar, TBM_GETPAGESIZE, 0, 0);
578 r = SendMessage(hWndTrackbar, TBM_SETPAGESIZE, 0, -2);
580 r = SendMessage(hWndTrackbar, TBM_GETPAGESIZE, 0, 0);
584 static void test_position(HWND hWndTrackbar){
587 flush_sequences(sequences, NUM_MSG_SEQUENCE);
588 /* test TBM_SETPOS */
589 SendMessage(hWndTrackbar, TBM_SETPOS, TRUE, -1);
590 r = SendMessage(hWndTrackbar, TBM_GETPOS, 0, 0);
592 SendMessage(hWndTrackbar, TBM_SETPOS, TRUE, 5);
593 r = SendMessage(hWndTrackbar, TBM_GETPOS, 0,0);
595 SendMessage(hWndTrackbar, TBM_SETPOS, TRUE, 5);
596 SendMessage(hWndTrackbar, TBM_SETPOS, TRUE, 1000);
597 r = SendMessage(hWndTrackbar, TBM_GETPOS, 0,0);
599 SendMessage(hWndTrackbar, TBM_SETPOS, FALSE, 20);
600 r = SendMessage(hWndTrackbar, TBM_GETPOS, 0,0);
602 SendMessage(hWndTrackbar, TBM_SETPOS, TRUE, 20);
604 /* test TBM_GETPOS */
605 r = SendMessage(hWndTrackbar, TBM_GETPOS, 0,0);
608 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, position_test_seq, "position test sequence", TRUE);
609 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_position_test_seq, "parent position test sequence", TRUE);
612 static void test_range(HWND hWndTrackbar){
615 flush_sequences(sequences, NUM_MSG_SEQUENCE);
616 /* test TBM_SETRANGE */
617 SendMessage(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(0, 10));
618 r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
620 r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
622 SendMessage(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(-1, 1000));
623 r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
625 r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
627 SendMessage(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(10, 0));
628 r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
630 r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
632 SendMessage(hWndTrackbar, TBM_SETRANGE, FALSE, MAKELONG(0,10));
633 r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
635 r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
638 /*test TBM_SETRANGEMAX */
639 SendMessage(hWndTrackbar, TBM_SETRANGEMAX, TRUE, 10);
640 r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
642 SendMessage(hWndTrackbar, TBM_SETRANGEMAX, TRUE, -1);
643 r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
645 SendMessage(hWndTrackbar, TBM_SETRANGEMAX, FALSE, 10);
646 r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
649 /* testing TBM_SETRANGEMIN */
650 SendMessage(hWndTrackbar, TBM_SETRANGEMIN, TRUE, 0);
651 r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
653 SendMessage(hWndTrackbar, TBM_SETRANGEMIN, TRUE, 10);
654 r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
656 SendMessage(hWndTrackbar, TBM_SETRANGEMIN, TRUE, -10);
657 r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
659 SendMessage(hWndTrackbar, TBM_SETRANGEMIN, FALSE, 5);
660 r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
663 /* test TBM_GETRANGEMAX */
664 r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
667 /* test TBM_GETRANGEMIN */
668 r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
671 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, range_test_seq, "range test sequence", TRUE);
672 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_range_test_seq, "parent range test sequence", TRUE);
675 static void test_selection(HWND hWndTrackbar){
678 flush_sequences(sequences, NUM_MSG_SEQUENCE);
679 /* test TBM_SETSEL */
680 SendMessage(hWndTrackbar, TBM_SETSEL, TRUE, MAKELONG(0,10));
681 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
683 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
685 SendMessage(hWndTrackbar, TBM_SETSEL, TRUE, MAKELONG(5, 20));
686 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
688 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
690 SendMessage(hWndTrackbar, TBM_SETSEL, FALSE, MAKELONG(5, 10));
691 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
693 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
696 /* test TBM_SETSELEND */
697 SendMessage(hWndTrackbar, TBM_SETSELEND, TRUE, 10);
698 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
700 SendMessage(hWndTrackbar, TBM_SETSELEND, TRUE, 20);
701 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
703 SendMessage(hWndTrackbar, TBM_SETSELEND, TRUE, 4);
704 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
706 SendMessage(hWndTrackbar, TBM_SETSELEND, FALSE, 2);
707 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
710 /* test TBM_GETSELEND */
711 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
714 /* testing TBM_SETSELSTART */
715 SendMessage(hWndTrackbar, TBM_SETSELSTART, TRUE, 5);
716 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
718 SendMessage(hWndTrackbar, TBM_SETSELSTART, TRUE, 0);
719 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
721 SendMessage(hWndTrackbar, TBM_SETSELSTART, TRUE, 20);
722 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
724 SendMessage(hWndTrackbar, TBM_SETSELSTART, FALSE, 8);
725 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
728 /* test TBM_GETSELSTART */
729 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
732 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, selection_test_seq, "selection test sequence", TRUE);
733 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_selection_test_seq, "parent selection test seqence", TRUE);
736 static void test_thumb_length(HWND hWndTrackbar){
739 flush_sequences(sequences, NUM_MSG_SEQUENCE);
740 /* testing TBM_SETTHUMBLENGTH */
741 SendMessage(hWndTrackbar, TBM_SETTHUMBLENGTH, 15, 0);
742 r = SendMessage(hWndTrackbar, TBM_GETTHUMBLENGTH, 0,0);
744 SendMessage(hWndTrackbar, TBM_SETTHUMBLENGTH, 20, 0);
745 r = SendMessage(hWndTrackbar, TBM_GETTHUMBLENGTH, 0,0);
748 /* test TBM_GETTHUMBLENGTH */
749 r = SendMessage(hWndTrackbar, TBM_GETTHUMBLENGTH, 0,0);
752 r = SendMessage(hWndTrackbar, WM_SIZE, 0,0);
754 r = SendMessage(hWndTrackbar, TBM_GETTHUMBLENGTH, 0,0);
756 r = SendMessage(hWndTrackbar, WM_SIZE, 0, MAKELPARAM(50, 50) );
758 r = SendMessage(hWndTrackbar, TBM_GETTHUMBLENGTH, 0,0);
761 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, thumb_length_test_seq, "thumb length test sequence", TRUE);
762 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_thumb_length_test_seq, "parent thumb length test sequence", TRUE);
765 static void test_tic_settings(HWND hWndTrackbar){
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_GETRANGEMAX, 0, 0);
773 r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0, 0);
776 flush_sequences(sequences, NUM_MSG_SEQUENCE);
777 r = SendMessage(hWndTrackbar, TBM_SETTIC, 0, 0);
778 ok(r == FALSE, "Expected FALSE, got %d\n", r);
779 r = SendMessage(hWndTrackbar, TBM_SETTIC, 0, 5);
780 ok(r == TRUE, "Expected TRUE, got %d\n", r);
781 r = SendMessage(hWndTrackbar, TBM_SETTIC, 0, 10);
782 ok(r == TRUE, "Expected TRUE, got %d\n", r);
784 r = SendMessage(hWndTrackbar, TBM_SETTIC, 0, 20);
785 ok(r == FALSE, "Expected False, got %d\n", r);
787 /* test TBM_SETTICFREQ */
788 SendMessage(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(0, 10));
789 SendMessage(hWndTrackbar, TBM_SETTICFREQ, 2, 0);
790 r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
792 SendMessage(hWndTrackbar, TBM_SETTICFREQ, 5, 0);
793 r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
795 SendMessage(hWndTrackbar, TBM_SETTICFREQ, 15, 0);
796 r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
799 /* test TBM_GETNUMTICS */
800 /* since TIC FREQ is 15, there should be only 2 tics now */
801 r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
804 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, tic_settings_test_seq, "tic settings test sequence", TRUE);
805 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_tic_settings_test_seq, "parent tic settings test sequence", TRUE);
807 /* range [0,0], freq = 1 */
808 SendMessage(hWndTrackbar, TBM_SETRANGEMAX, TRUE, 0);
809 SendMessage(hWndTrackbar, TBM_SETRANGEMIN, TRUE, 0);
810 SendMessage(hWndTrackbar, TBM_SETTICFREQ, 1, 0);
811 r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
813 /* range [0,1], freq = 1 */
814 SendMessage(hWndTrackbar, TBM_SETRANGEMAX, TRUE, 1);
815 SendMessage(hWndTrackbar, TBM_SETRANGEMIN, TRUE, 0);
816 SendMessage(hWndTrackbar, TBM_SETTICFREQ, 1, 0);
817 r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
819 /* range [0,2], freq = 1 */
820 SendMessage(hWndTrackbar, TBM_SETRANGEMAX, TRUE, 2);
821 SendMessage(hWndTrackbar, TBM_SETRANGEMIN, TRUE, 0);
822 SendMessage(hWndTrackbar, TBM_SETTICFREQ, 1, 0);
823 r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
827 static void test_tic_placement(HWND hWndTrackbar){
832 SendMessage(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(1, 6));
833 SendMessage(hWndTrackbar, TBM_SETTICFREQ, 1, 0);
835 numtics = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
836 ok(numtics == 6, "Expected 6, got %d\n", numtics);
838 flush_sequences(sequences, NUM_MSG_SEQUENCE);
839 /* test TBM_GETPTICS */
840 rPTics = (DWORD *) SendMessage(hWndTrackbar, TBM_GETPTICS, 0,0);
841 expect(2, rPTics[0]);
842 expect(3, rPTics[1]);
843 expect(4, rPTics[2]);
844 expect(5, rPTics[3]);
846 /* test TBM_GETTIC */
847 r = SendMessage(hWndTrackbar, TBM_GETTIC, 0,0);
849 r = SendMessage(hWndTrackbar, TBM_GETTIC, 2,0);
851 r = SendMessage(hWndTrackbar, TBM_GETTIC, 4,0);
854 /* test TBM_GETTICPIC */
855 r = SendMessage(hWndTrackbar, TBM_GETTICPOS, 0, 0);
856 ok(r > 0, "Expected r > 0, got %d\n", r);
857 r = SendMessage(hWndTrackbar, TBM_GETTICPOS, 2, 0);
858 ok(r > 0, "Expected r > 0, got %d\n", r);
860 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, tic_placement_test_seq, "get tic placement test sequence", FALSE);
861 ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq, "parent get tic placement test sequence", FALSE);
865 static void test_tool_tips(HWND hWndTrackbar){
870 flush_sequences(sequences, NUM_MSG_SEQUENCE);
871 /* testing TBM_SETTIPSIDE */
872 r = SendMessage(hWndTrackbar, TBM_SETTIPSIDE, TBTS_TOP, 0);
874 r = SendMessage(hWndTrackbar, TBM_SETTIPSIDE, TBTS_LEFT, 0);
876 r = SendMessage(hWndTrackbar, TBM_SETTIPSIDE, TBTS_BOTTOM, 0);
877 expect(TBTS_LEFT, r);
878 r = SendMessage(hWndTrackbar, TBM_SETTIPSIDE, TBTS_RIGHT, 0);
879 expect(TBTS_BOTTOM, r);
881 /* testing TBM_SETTOOLTIPS */
882 hWndTooltip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, 0,
883 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
884 NULL, NULL, NULL, NULL);
886 ok(hWndTooltip != NULL, "Expected non NULL value\n");
887 if (hWndTooltip != NULL){
888 SendMessage(hWndTrackbar, TBM_SETTOOLTIPS, (LPARAM) hWndTooltip, 0);
889 rTest = (HWND) SendMessage(hWndTrackbar, TBM_GETTOOLTIPS, 0,0);
890 ok(rTest == hWndTooltip, "Expected hWndToolTip, got\n");
891 SendMessage(hWndTrackbar, TBM_SETTOOLTIPS, 0, 0);
892 rTest = (HWND) SendMessage(hWndTrackbar, TBM_GETTOOLTIPS, 0,0);
893 ok(rTest == NULL, "Expected NULL\n");
894 SendMessage(hWndTrackbar, TBM_SETTOOLTIPS, (LPARAM) hWndTooltip, 5);
895 rTest = (HWND) SendMessage(hWndTrackbar, TBM_GETTOOLTIPS, 0,0);
896 ok(rTest == hWndTooltip, "Expected hWndTooltip, got\n");
898 skip("tool tip control not present?\n");
900 /* test TBM_GETTOOLTIPS */
901 rTest = (HWND) SendMessage(hWndTrackbar, TBM_GETTOOLTIPS, 0,0);
902 ok(rTest == hWndTooltip, "Expected hWndTooltip\n");
904 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, tool_tips_test_seq, "tool tips test sequence", FALSE);
905 ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq, "parent tool tips test sequence", FALSE);
909 static void test_unicode(HWND hWndTrackbar){
912 flush_sequences(sequences, NUM_MSG_SEQUENCE);
913 /* testing TBM_SETUNICODEFORMAT */
914 r = SendMessage(hWndTrackbar, TBM_SETUNICODEFORMAT, TRUE, 0);
915 ok(r == FALSE, "Expected FALSE, got %d\n",r);
916 r = SendMessage(hWndTrackbar, TBM_SETUNICODEFORMAT, FALSE, 0);
917 ok(r == TRUE, "Expected TRUE, got %d\n",r);
919 /* test TBM_GETUNICODEFORMAT */
920 r = SendMessage(hWndTrackbar, TBM_GETUNICODEFORMAT, 0,0);
921 ok(r == FALSE, "Expected FALSE, got %d\n",r);
923 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, unicode_test_seq, "unicode test sequence", FALSE);
924 ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq, "parent unicode test sequence", FALSE);
927 static void test_ignore_selection(HWND hWndTrackbar){
930 flush_sequences(sequences, NUM_MSG_SEQUENCE);
931 /* test TBM_SETSEL ensure that it is ignored */
932 SendMessage(hWndTrackbar, TBM_SETSEL, TRUE, MAKELONG(0,10));
933 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
935 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
937 SendMessage(hWndTrackbar, TBM_SETSEL, FALSE, MAKELONG(0,10));
938 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
940 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
943 /* test TBM_SETSELEND, ensure that it is ignored */
944 SendMessage(hWndTrackbar, TBM_SETSELEND, TRUE, 0);
945 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
947 SendMessage(hWndTrackbar, TBM_SETSELEND, TRUE, 10);
948 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
950 SendMessage(hWndTrackbar, TBM_SETSELEND, FALSE, 0);
951 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
954 /* test TBM_SETSELSTART, ensure that it is ignored */
955 SendMessage(hWndTrackbar, TBM_SETSELSTART, TRUE, 0);
956 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
958 SendMessage(hWndTrackbar, TBM_SETSELSTART, TRUE, 10);
959 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
961 SendMessage(hWndTrackbar, TBM_SETSELSTART, FALSE, 0);
962 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
965 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, ignore_selection_test_seq, "ignore selection setting test sequence", FALSE);
966 ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq, "parent ignore selection setting test sequence", FALSE);
969 static void test_initial_state(void)
974 hWnd = create_trackbar(0, hWndParent);
976 ret = SendMessage(hWnd, TBM_GETNUMTICS, 0, 0);
978 ret = SendMessage(hWnd, TBM_GETTIC, 0, 0);
980 ret = SendMessage(hWnd, TBM_GETTICPOS, 0, 0);
982 ret = SendMessage(hWnd, TBM_GETRANGEMIN, 0, 0);
984 ret = SendMessage(hWnd, TBM_GETRANGEMAX, 0, 0);
987 ret = SendMessage(hWnd, TBM_SETRANGEMAX, TRUE, 200);
990 ret = SendMessage(hWnd, TBM_GETNUMTICS, 0, 0);
993 ret = SendMessage(hWnd, TBM_SETRANGEMIN, TRUE, 10);
996 ret = SendMessage(hWnd, TBM_GETNUMTICS, 0, 0);
1002 static void test_TBS_AUTOTICKS(void)
1007 hWnd = create_trackbar(TBS_AUTOTICKS, hWndParent);
1009 ret = SendMessage(hWnd, TBM_GETNUMTICS, 0, 0);
1011 ret = SendMessage(hWnd, TBM_GETTIC, 0, 0);
1013 ret = SendMessage(hWnd, TBM_GETTICPOS, 0, 0);
1015 ret = SendMessage(hWnd, TBM_GETRANGEMIN, 0, 0);
1017 ret = SendMessage(hWnd, TBM_GETRANGEMAX, 0, 0);
1020 /* TBM_SETRANGEMAX rebuilds tics */
1021 ret = SendMessage(hWnd, TBM_SETRANGEMAX, TRUE, 200);
1023 ret = SendMessage(hWnd, TBM_GETNUMTICS, 0, 0);
1026 /* TBM_SETRANGEMIN rebuilds tics */
1027 ret = SendMessage(hWnd, TBM_SETRANGEMAX, TRUE, 100);
1029 ret = SendMessage(hWnd, TBM_SETRANGEMIN, TRUE, 10);
1031 ret = SendMessage(hWnd, TBM_GETNUMTICS, 0, 0);
1034 ret = SendMessage(hWnd, TBM_SETRANGEMIN, TRUE, 0);
1037 /* TBM_SETRANGE rebuilds tics */
1038 ret = SendMessage(hWnd, TBM_SETRANGE, TRUE, MAKELONG(10, 200));
1040 ret = SendMessage(hWnd, TBM_GETNUMTICS, 0, 0);
1043 DestroyWindow(hWnd);
1046 START_TEST(trackbar)
1048 DWORD style = WS_VISIBLE | TBS_TOOLTIPS | TBS_ENABLESELRANGE | TBS_FIXEDLENGTH | TBS_AUTOTICKS;
1051 init_msg_sequences(sequences, NUM_MSG_SEQUENCE);
1052 InitCommonControls();
1054 /* create parent window */
1055 hWndParent = create_parent_window();
1056 ok(hWndParent != NULL, "Failed to create parent Window!\n");
1059 skip("parent window not present\n");
1063 flush_sequences(sequences, NUM_MSG_SEQUENCE);
1065 /* create trackbar with set styles */
1066 hWndTrackbar = create_trackbar(style, hWndParent);
1068 ok(hWndTrackbar != NULL, "Expected non NULL value\n");
1071 skip("trackbar control not present?\n");
1075 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, empty_seq, "create Trackbar Window", FALSE);
1076 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_create_trackbar_wnd_seq, "parent trackbar window", TRUE);
1077 flush_sequences(sequences, NUM_MSG_SEQUENCE);
1079 /* TEST OF ALL SETTER and GETTER MESSAGES with required styles turned on*/
1080 test_trackbar_buddy(hWndTrackbar);
1081 test_line_size(hWndTrackbar);
1082 test_page_size(hWndTrackbar);
1083 test_position(hWndTrackbar);
1084 test_range(hWndTrackbar);
1085 test_selection(hWndTrackbar);
1086 test_thumb_length(hWndTrackbar);
1087 test_tic_settings(hWndTrackbar);
1088 test_tic_placement(hWndTrackbar);
1089 test_tool_tips(hWndTrackbar);
1090 test_unicode(hWndTrackbar);
1091 test_TBS_AUTOTICKS();
1093 flush_sequences(sequences, NUM_MSG_SEQUENCE);
1094 DestroyWindow(hWndTrackbar);
1096 /* test getters and setters without styles set */
1097 hWndTrackbar = create_trackbar(0, hWndParent);
1099 ok(hWndTrackbar != NULL, "Expected non NULL value\n");
1102 skip("trackbar control not present?\n");
1106 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_new_window_test_seq, "new trackbar window test sequence", TRUE);
1108 test_ignore_selection(hWndTrackbar);
1110 DestroyWindow(hWndTrackbar);
1112 test_initial_state();
1114 DestroyWindow(hWndParent);