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