mshtml: Wine Gecko 1.4 release.
[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     {0}
302 };
303
304 static const struct message parent_thumb_length_test_seq[] = {
305     { WM_CTLCOLORSTATIC, sent},
306     { WM_NOTIFY, sent},
307     { WM_CTLCOLORSTATIC, sent},
308     { WM_NOTIFY, sent},
309     {0}
310 };
311
312 static const struct message tic_placement_test_seq[] = {
313     { TBM_GETPTICS, sent},
314     { TBM_GETTIC, sent|wparam, 0},
315     { TBM_GETTIC, sent|wparam, 2},
316     { TBM_GETTIC, sent|wparam, 4},
317     { TBM_GETTICPOS, sent|wparam, 0},
318     { TBM_GETTICPOS, sent|wparam, 2},
319     {0}
320 };
321
322 static const struct message tool_tips_test_seq[] = {
323     { TBM_SETTIPSIDE, sent|wparam, TBTS_TOP},
324     { TBM_SETTIPSIDE, sent|wparam, TBTS_LEFT},
325     { TBM_SETTIPSIDE, sent|wparam, TBTS_BOTTOM},
326     { TBM_SETTIPSIDE, sent|wparam, TBTS_RIGHT},
327     { TBM_SETTOOLTIPS, sent},
328     { TBM_GETTOOLTIPS, sent},
329     { TBM_SETTOOLTIPS, sent},
330     { TBM_GETTOOLTIPS, sent},
331     { TBM_SETTOOLTIPS, sent},
332     { TBM_GETTOOLTIPS, sent},
333     { TBM_GETTOOLTIPS, sent},
334     {0}
335 };
336
337 static const struct message unicode_test_seq[] = {
338     { TBM_SETUNICODEFORMAT, sent|wparam, TRUE},
339     { TBM_SETUNICODEFORMAT, sent|wparam, FALSE},
340     { TBM_GETUNICODEFORMAT, sent},
341     {0}
342 };
343
344 static const struct message ignore_selection_test_seq[] = {
345     { TBM_SETSEL, sent|wparam|lparam, TRUE, MAKELONG(0,10)},
346     { TBM_GETSELEND, sent},
347     { TBM_GETSELSTART, sent},
348     { TBM_SETSEL, sent|wparam|lparam, FALSE, MAKELONG(0,10)},
349     { TBM_GETSELEND, sent},
350     { TBM_GETSELSTART, sent},
351     { TBM_SETSELEND, sent|wparam|lparam, TRUE,0},
352     { TBM_GETSELEND, sent},
353     { TBM_SETSELEND, sent|wparam|lparam, TRUE, 10},
354     { TBM_GETSELEND, sent},
355     { TBM_SETSELEND, sent|wparam|lparam, FALSE,0},
356     { TBM_GETSELEND, sent},
357     { TBM_SETSELSTART, sent|wparam|lparam, TRUE,0},
358     { TBM_GETSELSTART, sent},
359     { TBM_SETSELSTART, sent|wparam|lparam, TRUE, 10},
360     { TBM_GETSELSTART, sent},
361     { TBM_SETSELSTART, sent|wparam|lparam, FALSE,0},
362     { TBM_GETSELSTART, sent},
363     {0}
364 };
365
366 static LRESULT WINAPI parent_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){
367     static LONG defwndproc_counter = 0;
368     LRESULT ret;
369     struct message msg;
370
371     /* log system messages, except for painting */
372     if (message < WM_USER &&
373         message != WM_PAINT &&
374         message != WM_ERASEBKGND &&
375         message != WM_NCPAINT &&
376         message != WM_NCHITTEST &&
377         message != WM_GETTEXT &&
378         message != WM_GETICON &&
379         message != WM_DEVICECHANGE)
380     {
381         trace("parent: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
382
383         msg.message = message;
384         msg.flags = sent|wparam|lparam;
385         if (defwndproc_counter) msg.flags |= defwinproc;
386         msg.wParam = wParam;
387         msg.lParam = lParam;
388         add_message(sequences, PARENT_SEQ_INDEX, &msg);
389     }
390
391     defwndproc_counter++;
392     ret = DefWindowProcA(hwnd, message, wParam, lParam);
393     defwndproc_counter--;
394
395     return ret;
396 }
397
398 static BOOL register_parent_wnd_class(void){
399     WNDCLASSA cls;
400
401     cls.style = 0;
402     cls.lpfnWndProc = parent_wnd_proc;
403     cls.cbClsExtra = 0;
404     cls.cbWndExtra = 0;
405     cls.hInstance = GetModuleHandleA(NULL);
406     cls.hIcon = 0;
407     cls.hCursor = LoadCursorA(0, IDC_ARROW);
408     cls.hbrBackground = GetStockObject(WHITE_BRUSH);
409     cls.lpszMenuName = NULL;
410     cls.lpszClassName = "Trackbar test parent class";
411     return RegisterClassA(&cls);
412 }
413
414 static HWND create_parent_window(void){
415     if (!register_parent_wnd_class())
416         return NULL;
417
418     return CreateWindowEx(0, "Trackbar test parent class",
419         "Trackbar test parent window",
420         WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX |
421         WS_MAXIMIZEBOX | WS_VISIBLE,
422         0, 0, 100, 100,
423         GetDesktopWindow(), NULL, GetModuleHandleA(NULL), NULL);
424 }
425
426 static LRESULT WINAPI trackbar_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){
427     WNDPROC oldproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_USERDATA);
428     static LONG defwndproc_counter = 0;
429     LRESULT ret;
430     struct message msg;
431
432     trace("trackbar: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
433
434     msg.message = message;
435     msg.flags = sent|wparam|lparam;
436     if (defwndproc_counter) msg.flags |= defwinproc;
437     msg.wParam = wParam;
438     msg.lParam = lParam;
439     add_message(sequences, TRACKBAR_SEQ_INDEX, &msg);
440
441     defwndproc_counter++;
442     ret = CallWindowProcA(oldproc, hwnd, message, wParam, lParam);
443     defwndproc_counter--;
444
445     return ret;
446 }
447
448 static HWND create_trackbar(DWORD style, HWND parent){
449     HWND hWndTrack;
450     WNDPROC oldproc;
451     RECT rect;
452
453     GetClientRect(parent, &rect);
454     hWndTrack = CreateWindowEx(
455       0, TRACKBAR_CLASS,"Trackbar Control", style,
456       rect.right,rect.bottom, 100, 50,
457       parent, NULL,GetModuleHandleA(NULL) ,NULL);
458
459     if (!hWndTrack) return NULL;
460
461     oldproc = (WNDPROC)SetWindowLongPtrA(hWndTrack, GWLP_WNDPROC, (LONG_PTR)trackbar_subclass_proc);
462     SetWindowLongPtrA(hWndTrack, GWLP_USERDATA, (LONG_PTR)oldproc);
463
464     return hWndTrack;
465 }
466
467 /* test functions for setters, getters, and sequences */
468
469 static void test_trackbar_buddy(HWND hWndTrackbar){
470     HWND hWndLeftBuddy;
471     HWND hWndRightBuddy;
472     HWND hWndCurrentBuddy;
473     HWND rTest;
474
475     flush_sequences(sequences, NUM_MSG_SEQUENCE);
476
477     hWndLeftBuddy = CreateWindowEx(0, STATUSCLASSNAME, NULL, 0,
478         0,0,300,20, NULL, NULL, NULL, NULL);
479     ok(hWndLeftBuddy != NULL, "Expected non NULL value\n");
480
481     if (hWndLeftBuddy != NULL){
482         hWndCurrentBuddy = (HWND) SendMessage(hWndTrackbar, TBM_GETBUDDY, TRUE, 0);
483         rTest = (HWND) SendMessage(hWndTrackbar, TBM_SETBUDDY, FALSE, (LPARAM) hWndLeftBuddy);
484         ok(rTest == hWndCurrentBuddy, "Expected hWndCurrentBuddy\n");
485         rTest = (HWND) SendMessage(hWndTrackbar, TBM_SETBUDDY, FALSE, (LPARAM) hWndLeftBuddy);
486         ok(rTest == hWndLeftBuddy, "Expected hWndLeftBuddy\n");
487     } else
488         skip ("left buddy control not present?\n");
489
490     hWndRightBuddy = CreateWindowEx(0, STATUSCLASSNAME, NULL, 0,
491         0,0,300,20,NULL,NULL, NULL, NULL);
492
493     ok(hWndRightBuddy != NULL, "expected non NULL value\n");
494
495     /* test TBM_SETBUDDY */
496     if (hWndRightBuddy != NULL){
497         hWndCurrentBuddy = (HWND) SendMessage(hWndTrackbar, TBM_GETBUDDY, TRUE, 0);
498         rTest = (HWND) SendMessage(hWndTrackbar, TBM_SETBUDDY, TRUE, (LPARAM) hWndRightBuddy);
499         ok(rTest == hWndCurrentBuddy, "Expected hWndCurrentBuddy\n");
500         rTest = (HWND) SendMessage(hWndTrackbar, TBM_SETBUDDY, TRUE, (LPARAM) hWndRightBuddy);
501         ok(rTest == hWndRightBuddy, "Expected hWndRightbuddy\n");
502      } else
503        skip("Right buddy control not present?\n");
504
505     /* test TBM_GETBUDDY */
506     if (hWndLeftBuddy != NULL){
507         rTest = (HWND) SendMessage(hWndTrackbar, TBM_GETBUDDY, FALSE, 0);
508         ok(rTest == hWndLeftBuddy, "Expected hWndLeftBuddy\n");
509         DestroyWindow(hWndLeftBuddy);
510     }
511     if (hWndRightBuddy != NULL){
512         rTest = (HWND) SendMessage(hWndTrackbar, TBM_GETBUDDY, TRUE,0);
513         ok(rTest == hWndRightBuddy, "Expected hWndRightBuddy\n");
514         DestroyWindow(hWndRightBuddy);
515     }
516
517     ok_sequence(sequences, TRACKBAR_SEQ_INDEX, buddy_window_test_seq, "buddy test sequence", TRUE);
518     ok_sequence(sequences, PARENT_SEQ_INDEX, parent_buddy_window_test_seq, "parent buddy test seq", TRUE);
519
520 }
521
522 static void test_line_size(HWND hWndTrackbar){
523     int r;
524
525     flush_sequences(sequences, NUM_MSG_SEQUENCE);
526
527     /* test TBM_SETLINESIZE */
528     r = SendMessage(hWndTrackbar, TBM_SETLINESIZE, 0, 10);
529     expect(1,r);
530     r = SendMessage(hWndTrackbar, TBM_SETLINESIZE, 0, 4);
531     expect(10, r);
532
533     /* test TBM_GETLINESIZE */
534     r = SendMessage(hWndTrackbar, TBM_GETLINESIZE, 0,0);
535     expect(4, r);
536
537     ok_sequence(sequences, TRACKBAR_SEQ_INDEX, line_size_test_seq, "linesize test sequence", FALSE);
538     ok_sequence(sequences, PARENT_SEQ_INDEX, parent_empty_test_seq, "parent line test sequence", FALSE);
539 }
540
541
542 static void test_page_size(HWND hWndTrackbar){
543     int r;
544
545     flush_sequences(sequences, NUM_MSG_SEQUENCE);
546
547     /* test TBM_SETPAGESIZE */
548     r = SendMessage(hWndTrackbar, TBM_SETPAGESIZE, 0, 10);
549     expect(20, r);
550     r = SendMessage(hWndTrackbar, TBM_SETPAGESIZE, 0, -1);
551     expect(10, r);
552
553     /* test TBM_GETPAGESIZE */
554     r = SendMessage(hWndTrackbar, TBM_GETPAGESIZE, 0,0);
555     expect(20, r);
556
557     ok_sequence(sequences, TRACKBAR_SEQ_INDEX, page_size_test_seq, "page size test sequence", FALSE);
558     ok_sequence(sequences, PARENT_SEQ_INDEX, parent_empty_test_seq, "parent page size test sequence", FALSE);
559
560     /* check for zero page size */
561     r = SendMessage(hWndTrackbar, TBM_SETPAGESIZE, 0, 0);
562     expect(20, r);
563     r = SendMessage(hWndTrackbar, TBM_GETPAGESIZE, 0, 0);
564     expect(0, r);
565     /* revert to default */
566     r = SendMessage(hWndTrackbar, TBM_SETPAGESIZE, 0, -1);
567     expect(0, r);
568     r = SendMessage(hWndTrackbar, TBM_GETPAGESIZE, 0, 0);
569     expect(20, r);
570     /* < -1 */
571     r = SendMessage(hWndTrackbar, TBM_SETPAGESIZE, 0, -2);
572     expect(20, r);
573     r = SendMessage(hWndTrackbar, TBM_GETPAGESIZE, 0, 0);
574     expect(-2, r);
575 }
576
577 static void test_position(HWND hWndTrackbar){
578     int r;
579
580     flush_sequences(sequences, NUM_MSG_SEQUENCE);
581     /* test TBM_SETPOS */
582     SendMessage(hWndTrackbar, TBM_SETPOS, TRUE, -1);
583     r = SendMessage(hWndTrackbar, TBM_GETPOS, 0, 0);
584     expect(0, r);
585     SendMessage(hWndTrackbar, TBM_SETPOS, TRUE, 5);
586     r = SendMessage(hWndTrackbar, TBM_GETPOS, 0,0);
587     expect(5, r);
588     SendMessage(hWndTrackbar, TBM_SETPOS, TRUE, 5);
589     SendMessage(hWndTrackbar, TBM_SETPOS, TRUE, 1000);
590     r = SendMessage(hWndTrackbar, TBM_GETPOS, 0,0);
591     expect(100, r);
592     SendMessage(hWndTrackbar, TBM_SETPOS, FALSE, 20);
593     r = SendMessage(hWndTrackbar, TBM_GETPOS, 0,0);
594     expect(20, r);
595     SendMessage(hWndTrackbar, TBM_SETPOS, TRUE, 20);
596
597     /* test TBM_GETPOS */
598     r = SendMessage(hWndTrackbar, TBM_GETPOS, 0,0);
599     expect(20, r);
600
601     ok_sequence(sequences, TRACKBAR_SEQ_INDEX, position_test_seq, "position test sequence", TRUE);
602     ok_sequence(sequences, PARENT_SEQ_INDEX, parent_position_test_seq, "parent position test sequence", TRUE);
603 }
604
605 static void test_range(HWND hWndTrackbar){
606     int r;
607
608     flush_sequences(sequences, NUM_MSG_SEQUENCE);
609     /* test TBM_SETRANGE */
610     SendMessage(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(0, 10));
611     r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
612     expect(10, r);
613     r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
614     expect(0, r);
615     SendMessage(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(-1, 1000));
616     r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
617     expect(1000, r);
618     r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
619     expect(-1, r);
620     SendMessage(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(10, 0));
621     r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
622     expect(0, r);
623     r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
624     expect(10, r);
625     SendMessage(hWndTrackbar, TBM_SETRANGE, FALSE, MAKELONG(0,10));
626     r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
627     expect(10, r);
628     r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
629     expect(0, r);
630
631     /*test TBM_SETRANGEMAX */
632     SendMessage(hWndTrackbar, TBM_SETRANGEMAX, TRUE, 10);
633     r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
634     expect(10, r);
635     SendMessage(hWndTrackbar, TBM_SETRANGEMAX, TRUE, -1);
636     r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
637     expect(-1, r);
638     SendMessage(hWndTrackbar, TBM_SETRANGEMAX, FALSE, 10);
639     r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
640     expect(10, r);
641
642     /* testing TBM_SETRANGEMIN */
643     SendMessage(hWndTrackbar, TBM_SETRANGEMIN, TRUE, 0);
644     r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
645     expect(0, r);
646     SendMessage(hWndTrackbar, TBM_SETRANGEMIN, TRUE, 10);
647     r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
648     expect(10, r);
649     SendMessage(hWndTrackbar, TBM_SETRANGEMIN, TRUE, -10);
650     r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
651     expect(-10, r);
652     SendMessage(hWndTrackbar, TBM_SETRANGEMIN, FALSE, 5);
653     r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
654     expect(5, r);
655
656     /* test TBM_GETRANGEMAX */
657     r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
658     expect(10, r);
659
660     /* test TBM_GETRANGEMIN */
661     r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
662     expect(5, r);
663
664     ok_sequence(sequences, TRACKBAR_SEQ_INDEX, range_test_seq, "range test sequence", TRUE);
665     ok_sequence(sequences, PARENT_SEQ_INDEX, parent_range_test_seq, "parent range test sequence", TRUE);
666 }
667
668 static void test_selection(HWND hWndTrackbar){
669     int r;
670
671     flush_sequences(sequences, NUM_MSG_SEQUENCE);
672     /* test TBM_SETSEL */
673     SendMessage(hWndTrackbar, TBM_SETSEL, TRUE, MAKELONG(0,10));
674     r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
675     expect(10, r);
676     r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
677     expect(5, r);
678     SendMessage(hWndTrackbar, TBM_SETSEL, TRUE, MAKELONG(5, 20));
679     r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
680     expect(10, r);
681     r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
682     expect(5, r);
683     SendMessage(hWndTrackbar, TBM_SETSEL, FALSE, MAKELONG(5, 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
689     /* test TBM_SETSELEND */
690     SendMessage(hWndTrackbar, TBM_SETSELEND, TRUE, 10);
691     r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
692     expect(10, r);
693     SendMessage(hWndTrackbar, TBM_SETSELEND, TRUE, 20);
694     r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
695     expect(10, r);
696     SendMessage(hWndTrackbar, TBM_SETSELEND, TRUE, 4);
697     r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
698     expect(4, r);
699     SendMessage(hWndTrackbar, TBM_SETSELEND, FALSE, 2);
700     r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
701     expect(2, r);
702
703     /* test TBM_GETSELEND */
704     r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
705     expect(2, r);
706
707     /* testing TBM_SETSELSTART */
708     SendMessage(hWndTrackbar, TBM_SETSELSTART, TRUE, 5);
709     r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
710     expect(5, r);
711     SendMessage(hWndTrackbar, TBM_SETSELSTART, TRUE, 0);
712     r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
713     expect(5, r);
714     SendMessage(hWndTrackbar, TBM_SETSELSTART, TRUE, 20);
715     r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
716     expect(20, r);
717     SendMessage(hWndTrackbar, TBM_SETSELSTART, FALSE, 8);
718     r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
719     expect(8, r);
720
721     /* test TBM_GETSELSTART */
722     r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
723     expect(8, r);
724
725     ok_sequence(sequences, TRACKBAR_SEQ_INDEX, selection_test_seq, "selection test sequence", TRUE);
726     ok_sequence(sequences, PARENT_SEQ_INDEX, parent_selection_test_seq, "parent selection test seqence", TRUE);
727 }
728
729 static void test_thumb_length(HWND hWndTrackbar){
730     int r;
731
732     flush_sequences(sequences, NUM_MSG_SEQUENCE);
733     /* testing TBM_SETTHUMBLENGTH */
734     SendMessage(hWndTrackbar, TBM_SETTHUMBLENGTH, 15, 0);
735     r = SendMessage(hWndTrackbar, TBM_GETTHUMBLENGTH, 0,0);
736     expect(15, r);
737     SendMessage(hWndTrackbar, TBM_SETTHUMBLENGTH, 20, 0);
738     r = SendMessage(hWndTrackbar, TBM_GETTHUMBLENGTH, 0,0);
739     expect(20, r);
740
741     /* test TBM_GETTHUMBLENGTH */
742     r = SendMessage(hWndTrackbar, TBM_GETTHUMBLENGTH, 0,0);
743     expect(20, r);
744
745     ok_sequence(sequences, TRACKBAR_SEQ_INDEX, thumb_length_test_seq, "thumb length test sequence", TRUE);
746     ok_sequence(sequences, PARENT_SEQ_INDEX, parent_thumb_length_test_seq, "parent thumb lenth test sequence", TRUE);
747 }
748
749 static void test_tic_settings(HWND hWndTrackbar){
750     int r;
751
752     /* testing TBM_SETTIC */
753     /* Set tics at 5 and 10 */
754     /* 0 and 20 are out of range and should not be set */
755     r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0, 0);
756     expect(10, r);
757     r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0, 0);
758     expect(5, r);
759
760     flush_sequences(sequences, NUM_MSG_SEQUENCE);
761     r = SendMessage(hWndTrackbar, TBM_SETTIC, 0, 0);
762     ok(r == FALSE, "Expected FALSE, got %d\n", r);
763     r = SendMessage(hWndTrackbar, TBM_SETTIC, 0, 5);
764     ok(r == TRUE, "Expected TRUE, got %d\n", r);
765     r = SendMessage(hWndTrackbar, TBM_SETTIC, 0, 10);
766     ok(r == TRUE, "Expected TRUE, got %d\n", r);
767
768     r = SendMessage(hWndTrackbar, TBM_SETTIC, 0, 20);
769     ok(r == FALSE, "Expected False, got %d\n", r);
770
771     /* test TBM_SETTICFREQ */
772     SendMessage(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(0, 10));
773     SendMessage(hWndTrackbar, TBM_SETTICFREQ, 2, 0);
774     r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
775     expect(6, r);
776     SendMessage(hWndTrackbar, TBM_SETTICFREQ, 5, 0);
777     r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
778     expect(3, r);
779     SendMessage(hWndTrackbar, TBM_SETTICFREQ, 15, 0);
780     r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
781     expect(2, r);
782
783     /* test TBM_GETNUMTICS */
784     /* since TIC FREQ is 15, there should be only 2 tics now */
785     r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
786     expect(2, r);
787
788     ok_sequence(sequences, TRACKBAR_SEQ_INDEX, tic_settings_test_seq, "tic settings test sequence", TRUE);
789     ok_sequence(sequences, PARENT_SEQ_INDEX, parent_tic_settings_test_seq, "parent tic settings test sequence", TRUE);
790
791     /* range [0,0], freq = 1 */
792     SendMessage(hWndTrackbar, TBM_SETRANGEMAX, TRUE, 0);
793     SendMessage(hWndTrackbar, TBM_SETRANGEMIN, TRUE, 0);
794     SendMessage(hWndTrackbar, TBM_SETTICFREQ, 1, 0);
795     r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
796     expect(2, r);
797     /* range [0,1], freq = 1 */
798     SendMessage(hWndTrackbar, TBM_SETRANGEMAX, TRUE, 1);
799     SendMessage(hWndTrackbar, TBM_SETRANGEMIN, TRUE, 0);
800     SendMessage(hWndTrackbar, TBM_SETTICFREQ, 1, 0);
801     r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
802     expect(2, r);
803     /* range [0,2], freq = 1 */
804     SendMessage(hWndTrackbar, TBM_SETRANGEMAX, TRUE, 2);
805     SendMessage(hWndTrackbar, TBM_SETRANGEMIN, TRUE, 0);
806     SendMessage(hWndTrackbar, TBM_SETTICFREQ, 1, 0);
807     r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
808     expect(3, r);
809 }
810
811 static void test_tic_placement(HWND hWndTrackbar){
812     int r;
813     DWORD *rPTics;
814     DWORD numtics;
815
816     SendMessage(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(1, 6));
817     SendMessage(hWndTrackbar, TBM_SETTICFREQ, 1, 0);
818
819     numtics = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
820     ok(numtics == 6, "Expected 6, got %d\n", numtics);
821
822     flush_sequences(sequences, NUM_MSG_SEQUENCE);
823     /* test TBM_GETPTICS */
824     rPTics = (DWORD *) SendMessage(hWndTrackbar, TBM_GETPTICS, 0,0);
825     expect(2, rPTics[0]);
826     expect(3, rPTics[1]);
827     expect(4, rPTics[2]);
828     expect(5, rPTics[3]);
829
830     /* test TBM_GETTIC */
831     r = SendMessage(hWndTrackbar, TBM_GETTIC, 0,0);
832     expect(2, r);
833     r = SendMessage(hWndTrackbar, TBM_GETTIC, 2,0);
834     expect(4, r);
835     r = SendMessage(hWndTrackbar, TBM_GETTIC, 4,0);
836     expect(-1, r);
837
838     /* test TBM_GETTICPIC */
839     r = SendMessage(hWndTrackbar, TBM_GETTICPOS, 0, 0);
840     ok(r > 0, "Expected r > 0, got %d\n", r);
841     r = SendMessage(hWndTrackbar, TBM_GETTICPOS, 2, 0);
842     ok(r > 0, "Expected r > 0, got %d\n", r);
843
844     ok_sequence(sequences, TRACKBAR_SEQ_INDEX, tic_placement_test_seq, "get tic placement test sequence", FALSE);
845     ok_sequence(sequences, PARENT_SEQ_INDEX, parent_empty_test_seq, "parent get tic placement test sequence", FALSE);
846 }
847
848
849 static void test_tool_tips(HWND hWndTrackbar){
850     int r;
851     HWND hWndTooltip;
852     HWND rTest;
853
854     flush_sequences(sequences, NUM_MSG_SEQUENCE);
855     /* testing TBM_SETTIPSIDE */
856     r = SendMessage(hWndTrackbar, TBM_SETTIPSIDE, TBTS_TOP, 0);
857     expect(TBTS_TOP, r);
858     r = SendMessage(hWndTrackbar, TBM_SETTIPSIDE, TBTS_LEFT, 0);
859     expect(TBTS_TOP, r);
860     r = SendMessage(hWndTrackbar, TBM_SETTIPSIDE, TBTS_BOTTOM, 0);
861     expect(TBTS_LEFT, r);
862     r = SendMessage(hWndTrackbar, TBM_SETTIPSIDE, TBTS_RIGHT, 0);
863     expect(TBTS_BOTTOM, r);
864
865     /* testing TBM_SETTOOLTIPS */
866     hWndTooltip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, 0,
867       CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
868       NULL, NULL, NULL, NULL);
869
870     ok(hWndTooltip != NULL, "Expected non NULL value\n");
871     if (hWndTooltip != NULL){
872         SendMessage(hWndTrackbar, TBM_SETTOOLTIPS, (LPARAM) hWndTooltip, 0);
873         rTest = (HWND) SendMessage(hWndTrackbar, TBM_GETTOOLTIPS, 0,0);
874         ok(rTest == hWndTooltip, "Expected hWndToolTip, got\n");
875         SendMessage(hWndTrackbar, TBM_SETTOOLTIPS, 0, 0);
876         rTest = (HWND) SendMessage(hWndTrackbar, TBM_GETTOOLTIPS, 0,0);
877         ok(rTest == NULL, "Expected NULL\n");
878         SendMessage(hWndTrackbar, TBM_SETTOOLTIPS, (LPARAM) hWndTooltip, 5);
879         rTest = (HWND) SendMessage(hWndTrackbar, TBM_GETTOOLTIPS, 0,0);
880         ok(rTest == hWndTooltip, "Expected hWndTooltip, got\n");
881     } else
882         skip("tool tip control not present?\n");
883
884     /* test TBM_GETTOOLTIPS */
885     rTest = (HWND) SendMessage(hWndTrackbar, TBM_GETTOOLTIPS, 0,0);
886     ok(rTest == hWndTooltip, "Expected hWndTooltip\n");
887
888     ok_sequence(sequences, TRACKBAR_SEQ_INDEX, tool_tips_test_seq, "tool tips test sequence", FALSE);
889     ok_sequence(sequences, PARENT_SEQ_INDEX, parent_empty_test_seq, "parent tool tips test sequence", FALSE);
890 }
891
892
893 static void test_unicode(HWND hWndTrackbar){
894     int r;
895
896     flush_sequences(sequences, NUM_MSG_SEQUENCE);
897     /* testing TBM_SETUNICODEFORMAT */
898     r = SendMessage(hWndTrackbar, TBM_SETUNICODEFORMAT, TRUE, 0);
899     ok(r == FALSE, "Expected FALSE, got %d\n",r);
900     r = SendMessage(hWndTrackbar, TBM_SETUNICODEFORMAT, FALSE, 0);
901     ok(r == TRUE, "Expected TRUE, got %d\n",r);
902
903     /* test TBM_GETUNICODEFORMAT */
904     r = SendMessage(hWndTrackbar, TBM_GETUNICODEFORMAT, 0,0);
905     ok(r == FALSE, "Expected FALSE, got %d\n",r);
906
907     ok_sequence(sequences, TRACKBAR_SEQ_INDEX, unicode_test_seq, "unicode test sequence", FALSE);
908     ok_sequence(sequences, PARENT_SEQ_INDEX, parent_empty_test_seq, "parent unicode test sequence", FALSE);
909 }
910
911 static void test_ignore_selection(HWND hWndTrackbar){
912     int r;
913
914     flush_sequences(sequences, NUM_MSG_SEQUENCE);
915     /* test TBM_SETSEL  ensure that it is ignored */
916     SendMessage(hWndTrackbar, TBM_SETSEL, TRUE, MAKELONG(0,10));
917     r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
918     expect(0, r);
919     r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
920     expect(0, r);
921     SendMessage(hWndTrackbar, TBM_SETSEL, FALSE, MAKELONG(0,10));
922     r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
923     expect(0, r);
924     r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
925     expect(0, r);
926
927     /* test TBM_SETSELEND, ensure that it is ignored */
928     SendMessage(hWndTrackbar, TBM_SETSELEND, TRUE, 0);
929     r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
930     expect(0, r);
931     SendMessage(hWndTrackbar, TBM_SETSELEND, TRUE, 10);
932     r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
933     expect(0,r);
934     SendMessage(hWndTrackbar, TBM_SETSELEND, FALSE, 0);
935     r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
936     expect(0, r);
937
938     /* test TBM_SETSELSTART, ensure that it is ignored */
939     SendMessage(hWndTrackbar, TBM_SETSELSTART, TRUE, 0);
940     r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
941     expect(0, r);
942     SendMessage(hWndTrackbar, TBM_SETSELSTART, TRUE, 10);
943     r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
944     expect(0,r);
945     SendMessage(hWndTrackbar, TBM_SETSELSTART, FALSE, 0);
946     r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
947     expect(0, r);
948
949     ok_sequence(sequences, TRACKBAR_SEQ_INDEX, ignore_selection_test_seq, "ignore selection setting test sequence", FALSE);
950     ok_sequence(sequences, PARENT_SEQ_INDEX, parent_empty_test_seq, "parent ignore selection setting test sequence", FALSE);
951 }
952
953 static void test_initial_state(void)
954 {
955     HWND hWnd;
956     int ret;
957
958     hWnd = create_trackbar(0, hWndParent);
959
960     ret = SendMessage(hWnd, TBM_GETNUMTICS, 0, 0);
961     expect(2, ret);
962     ret = SendMessage(hWnd, TBM_GETTIC, 0, 0);
963     expect(-1, ret);
964     ret = SendMessage(hWnd, TBM_GETTICPOS, 0, 0);
965     expect(-1, ret);
966
967     DestroyWindow(hWnd);
968 }
969
970 START_TEST(trackbar)
971 {
972     DWORD style = WS_VISIBLE | TBS_TOOLTIPS | TBS_ENABLESELRANGE | TBS_FIXEDLENGTH | TBS_AUTOTICKS;
973     HWND hWndTrackbar;
974
975     init_msg_sequences(sequences, NUM_MSG_SEQUENCE);
976     InitCommonControls();
977
978     /* create parent window */
979     hWndParent = create_parent_window();
980     ok(hWndParent != NULL, "Failed to create parent Window!\n");
981
982     if(!hWndParent){
983         skip("parent window not present\n");
984         return;
985     }
986
987     flush_sequences(sequences, NUM_MSG_SEQUENCE);
988
989     /* create trackbar with set styles */
990     hWndTrackbar = create_trackbar(style, hWndParent);
991
992     ok(hWndTrackbar != NULL, "Expected non NULL value\n");
993
994     if (!hWndTrackbar){
995         skip("trackbar control not present?\n");
996         return;
997     }
998
999     ok_sequence(sequences, TRACKBAR_SEQ_INDEX, create_trackbar_wnd_seq, "create Trackbar Window", FALSE);
1000     ok_sequence(sequences, PARENT_SEQ_INDEX, parent_create_trackbar_wnd_seq, "parent trackbar window", TRUE);
1001     flush_sequences(sequences, NUM_MSG_SEQUENCE);
1002
1003     /* TEST OF ALL SETTER and GETTER MESSAGES with required styles turned on*/
1004     test_trackbar_buddy(hWndTrackbar);
1005     test_line_size(hWndTrackbar);
1006     test_page_size(hWndTrackbar);
1007     test_position(hWndTrackbar);
1008     test_range(hWndTrackbar);
1009     test_selection(hWndTrackbar);
1010     test_thumb_length(hWndTrackbar);
1011     test_tic_settings(hWndTrackbar);
1012     test_tic_placement(hWndTrackbar);
1013     test_tool_tips(hWndTrackbar);
1014     test_unicode(hWndTrackbar);
1015
1016     flush_sequences(sequences, NUM_MSG_SEQUENCE);
1017     DestroyWindow(hWndTrackbar);
1018
1019     /* test getters and setters without styles set */
1020     hWndTrackbar = create_trackbar(0, hWndParent);
1021
1022     ok(hWndTrackbar != NULL, "Expected non NULL value\n");
1023
1024     if (!hWndTrackbar){
1025         skip("trackbar control not present?\n");
1026         return;
1027     }
1028
1029     ok_sequence(sequences, PARENT_SEQ_INDEX, parent_new_window_test_seq, "new trackbar window test sequence", TRUE);
1030
1031     test_ignore_selection(hWndTrackbar);
1032
1033     DestroyWindow(hWndTrackbar);
1034
1035     test_initial_state();
1036
1037     DestroyWindow(hWndParent);
1038 }