comctl32: Update ticks on TBM_SETRANGE.
[wine] / dlls / comctl32 / tests / trackbar.c
1 /* Unit tests for the track bar control.
2  *
3  * Copyright 2007 Keith Stevens
4  *
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.
9  *
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.
14  *
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
18  */
19
20 #include <windows.h>
21 #include <commctrl.h>
22 #include <stdio.h>
23
24 #include "wine/test.h"
25 #include "msg.h"
26
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
31
32 static HWND hWndParent;
33
34 static struct msg_sequence *sequences[NUM_MSG_SEQUENCE];
35
36 static const struct message create_trackbar_wnd_seq[] = {
37     {0}
38 };
39
40 static const struct message parent_empty_test_seq[] = {
41     {0}
42 };
43
44 static const struct message parent_create_trackbar_wnd_seq[] = {
45     { WM_NOTIFYFORMAT, sent},
46     { WM_QUERYUISTATE, sent|optional},
47     { WM_WINDOWPOSCHANGING, sent},
48     { WM_NCACTIVATE, sent},
49     { PBT_APMRESUMECRITICAL, sent},
50     { WM_WINDOWPOSCHANGING, sent},
51     { PBT_APMRESUMESTANDBY, sent},
52     { WM_IME_SETCONTEXT, sent|optional},
53     { WM_IME_NOTIFY, sent|optional},
54     { WM_CTLCOLORSTATIC, sent},
55     { WM_NOTIFY, sent},
56     {0}
57 };
58
59 static const struct message parent_new_window_test_seq[] = {
60     { WM_QUERYNEWPALETTE, sent|optional },
61     { WM_WINDOWPOSCHANGING, sent|optional},
62     { WM_NCACTIVATE, sent|optional},
63     { PBT_APMRESUMECRITICAL, sent|optional},
64     { WM_IME_SETCONTEXT, sent|defwinproc|optional},
65     { WM_IME_NOTIFY, sent|defwinproc|optional},
66     { WM_SETFOCUS, sent|defwinproc|optional},
67     { WM_NOTIFYFORMAT, sent},
68     { WM_QUERYUISTATE, sent|optional},
69     {0}
70 };
71
72 static const struct message buddy_window_test_seq[] = {
73     { TBM_GETBUDDY, sent|wparam, TRUE},
74     { TBM_SETBUDDY, sent|wparam, FALSE},
75     { WM_PAINT, sent|defwinproc},
76     { TBM_SETBUDDY, sent|wparam, FALSE},
77     { WM_PAINT, sent|defwinproc},
78     { TBM_GETBUDDY, sent|wparam, TRUE},
79     { TBM_SETBUDDY, sent|wparam, TRUE},
80     { WM_PAINT, sent|defwinproc},
81     { TBM_SETBUDDY, sent|wparam, TRUE},
82     { WM_PAINT, sent|defwinproc},
83     { TBM_GETBUDDY, sent|wparam, FALSE},
84     { TBM_GETBUDDY, sent|wparam, TRUE},
85     {0}
86 };
87
88 static const struct message parent_buddy_window_test_seq[] = {
89     { WM_CTLCOLORSTATIC, sent},
90     { WM_NOTIFY, sent},
91     { WM_CTLCOLORSTATIC, sent},
92     { WM_NOTIFY, sent},
93     { WM_CTLCOLORSTATIC, sent},
94     { WM_NOTIFY, sent},
95     { WM_CTLCOLORSTATIC, sent},
96     { WM_NOTIFY, sent},
97     {0}
98 };
99
100 static const struct message line_size_test_seq[] = {
101     { TBM_SETLINESIZE, sent|lparam, 0, 10},
102     { TBM_SETLINESIZE, sent|lparam, 0, 4},
103     { TBM_GETLINESIZE, sent},
104     {0}
105 };
106
107 static const struct message page_size_test_seq[] = {
108     { TBM_SETPAGESIZE, sent|lparam, 0, 10},
109     { TBM_SETPAGESIZE, sent|lparam, 0, -1},
110     { TBM_GETPAGESIZE, sent},
111     {0}
112 };
113
114 static const struct message position_test_seq[] = {
115     { TBM_SETPOS, sent|wparam|lparam, TRUE, -1},
116     { WM_PAINT, sent|defwinproc},
117     { TBM_GETPOS, sent},
118     { TBM_SETPOS, sent|wparam|lparam, TRUE, 5},
119     { WM_PAINT, sent|defwinproc},
120     { TBM_GETPOS, sent},
121     { TBM_SETPOS, sent|wparam|lparam, TRUE, 5},
122     { TBM_SETPOS, sent|wparam|lparam, TRUE, 1000},
123     { WM_PAINT, sent|defwinproc},
124     { TBM_GETPOS, sent},
125     { TBM_SETPOS, sent|wparam|lparam, FALSE, 20},
126     { TBM_GETPOS, sent},
127     { TBM_SETPOS, sent|wparam|lparam, TRUE, 20},
128     { TBM_GETPOS, sent},
129     {0}
130 };
131
132 static const struct message parent_position_test_seq[] = {
133     { WM_CTLCOLORSTATIC, sent},
134     { WM_NOTIFY, sent},
135     { WM_CTLCOLORSTATIC, sent},
136     { WM_NOTIFY, sent},
137     { WM_CTLCOLORSTATIC, sent},
138     { WM_NOTIFY, sent},
139     {0}
140 };
141
142 static const struct message range_test_seq[] = {
143     { TBM_SETRANGE, sent|wparam|lparam, TRUE, MAKELONG(0, 10)},
144     { WM_PAINT, sent|defwinproc},
145     { TBM_GETRANGEMAX, sent},
146     { TBM_GETRANGEMIN, sent},
147     { TBM_SETRANGE, sent|wparam|lparam, TRUE, MAKELONG(-1, 1000)},
148     { WM_PAINT, sent|defwinproc},
149     { TBM_GETRANGEMAX, sent},
150     { TBM_GETRANGEMIN, sent},
151     { TBM_SETRANGE, sent|wparam|lparam, TRUE, MAKELONG(10, 0)},
152     { WM_PAINT, sent|defwinproc},
153     { TBM_GETRANGEMAX, sent},
154     { TBM_GETRANGEMIN, sent},
155     { TBM_SETRANGE, sent|wparam|lparam, FALSE, MAKELONG(0, 10)},
156     { TBM_GETRANGEMAX, sent},
157     { TBM_GETRANGEMIN, sent},
158     { TBM_SETRANGEMAX, sent|wparam|lparam, TRUE, 10},
159     { WM_PAINT, sent|defwinproc},
160     { TBM_GETRANGEMAX, sent},
161     { TBM_SETRANGEMAX, sent|wparam|lparam, TRUE, -1},
162     { WM_PAINT, sent|defwinproc},
163     { TBM_GETRANGEMAX, sent},
164     { TBM_SETRANGEMAX, sent|wparam|lparam, FALSE, 10},
165     { TBM_GETRANGEMAX, sent},
166     { TBM_SETRANGEMIN, sent|wparam|lparam, TRUE, 0},
167     { WM_PAINT, sent|defwinproc},
168     { TBM_GETRANGEMIN, sent},
169     { TBM_SETRANGEMIN, sent|wparam|lparam, TRUE, 10},
170     { WM_PAINT, sent|defwinproc},
171     { TBM_GETRANGEMIN, sent},
172     { TBM_SETRANGEMIN, sent|wparam|lparam, TRUE, -10},
173     { WM_PAINT, sent|defwinproc},
174     { TBM_GETRANGEMIN, sent},
175     { TBM_SETRANGEMIN, sent|wparam|lparam, FALSE, 5},
176     { TBM_GETRANGEMIN, sent},
177     { TBM_GETRANGEMAX, sent},
178     { TBM_GETRANGEMIN, sent},
179     {0}
180 };
181
182 static const struct message parent_range_test_seq[] = {
183     { WM_CTLCOLORSTATIC, sent},
184     { WM_NOTIFY, sent},
185     { WM_CTLCOLORSTATIC, sent},
186     { WM_NOTIFY, sent},
187     { WM_CTLCOLORSTATIC, sent},
188     { WM_NOTIFY, sent},
189     { WM_CTLCOLORSTATIC, sent},
190     { WM_NOTIFY, sent},
191     { WM_CTLCOLORSTATIC, sent},
192     { WM_NOTIFY, sent},
193     { WM_CTLCOLORSTATIC, sent},
194     { WM_NOTIFY, sent},
195     { WM_CTLCOLORSTATIC, sent},
196     { WM_NOTIFY, sent},
197     { WM_CTLCOLORSTATIC, sent},
198     { WM_NOTIFY, sent},
199     {0}
200 };
201
202 static const struct message selection_test_seq[] = {
203     { TBM_SETSEL, sent|wparam|lparam, TRUE, MAKELONG(0, 10)},
204     { WM_PAINT, sent|defwinproc},
205     { TBM_GETSELEND, sent},
206     { TBM_GETSELSTART, sent},
207     { TBM_SETSEL, sent|wparam|lparam, TRUE, MAKELONG(5, 20)},
208     { WM_PAINT, sent|defwinproc},
209     { TBM_GETSELEND, sent},
210     { TBM_GETSELSTART, sent},
211     { TBM_SETSEL, sent|wparam|lparam, FALSE, MAKELONG(5, 10)},
212     { TBM_GETSELEND, sent},
213     { TBM_GETSELSTART, sent},
214     { TBM_SETSELEND, sent|wparam|lparam, TRUE, 10},
215     { WM_PAINT, sent|defwinproc},
216     { TBM_GETSELEND, sent},
217     { TBM_SETSELEND, sent|wparam|lparam, TRUE, 20},
218     { WM_PAINT, sent|defwinproc},
219     { TBM_GETSELEND, sent},
220     { TBM_SETSELEND, sent|wparam|lparam, TRUE, 4},
221     { WM_PAINT, sent|defwinproc},
222     { TBM_GETSELEND, sent},
223     { TBM_SETSELEND, sent|wparam|lparam, FALSE, 2},
224     { TBM_GETSELEND, sent},
225     { TBM_GETSELEND, sent},
226     { TBM_SETSELSTART, sent|wparam|lparam, TRUE, 5},
227     { WM_PAINT, sent|defwinproc},
228     { TBM_GETSELSTART, sent},
229     { TBM_SETSELSTART, sent|wparam|lparam, TRUE, 0},
230     { WM_PAINT, sent|defwinproc},
231     { TBM_GETSELSTART, sent},
232     { TBM_SETSELSTART, sent|wparam|lparam, TRUE, 20},
233     { WM_PAINT, sent|defwinproc},
234     { TBM_GETSELSTART, sent},
235     { TBM_SETSELSTART, sent|wparam|lparam, FALSE, 8},
236     { TBM_GETSELSTART, sent},
237     { TBM_GETSELSTART, sent},
238     {0}
239 };
240
241 static const struct message parent_selection_test_seq[] = {
242     { WM_CTLCOLORSTATIC, sent},
243     { WM_NOTIFY, sent},
244     { WM_CTLCOLORSTATIC, sent},
245     { WM_NOTIFY, sent},
246     { WM_CTLCOLORSTATIC, sent},
247     { WM_NOTIFY, sent},
248     { WM_CTLCOLORSTATIC, sent},
249     { WM_NOTIFY, sent},
250     { WM_CTLCOLORSTATIC, sent},
251     { WM_NOTIFY, sent},
252     { WM_CTLCOLORSTATIC, sent},
253     { WM_NOTIFY, sent},
254     { WM_CTLCOLORSTATIC, sent},
255     { WM_NOTIFY, sent},
256     { WM_CTLCOLORSTATIC, sent},
257     { WM_NOTIFY, sent},
258     {0}
259 };
260
261 static const struct message tic_settings_test_seq[] = {
262     { TBM_SETTIC, sent|lparam, 0, 0},
263     { TBM_SETTIC, sent|lparam, 0, 5},
264     { TBM_SETTIC, sent|lparam, 0, 10},
265     { TBM_SETTIC, sent|lparam, 0, 20},
266     { TBM_SETRANGE, sent|wparam|lparam, TRUE, MAKELONG(0,10)},
267     { WM_PAINT, sent|defwinproc},
268     { TBM_SETTICFREQ, sent|wparam, 2},
269     { WM_PAINT, sent|defwinproc},
270     { TBM_GETNUMTICS, sent},
271     { TBM_SETTICFREQ, sent|wparam, 5},
272     { WM_PAINT, sent|defwinproc},
273     { TBM_GETNUMTICS, sent},
274     { TBM_SETTICFREQ, sent|wparam, 15},
275     { WM_PAINT, sent|defwinproc},
276     { TBM_GETNUMTICS, sent},
277     { TBM_GETNUMTICS, sent},
278     {0}
279 };
280
281 static const struct message parent_tic_settings_test_seq[] = {
282     { WM_CTLCOLORSTATIC, sent},
283     { WM_NOTIFY, sent},
284     { WM_CTLCOLORSTATIC, sent},
285     { WM_NOTIFY, sent},
286     { WM_CTLCOLORSTATIC, sent},
287     { WM_NOTIFY, sent},
288     { WM_CTLCOLORSTATIC, sent},
289     { WM_NOTIFY, sent},
290     {0}
291 };
292
293 static const struct message thumb_length_test_seq[] = {
294     { TBM_SETTHUMBLENGTH, sent|wparam|lparam, 15, 0},
295     { WM_PAINT, sent|defwinproc},
296     { TBM_GETTHUMBLENGTH, sent},
297     { TBM_SETTHUMBLENGTH, sent|wparam|lparam, 20, 0},
298     { WM_PAINT, sent|defwinproc},
299     { TBM_GETTHUMBLENGTH, sent},
300     { TBM_GETTHUMBLENGTH, sent},
301     { WM_SIZE, sent},
302     { WM_PAINT, sent|defwinproc},
303     { TBM_GETTHUMBLENGTH, sent},
304     { WM_SIZE, sent},
305     { WM_PAINT, sent|defwinproc},
306     { TBM_GETTHUMBLENGTH, sent},
307     {0}
308 };
309
310 static const struct message parent_thumb_length_test_seq[] = {
311     { WM_CTLCOLORSTATIC, sent},
312     { WM_NOTIFY, sent},
313     { WM_CTLCOLORSTATIC, sent},
314     { WM_NOTIFY, sent},
315     { WM_CTLCOLORSTATIC, sent},
316     { WM_NOTIFY, sent},
317     { WM_CTLCOLORSTATIC, sent},
318     { WM_NOTIFY, sent},
319     {0}
320 };
321
322 static const struct message tic_placement_test_seq[] = {
323     { TBM_GETPTICS, sent},
324     { TBM_GETTIC, sent|wparam, 0},
325     { TBM_GETTIC, sent|wparam, 2},
326     { TBM_GETTIC, sent|wparam, 4},
327     { TBM_GETTICPOS, sent|wparam, 0},
328     { TBM_GETTICPOS, sent|wparam, 2},
329     {0}
330 };
331
332 static const struct message tool_tips_test_seq[] = {
333     { TBM_SETTIPSIDE, sent|wparam, TBTS_TOP},
334     { TBM_SETTIPSIDE, sent|wparam, TBTS_LEFT},
335     { TBM_SETTIPSIDE, sent|wparam, TBTS_BOTTOM},
336     { TBM_SETTIPSIDE, sent|wparam, TBTS_RIGHT},
337     { TBM_SETTOOLTIPS, sent},
338     { TBM_GETTOOLTIPS, sent},
339     { TBM_SETTOOLTIPS, sent},
340     { TBM_GETTOOLTIPS, sent},
341     { TBM_SETTOOLTIPS, sent},
342     { TBM_GETTOOLTIPS, sent},
343     { TBM_GETTOOLTIPS, sent},
344     {0}
345 };
346
347 static const struct message unicode_test_seq[] = {
348     { TBM_SETUNICODEFORMAT, sent|wparam, TRUE},
349     { TBM_SETUNICODEFORMAT, sent|wparam, FALSE},
350     { TBM_GETUNICODEFORMAT, sent},
351     {0}
352 };
353
354 static const struct message ignore_selection_test_seq[] = {
355     { TBM_SETSEL, sent|wparam|lparam, TRUE, MAKELONG(0,10)},
356     { TBM_GETSELEND, sent},
357     { TBM_GETSELSTART, sent},
358     { TBM_SETSEL, sent|wparam|lparam, FALSE, MAKELONG(0,10)},
359     { TBM_GETSELEND, sent},
360     { TBM_GETSELSTART, sent},
361     { TBM_SETSELEND, sent|wparam|lparam, TRUE,0},
362     { TBM_GETSELEND, sent},
363     { TBM_SETSELEND, sent|wparam|lparam, TRUE, 10},
364     { TBM_GETSELEND, sent},
365     { TBM_SETSELEND, sent|wparam|lparam, FALSE,0},
366     { TBM_GETSELEND, sent},
367     { TBM_SETSELSTART, sent|wparam|lparam, TRUE,0},
368     { TBM_GETSELSTART, sent},
369     { TBM_SETSELSTART, sent|wparam|lparam, TRUE, 10},
370     { TBM_GETSELSTART, sent},
371     { TBM_SETSELSTART, sent|wparam|lparam, FALSE,0},
372     { TBM_GETSELSTART, sent},
373     {0}
374 };
375
376 static LRESULT WINAPI parent_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){
377     static LONG defwndproc_counter = 0;
378     LRESULT ret;
379     struct message msg;
380
381     /* log system messages, except for painting */
382     if (message < WM_USER &&
383         message != WM_PAINT &&
384         message != WM_ERASEBKGND &&
385         message != WM_NCPAINT &&
386         message != WM_NCHITTEST &&
387         message != WM_GETTEXT &&
388         message != WM_GETICON &&
389         message != WM_DEVICECHANGE)
390     {
391         trace("parent: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
392
393         msg.message = message;
394         msg.flags = sent|wparam|lparam;
395         if (defwndproc_counter) msg.flags |= defwinproc;
396         msg.wParam = wParam;
397         msg.lParam = lParam;
398         add_message(sequences, PARENT_SEQ_INDEX, &msg);
399     }
400
401     defwndproc_counter++;
402     ret = DefWindowProcA(hwnd, message, wParam, lParam);
403     defwndproc_counter--;
404
405     return ret;
406 }
407
408 static BOOL register_parent_wnd_class(void){
409     WNDCLASSA cls;
410
411     cls.style = 0;
412     cls.lpfnWndProc = parent_wnd_proc;
413     cls.cbClsExtra = 0;
414     cls.cbWndExtra = 0;
415     cls.hInstance = GetModuleHandleA(NULL);
416     cls.hIcon = 0;
417     cls.hCursor = LoadCursorA(0, IDC_ARROW);
418     cls.hbrBackground = GetStockObject(WHITE_BRUSH);
419     cls.lpszMenuName = NULL;
420     cls.lpszClassName = "Trackbar test parent class";
421     return RegisterClassA(&cls);
422 }
423
424 static HWND create_parent_window(void){
425     if (!register_parent_wnd_class())
426         return NULL;
427
428     return CreateWindowEx(0, "Trackbar test parent class",
429         "Trackbar test parent window",
430         WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX |
431         WS_MAXIMIZEBOX | WS_VISIBLE,
432         0, 0, 100, 100,
433         GetDesktopWindow(), NULL, GetModuleHandleA(NULL), NULL);
434 }
435
436 static LRESULT WINAPI trackbar_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){
437     WNDPROC oldproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_USERDATA);
438     static LONG defwndproc_counter = 0;
439     LRESULT ret;
440     struct message msg;
441
442     trace("trackbar: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
443
444     msg.message = message;
445     msg.flags = sent|wparam|lparam;
446     if (defwndproc_counter) msg.flags |= defwinproc;
447     msg.wParam = wParam;
448     msg.lParam = lParam;
449     add_message(sequences, TRACKBAR_SEQ_INDEX, &msg);
450
451     defwndproc_counter++;
452     ret = CallWindowProcA(oldproc, hwnd, message, wParam, lParam);
453     defwndproc_counter--;
454
455     return ret;
456 }
457
458 static HWND create_trackbar(DWORD style, HWND parent){
459     HWND hWndTrack;
460     WNDPROC oldproc;
461     RECT rect;
462
463     GetClientRect(parent, &rect);
464     hWndTrack = CreateWindowEx(
465       0, TRACKBAR_CLASS,"Trackbar Control", style,
466       rect.right,rect.bottom, 100, 50,
467       parent, NULL,GetModuleHandleA(NULL) ,NULL);
468
469     if (!hWndTrack) return NULL;
470
471     oldproc = (WNDPROC)SetWindowLongPtrA(hWndTrack, GWLP_WNDPROC, (LONG_PTR)trackbar_subclass_proc);
472     SetWindowLongPtrA(hWndTrack, GWLP_USERDATA, (LONG_PTR)oldproc);
473
474     return hWndTrack;
475 }
476
477 /* test functions for setters, getters, and sequences */
478
479 static void test_trackbar_buddy(HWND hWndTrackbar){
480     HWND hWndLeftBuddy;
481     HWND hWndRightBuddy;
482     HWND hWndCurrentBuddy;
483     HWND rTest;
484
485     flush_sequences(sequences, NUM_MSG_SEQUENCE);
486
487     hWndLeftBuddy = CreateWindowEx(0, STATUSCLASSNAME, NULL, 0,
488         0,0,300,20, NULL, NULL, NULL, NULL);
489     ok(hWndLeftBuddy != NULL, "Expected non NULL value\n");
490
491     if (hWndLeftBuddy != NULL){
492         hWndCurrentBuddy = (HWND) SendMessage(hWndTrackbar, TBM_GETBUDDY, TRUE, 0);
493         rTest = (HWND) SendMessage(hWndTrackbar, TBM_SETBUDDY, FALSE, (LPARAM) hWndLeftBuddy);
494         ok(rTest == hWndCurrentBuddy, "Expected hWndCurrentBuddy\n");
495         rTest = (HWND) SendMessage(hWndTrackbar, TBM_SETBUDDY, FALSE, (LPARAM) hWndLeftBuddy);
496         ok(rTest == hWndLeftBuddy, "Expected hWndLeftBuddy\n");
497     } else
498         skip ("left buddy control not present?\n");
499
500     hWndRightBuddy = CreateWindowEx(0, STATUSCLASSNAME, NULL, 0,
501         0,0,300,20,NULL,NULL, NULL, NULL);
502
503     ok(hWndRightBuddy != NULL, "expected non NULL value\n");
504
505     /* test TBM_SETBUDDY */
506     if (hWndRightBuddy != NULL){
507         hWndCurrentBuddy = (HWND) SendMessage(hWndTrackbar, TBM_GETBUDDY, TRUE, 0);
508         rTest = (HWND) SendMessage(hWndTrackbar, TBM_SETBUDDY, TRUE, (LPARAM) hWndRightBuddy);
509         ok(rTest == hWndCurrentBuddy, "Expected hWndCurrentBuddy\n");
510         rTest = (HWND) SendMessage(hWndTrackbar, TBM_SETBUDDY, TRUE, (LPARAM) hWndRightBuddy);
511         ok(rTest == hWndRightBuddy, "Expected hWndRightbuddy\n");
512      } else
513        skip("Right buddy control not present?\n");
514
515     /* test TBM_GETBUDDY */
516     if (hWndLeftBuddy != NULL){
517         rTest = (HWND) SendMessage(hWndTrackbar, TBM_GETBUDDY, FALSE, 0);
518         ok(rTest == hWndLeftBuddy, "Expected hWndLeftBuddy\n");
519         DestroyWindow(hWndLeftBuddy);
520     }
521     if (hWndRightBuddy != NULL){
522         rTest = (HWND) SendMessage(hWndTrackbar, TBM_GETBUDDY, TRUE,0);
523         ok(rTest == hWndRightBuddy, "Expected hWndRightBuddy\n");
524         DestroyWindow(hWndRightBuddy);
525     }
526
527     ok_sequence(sequences, TRACKBAR_SEQ_INDEX, buddy_window_test_seq, "buddy test sequence", TRUE);
528     ok_sequence(sequences, PARENT_SEQ_INDEX, parent_buddy_window_test_seq, "parent buddy test seq", TRUE);
529
530 }
531
532 static void test_line_size(HWND hWndTrackbar){
533     int r;
534
535     flush_sequences(sequences, NUM_MSG_SEQUENCE);
536
537     /* test TBM_SETLINESIZE */
538     r = SendMessage(hWndTrackbar, TBM_SETLINESIZE, 0, 10);
539     expect(1,r);
540     r = SendMessage(hWndTrackbar, TBM_SETLINESIZE, 0, 4);
541     expect(10, r);
542
543     /* test TBM_GETLINESIZE */
544     r = SendMessage(hWndTrackbar, TBM_GETLINESIZE, 0,0);
545     expect(4, r);
546
547     ok_sequence(sequences, TRACKBAR_SEQ_INDEX, line_size_test_seq, "linesize test sequence", FALSE);
548     ok_sequence(sequences, PARENT_SEQ_INDEX, parent_empty_test_seq, "parent line test sequence", FALSE);
549 }
550
551
552 static void test_page_size(HWND hWndTrackbar){
553     int r;
554
555     flush_sequences(sequences, NUM_MSG_SEQUENCE);
556
557     /* test TBM_SETPAGESIZE */
558     r = SendMessage(hWndTrackbar, TBM_SETPAGESIZE, 0, 10);
559     expect(20, r);
560     r = SendMessage(hWndTrackbar, TBM_SETPAGESIZE, 0, -1);
561     expect(10, r);
562
563     /* test TBM_GETPAGESIZE */
564     r = SendMessage(hWndTrackbar, TBM_GETPAGESIZE, 0,0);
565     expect(20, r);
566
567     ok_sequence(sequences, TRACKBAR_SEQ_INDEX, page_size_test_seq, "page size test sequence", FALSE);
568     ok_sequence(sequences, PARENT_SEQ_INDEX, parent_empty_test_seq, "parent page size test sequence", FALSE);
569
570     /* check for zero page size */
571     r = SendMessage(hWndTrackbar, TBM_SETPAGESIZE, 0, 0);
572     expect(20, r);
573     r = SendMessage(hWndTrackbar, TBM_GETPAGESIZE, 0, 0);
574     expect(0, r);
575     /* revert to default */
576     r = SendMessage(hWndTrackbar, TBM_SETPAGESIZE, 0, -1);
577     expect(0, r);
578     r = SendMessage(hWndTrackbar, TBM_GETPAGESIZE, 0, 0);
579     expect(20, r);
580     /* < -1 */
581     r = SendMessage(hWndTrackbar, TBM_SETPAGESIZE, 0, -2);
582     expect(20, r);
583     r = SendMessage(hWndTrackbar, TBM_GETPAGESIZE, 0, 0);
584     expect(-2, r);
585 }
586
587 static void test_position(HWND hWndTrackbar){
588     int r;
589
590     flush_sequences(sequences, NUM_MSG_SEQUENCE);
591     /* test TBM_SETPOS */
592     SendMessage(hWndTrackbar, TBM_SETPOS, TRUE, -1);
593     r = SendMessage(hWndTrackbar, TBM_GETPOS, 0, 0);
594     expect(0, r);
595     SendMessage(hWndTrackbar, TBM_SETPOS, TRUE, 5);
596     r = SendMessage(hWndTrackbar, TBM_GETPOS, 0,0);
597     expect(5, r);
598     SendMessage(hWndTrackbar, TBM_SETPOS, TRUE, 5);
599     SendMessage(hWndTrackbar, TBM_SETPOS, TRUE, 1000);
600     r = SendMessage(hWndTrackbar, TBM_GETPOS, 0,0);
601     expect(100, r);
602     SendMessage(hWndTrackbar, TBM_SETPOS, FALSE, 20);
603     r = SendMessage(hWndTrackbar, TBM_GETPOS, 0,0);
604     expect(20, r);
605     SendMessage(hWndTrackbar, TBM_SETPOS, TRUE, 20);
606
607     /* test TBM_GETPOS */
608     r = SendMessage(hWndTrackbar, TBM_GETPOS, 0,0);
609     expect(20, r);
610
611     ok_sequence(sequences, TRACKBAR_SEQ_INDEX, position_test_seq, "position test sequence", TRUE);
612     ok_sequence(sequences, PARENT_SEQ_INDEX, parent_position_test_seq, "parent position test sequence", TRUE);
613 }
614
615 static void test_range(HWND hWndTrackbar){
616     int r;
617
618     flush_sequences(sequences, NUM_MSG_SEQUENCE);
619     /* test TBM_SETRANGE */
620     SendMessage(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(0, 10));
621     r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
622     expect(10, r);
623     r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
624     expect(0, r);
625     SendMessage(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(-1, 1000));
626     r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
627     expect(1000, r);
628     r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
629     expect(-1, r);
630     SendMessage(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(10, 0));
631     r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
632     expect(0, r);
633     r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
634     expect(10, r);
635     SendMessage(hWndTrackbar, TBM_SETRANGE, FALSE, MAKELONG(0,10));
636     r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
637     expect(10, r);
638     r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
639     expect(0, r);
640
641     /*test TBM_SETRANGEMAX */
642     SendMessage(hWndTrackbar, TBM_SETRANGEMAX, TRUE, 10);
643     r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
644     expect(10, r);
645     SendMessage(hWndTrackbar, TBM_SETRANGEMAX, TRUE, -1);
646     r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
647     expect(-1, r);
648     SendMessage(hWndTrackbar, TBM_SETRANGEMAX, FALSE, 10);
649     r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
650     expect(10, r);
651
652     /* testing TBM_SETRANGEMIN */
653     SendMessage(hWndTrackbar, TBM_SETRANGEMIN, TRUE, 0);
654     r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
655     expect(0, r);
656     SendMessage(hWndTrackbar, TBM_SETRANGEMIN, TRUE, 10);
657     r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
658     expect(10, r);
659     SendMessage(hWndTrackbar, TBM_SETRANGEMIN, TRUE, -10);
660     r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
661     expect(-10, r);
662     SendMessage(hWndTrackbar, TBM_SETRANGEMIN, FALSE, 5);
663     r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
664     expect(5, r);
665
666     /* test TBM_GETRANGEMAX */
667     r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
668     expect(10, r);
669
670     /* test TBM_GETRANGEMIN */
671     r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
672     expect(5, r);
673
674     ok_sequence(sequences, TRACKBAR_SEQ_INDEX, range_test_seq, "range test sequence", TRUE);
675     ok_sequence(sequences, PARENT_SEQ_INDEX, parent_range_test_seq, "parent range test sequence", TRUE);
676 }
677
678 static void test_selection(HWND hWndTrackbar){
679     int r;
680
681     flush_sequences(sequences, NUM_MSG_SEQUENCE);
682     /* test TBM_SETSEL */
683     SendMessage(hWndTrackbar, TBM_SETSEL, TRUE, MAKELONG(0,10));
684     r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
685     expect(10, r);
686     r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
687     expect(5, r);
688     SendMessage(hWndTrackbar, TBM_SETSEL, TRUE, MAKELONG(5, 20));
689     r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
690     expect(10, r);
691     r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
692     expect(5, r);
693     SendMessage(hWndTrackbar, TBM_SETSEL, FALSE, MAKELONG(5, 10));
694     r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
695     expect(10, r);
696     r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
697     expect(5, r);
698
699     /* test TBM_SETSELEND */
700     SendMessage(hWndTrackbar, TBM_SETSELEND, TRUE, 10);
701     r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
702     expect(10, r);
703     SendMessage(hWndTrackbar, TBM_SETSELEND, TRUE, 20);
704     r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
705     expect(10, r);
706     SendMessage(hWndTrackbar, TBM_SETSELEND, TRUE, 4);
707     r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
708     expect(4, r);
709     SendMessage(hWndTrackbar, TBM_SETSELEND, FALSE, 2);
710     r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
711     expect(2, r);
712
713     /* test TBM_GETSELEND */
714     r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
715     expect(2, r);
716
717     /* testing TBM_SETSELSTART */
718     SendMessage(hWndTrackbar, TBM_SETSELSTART, TRUE, 5);
719     r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
720     expect(5, r);
721     SendMessage(hWndTrackbar, TBM_SETSELSTART, TRUE, 0);
722     r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
723     expect(5, r);
724     SendMessage(hWndTrackbar, TBM_SETSELSTART, TRUE, 20);
725     r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
726     expect(20, r);
727     SendMessage(hWndTrackbar, TBM_SETSELSTART, FALSE, 8);
728     r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
729     expect(8, r);
730
731     /* test TBM_GETSELSTART */
732     r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
733     expect(8, r);
734
735     ok_sequence(sequences, TRACKBAR_SEQ_INDEX, selection_test_seq, "selection test sequence", TRUE);
736     ok_sequence(sequences, PARENT_SEQ_INDEX, parent_selection_test_seq, "parent selection test seqence", TRUE);
737 }
738
739 static void test_thumb_length(HWND hWndTrackbar){
740     int r;
741
742     flush_sequences(sequences, NUM_MSG_SEQUENCE);
743     /* testing TBM_SETTHUMBLENGTH */
744     SendMessage(hWndTrackbar, TBM_SETTHUMBLENGTH, 15, 0);
745     r = SendMessage(hWndTrackbar, TBM_GETTHUMBLENGTH, 0,0);
746     expect(15, r);
747     SendMessage(hWndTrackbar, TBM_SETTHUMBLENGTH, 20, 0);
748     r = SendMessage(hWndTrackbar, TBM_GETTHUMBLENGTH, 0,0);
749     expect(20, r);
750
751     /* test TBM_GETTHUMBLENGTH */
752     r = SendMessage(hWndTrackbar, TBM_GETTHUMBLENGTH, 0,0);
753     expect(20, r);
754
755     r = SendMessage(hWndTrackbar, WM_SIZE, 0,0);
756     expect(0, r);
757     r = SendMessage(hWndTrackbar, TBM_GETTHUMBLENGTH, 0,0);
758     expect(20, r);
759     r = SendMessage(hWndTrackbar, WM_SIZE, 0, MAKELPARAM(50, 50) );
760     expect(0, r);
761     r = SendMessage(hWndTrackbar, TBM_GETTHUMBLENGTH, 0,0);
762     expect(20, r);
763
764     ok_sequence(sequences, TRACKBAR_SEQ_INDEX, thumb_length_test_seq, "thumb length test sequence", TRUE);
765     ok_sequence(sequences, PARENT_SEQ_INDEX, parent_thumb_length_test_seq, "parent thumb length test sequence", TRUE);
766 }
767
768 static void test_tic_settings(HWND hWndTrackbar){
769     int r;
770
771     /* testing TBM_SETTIC */
772     /* Set tics at 5 and 10 */
773     /* 0 and 20 are out of range and should not be set */
774     r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0, 0);
775     expect(10, r);
776     r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0, 0);
777     expect(5, r);
778
779     flush_sequences(sequences, NUM_MSG_SEQUENCE);
780     r = SendMessage(hWndTrackbar, TBM_SETTIC, 0, 0);
781     ok(r == FALSE, "Expected FALSE, got %d\n", r);
782     r = SendMessage(hWndTrackbar, TBM_SETTIC, 0, 5);
783     ok(r == TRUE, "Expected TRUE, got %d\n", r);
784     r = SendMessage(hWndTrackbar, TBM_SETTIC, 0, 10);
785     ok(r == TRUE, "Expected TRUE, got %d\n", r);
786
787     r = SendMessage(hWndTrackbar, TBM_SETTIC, 0, 20);
788     ok(r == FALSE, "Expected False, got %d\n", r);
789
790     /* test TBM_SETTICFREQ */
791     SendMessage(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(0, 10));
792     SendMessage(hWndTrackbar, TBM_SETTICFREQ, 2, 0);
793     r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
794     expect(6, r);
795     SendMessage(hWndTrackbar, TBM_SETTICFREQ, 5, 0);
796     r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
797     expect(3, r);
798     SendMessage(hWndTrackbar, TBM_SETTICFREQ, 15, 0);
799     r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
800     expect(2, r);
801
802     /* test TBM_GETNUMTICS */
803     /* since TIC FREQ is 15, there should be only 2 tics now */
804     r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
805     expect(2, r);
806
807     ok_sequence(sequences, TRACKBAR_SEQ_INDEX, tic_settings_test_seq, "tic settings test sequence", TRUE);
808     ok_sequence(sequences, PARENT_SEQ_INDEX, parent_tic_settings_test_seq, "parent tic settings test sequence", TRUE);
809
810     /* range [0,0], freq = 1 */
811     SendMessage(hWndTrackbar, TBM_SETRANGEMAX, TRUE, 0);
812     SendMessage(hWndTrackbar, TBM_SETRANGEMIN, TRUE, 0);
813     SendMessage(hWndTrackbar, TBM_SETTICFREQ, 1, 0);
814     r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
815     expect(2, r);
816     /* range [0,1], freq = 1 */
817     SendMessage(hWndTrackbar, TBM_SETRANGEMAX, TRUE, 1);
818     SendMessage(hWndTrackbar, TBM_SETRANGEMIN, TRUE, 0);
819     SendMessage(hWndTrackbar, TBM_SETTICFREQ, 1, 0);
820     r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
821     expect(2, r);
822     /* range [0,2], freq = 1 */
823     SendMessage(hWndTrackbar, TBM_SETRANGEMAX, TRUE, 2);
824     SendMessage(hWndTrackbar, TBM_SETRANGEMIN, TRUE, 0);
825     SendMessage(hWndTrackbar, TBM_SETTICFREQ, 1, 0);
826     r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
827     expect(3, r);
828 }
829
830 static void test_tic_placement(HWND hWndTrackbar){
831     int r;
832     DWORD *rPTics;
833     DWORD numtics;
834
835     SendMessage(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(1, 6));
836     SendMessage(hWndTrackbar, TBM_SETTICFREQ, 1, 0);
837
838     numtics = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
839     ok(numtics == 6, "Expected 6, got %d\n", numtics);
840
841     flush_sequences(sequences, NUM_MSG_SEQUENCE);
842     /* test TBM_GETPTICS */
843     rPTics = (DWORD *) SendMessage(hWndTrackbar, TBM_GETPTICS, 0,0);
844     expect(2, rPTics[0]);
845     expect(3, rPTics[1]);
846     expect(4, rPTics[2]);
847     expect(5, rPTics[3]);
848
849     /* test TBM_GETTIC */
850     r = SendMessage(hWndTrackbar, TBM_GETTIC, 0,0);
851     expect(2, r);
852     r = SendMessage(hWndTrackbar, TBM_GETTIC, 2,0);
853     expect(4, r);
854     r = SendMessage(hWndTrackbar, TBM_GETTIC, 4,0);
855     expect(-1, r);
856
857     /* test TBM_GETTICPIC */
858     r = SendMessage(hWndTrackbar, TBM_GETTICPOS, 0, 0);
859     ok(r > 0, "Expected r > 0, got %d\n", r);
860     r = SendMessage(hWndTrackbar, TBM_GETTICPOS, 2, 0);
861     ok(r > 0, "Expected r > 0, got %d\n", r);
862
863     ok_sequence(sequences, TRACKBAR_SEQ_INDEX, tic_placement_test_seq, "get tic placement test sequence", FALSE);
864     ok_sequence(sequences, PARENT_SEQ_INDEX, parent_empty_test_seq, "parent get tic placement test sequence", FALSE);
865 }
866
867
868 static void test_tool_tips(HWND hWndTrackbar){
869     int r;
870     HWND hWndTooltip;
871     HWND rTest;
872
873     flush_sequences(sequences, NUM_MSG_SEQUENCE);
874     /* testing TBM_SETTIPSIDE */
875     r = SendMessage(hWndTrackbar, TBM_SETTIPSIDE, TBTS_TOP, 0);
876     expect(TBTS_TOP, r);
877     r = SendMessage(hWndTrackbar, TBM_SETTIPSIDE, TBTS_LEFT, 0);
878     expect(TBTS_TOP, r);
879     r = SendMessage(hWndTrackbar, TBM_SETTIPSIDE, TBTS_BOTTOM, 0);
880     expect(TBTS_LEFT, r);
881     r = SendMessage(hWndTrackbar, TBM_SETTIPSIDE, TBTS_RIGHT, 0);
882     expect(TBTS_BOTTOM, r);
883
884     /* testing TBM_SETTOOLTIPS */
885     hWndTooltip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, 0,
886       CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
887       NULL, NULL, NULL, NULL);
888
889     ok(hWndTooltip != NULL, "Expected non NULL value\n");
890     if (hWndTooltip != NULL){
891         SendMessage(hWndTrackbar, TBM_SETTOOLTIPS, (LPARAM) hWndTooltip, 0);
892         rTest = (HWND) SendMessage(hWndTrackbar, TBM_GETTOOLTIPS, 0,0);
893         ok(rTest == hWndTooltip, "Expected hWndToolTip, got\n");
894         SendMessage(hWndTrackbar, TBM_SETTOOLTIPS, 0, 0);
895         rTest = (HWND) SendMessage(hWndTrackbar, TBM_GETTOOLTIPS, 0,0);
896         ok(rTest == NULL, "Expected NULL\n");
897         SendMessage(hWndTrackbar, TBM_SETTOOLTIPS, (LPARAM) hWndTooltip, 5);
898         rTest = (HWND) SendMessage(hWndTrackbar, TBM_GETTOOLTIPS, 0,0);
899         ok(rTest == hWndTooltip, "Expected hWndTooltip, got\n");
900     } else
901         skip("tool tip control not present?\n");
902
903     /* test TBM_GETTOOLTIPS */
904     rTest = (HWND) SendMessage(hWndTrackbar, TBM_GETTOOLTIPS, 0,0);
905     ok(rTest == hWndTooltip, "Expected hWndTooltip\n");
906
907     ok_sequence(sequences, TRACKBAR_SEQ_INDEX, tool_tips_test_seq, "tool tips test sequence", FALSE);
908     ok_sequence(sequences, PARENT_SEQ_INDEX, parent_empty_test_seq, "parent tool tips test sequence", FALSE);
909 }
910
911
912 static void test_unicode(HWND hWndTrackbar){
913     int r;
914
915     flush_sequences(sequences, NUM_MSG_SEQUENCE);
916     /* testing TBM_SETUNICODEFORMAT */
917     r = SendMessage(hWndTrackbar, TBM_SETUNICODEFORMAT, TRUE, 0);
918     ok(r == FALSE, "Expected FALSE, got %d\n",r);
919     r = SendMessage(hWndTrackbar, TBM_SETUNICODEFORMAT, FALSE, 0);
920     ok(r == TRUE, "Expected TRUE, got %d\n",r);
921
922     /* test TBM_GETUNICODEFORMAT */
923     r = SendMessage(hWndTrackbar, TBM_GETUNICODEFORMAT, 0,0);
924     ok(r == FALSE, "Expected FALSE, got %d\n",r);
925
926     ok_sequence(sequences, TRACKBAR_SEQ_INDEX, unicode_test_seq, "unicode test sequence", FALSE);
927     ok_sequence(sequences, PARENT_SEQ_INDEX, parent_empty_test_seq, "parent unicode test sequence", FALSE);
928 }
929
930 static void test_ignore_selection(HWND hWndTrackbar){
931     int r;
932
933     flush_sequences(sequences, NUM_MSG_SEQUENCE);
934     /* test TBM_SETSEL  ensure that it is ignored */
935     SendMessage(hWndTrackbar, TBM_SETSEL, TRUE, MAKELONG(0,10));
936     r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
937     expect(0, r);
938     r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
939     expect(0, r);
940     SendMessage(hWndTrackbar, TBM_SETSEL, FALSE, MAKELONG(0,10));
941     r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
942     expect(0, r);
943     r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
944     expect(0, r);
945
946     /* test TBM_SETSELEND, ensure that it is ignored */
947     SendMessage(hWndTrackbar, TBM_SETSELEND, TRUE, 0);
948     r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
949     expect(0, r);
950     SendMessage(hWndTrackbar, TBM_SETSELEND, TRUE, 10);
951     r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
952     expect(0,r);
953     SendMessage(hWndTrackbar, TBM_SETSELEND, FALSE, 0);
954     r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
955     expect(0, r);
956
957     /* test TBM_SETSELSTART, ensure that it is ignored */
958     SendMessage(hWndTrackbar, TBM_SETSELSTART, TRUE, 0);
959     r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
960     expect(0, r);
961     SendMessage(hWndTrackbar, TBM_SETSELSTART, TRUE, 10);
962     r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
963     expect(0,r);
964     SendMessage(hWndTrackbar, TBM_SETSELSTART, FALSE, 0);
965     r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
966     expect(0, r);
967
968     ok_sequence(sequences, TRACKBAR_SEQ_INDEX, ignore_selection_test_seq, "ignore selection setting test sequence", FALSE);
969     ok_sequence(sequences, PARENT_SEQ_INDEX, parent_empty_test_seq, "parent ignore selection setting test sequence", FALSE);
970 }
971
972 static void test_initial_state(void)
973 {
974     HWND hWnd;
975     int ret;
976
977     hWnd = create_trackbar(0, hWndParent);
978
979     ret = SendMessage(hWnd, TBM_GETNUMTICS, 0, 0);
980     expect(2, ret);
981     ret = SendMessage(hWnd, TBM_GETTIC, 0, 0);
982     expect(-1, ret);
983     ret = SendMessage(hWnd, TBM_GETTICPOS, 0, 0);
984     expect(-1, ret);
985     ret = SendMessage(hWnd, TBM_GETRANGEMIN, 0, 0);
986     expect(0, ret);
987     ret = SendMessage(hWnd, TBM_GETRANGEMAX, 0, 0);
988     expect(100, ret);
989
990     ret = SendMessage(hWnd, TBM_SETRANGEMAX, TRUE, 200);
991     expect(0, ret);
992
993     ret = SendMessage(hWnd, TBM_GETNUMTICS, 0, 0);
994     expect(2, ret);
995
996     ret = SendMessage(hWnd, TBM_SETRANGEMIN, TRUE, 10);
997     expect(0, ret);
998
999     ret = SendMessage(hWnd, TBM_GETNUMTICS, 0, 0);
1000     expect(2, ret);
1001
1002     DestroyWindow(hWnd);
1003 }
1004
1005 static void test_TBS_AUTOTICKS(void)
1006 {
1007     HWND hWnd;
1008     int ret;
1009
1010     hWnd = create_trackbar(TBS_AUTOTICKS, hWndParent);
1011
1012     ret = SendMessage(hWnd, TBM_GETNUMTICS, 0, 0);
1013     expect(2, ret);
1014     ret = SendMessage(hWnd, TBM_GETTIC, 0, 0);
1015     expect(-1, ret);
1016     ret = SendMessage(hWnd, TBM_GETTICPOS, 0, 0);
1017     expect(-1, ret);
1018     ret = SendMessage(hWnd, TBM_GETRANGEMIN, 0, 0);
1019     expect(0, ret);
1020     ret = SendMessage(hWnd, TBM_GETRANGEMAX, 0, 0);
1021     expect(100, ret);
1022
1023     /* TBM_SETRANGEMAX rebuilds tics */
1024     ret = SendMessage(hWnd, TBM_SETRANGEMAX, TRUE, 200);
1025     expect(0, ret);
1026     ret = SendMessage(hWnd, TBM_GETNUMTICS, 0, 0);
1027     expect(201, ret);
1028
1029     /* TBM_SETRANGEMIN rebuilds tics */
1030     ret = SendMessage(hWnd, TBM_SETRANGEMAX, TRUE, 100);
1031     expect(0, ret);
1032     ret = SendMessage(hWnd, TBM_SETRANGEMIN, TRUE, 10);
1033     expect(0, ret);
1034     ret = SendMessage(hWnd, TBM_GETNUMTICS, 0, 0);
1035     expect(91, ret);
1036
1037     ret = SendMessage(hWnd, TBM_SETRANGEMIN, TRUE, 0);
1038     expect(0, ret);
1039
1040     /* TBM_SETRANGE rebuilds tics */
1041     ret = SendMessage(hWnd, TBM_SETRANGE, TRUE, MAKELONG(10, 200));
1042     expect(0, ret);
1043     ret = SendMessage(hWnd, TBM_GETNUMTICS, 0, 0);
1044     expect(191, ret);
1045
1046     DestroyWindow(hWnd);
1047 }
1048
1049 START_TEST(trackbar)
1050 {
1051     DWORD style = WS_VISIBLE | TBS_TOOLTIPS | TBS_ENABLESELRANGE | TBS_FIXEDLENGTH | TBS_AUTOTICKS;
1052     HWND hWndTrackbar;
1053
1054     init_msg_sequences(sequences, NUM_MSG_SEQUENCE);
1055     InitCommonControls();
1056
1057     /* create parent window */
1058     hWndParent = create_parent_window();
1059     ok(hWndParent != NULL, "Failed to create parent Window!\n");
1060
1061     if(!hWndParent){
1062         skip("parent window not present\n");
1063         return;
1064     }
1065
1066     flush_sequences(sequences, NUM_MSG_SEQUENCE);
1067
1068     /* create trackbar with set styles */
1069     hWndTrackbar = create_trackbar(style, hWndParent);
1070
1071     ok(hWndTrackbar != NULL, "Expected non NULL value\n");
1072
1073     if (!hWndTrackbar){
1074         skip("trackbar control not present?\n");
1075         return;
1076     }
1077
1078     ok_sequence(sequences, TRACKBAR_SEQ_INDEX, create_trackbar_wnd_seq, "create Trackbar Window", FALSE);
1079     ok_sequence(sequences, PARENT_SEQ_INDEX, parent_create_trackbar_wnd_seq, "parent trackbar window", TRUE);
1080     flush_sequences(sequences, NUM_MSG_SEQUENCE);
1081
1082     /* TEST OF ALL SETTER and GETTER MESSAGES with required styles turned on*/
1083     test_trackbar_buddy(hWndTrackbar);
1084     test_line_size(hWndTrackbar);
1085     test_page_size(hWndTrackbar);
1086     test_position(hWndTrackbar);
1087     test_range(hWndTrackbar);
1088     test_selection(hWndTrackbar);
1089     test_thumb_length(hWndTrackbar);
1090     test_tic_settings(hWndTrackbar);
1091     test_tic_placement(hWndTrackbar);
1092     test_tool_tips(hWndTrackbar);
1093     test_unicode(hWndTrackbar);
1094     test_TBS_AUTOTICKS();
1095
1096     flush_sequences(sequences, NUM_MSG_SEQUENCE);
1097     DestroyWindow(hWndTrackbar);
1098
1099     /* test getters and setters without styles set */
1100     hWndTrackbar = create_trackbar(0, hWndParent);
1101
1102     ok(hWndTrackbar != NULL, "Expected non NULL value\n");
1103
1104     if (!hWndTrackbar){
1105         skip("trackbar control not present?\n");
1106         return;
1107     }
1108
1109     ok_sequence(sequences, PARENT_SEQ_INDEX, parent_new_window_test_seq, "new trackbar window test sequence", TRUE);
1110
1111     test_ignore_selection(hWndTrackbar);
1112
1113     DestroyWindow(hWndTrackbar);
1114
1115     test_initial_state();
1116
1117     DestroyWindow(hWndParent);
1118 }