TESTING -- override pthreads to fix gstreamer v5
[wine/multimedia.git] / dlls / comctl32 / tests / trackbar.c
blob5a468ee7527f4cc710781392d9b804fe23a25000
1 /* Unit tests for the track bar control.
3 * Copyright 2007 Keith Stevens
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include <windows.h>
21 #include <commctrl.h>
22 #include <stdio.h>
24 #include "wine/test.h"
25 #include "msg.h"
27 #define expect(expected, got) ok(got == expected, "Expected %d, got %d\n", expected, got)
28 #define NUM_MSG_SEQUENCE 2
29 #define PARENT_SEQ_INDEX 0
30 #define TRACKBAR_SEQ_INDEX 1
32 static HWND hWndParent;
34 static struct msg_sequence *sequences[NUM_MSG_SEQUENCE];
36 static const struct message empty_seq[] = {
37 {0}
40 static const struct message parent_create_trackbar_wnd_seq[] = {
41 { WM_NOTIFYFORMAT, sent},
42 { WM_QUERYUISTATE, sent|optional},
43 { WM_WINDOWPOSCHANGING, sent},
44 { WM_NCACTIVATE, sent},
45 { PBT_APMRESUMECRITICAL, sent},
46 { WM_WINDOWPOSCHANGING, sent},
47 { PBT_APMRESUMESTANDBY, sent},
48 { WM_IME_SETCONTEXT, sent|optional},
49 { WM_IME_NOTIFY, sent|optional},
50 { WM_CTLCOLORSTATIC, sent},
51 { WM_NOTIFY, sent},
52 {0}
55 static const struct message parent_new_window_test_seq[] = {
56 { WM_QUERYNEWPALETTE, sent|optional },
57 { WM_WINDOWPOSCHANGING, sent|optional},
58 { WM_NCACTIVATE, sent|optional},
59 { PBT_APMRESUMECRITICAL, sent|optional},
60 { WM_IME_SETCONTEXT, sent|defwinproc|optional},
61 { WM_IME_NOTIFY, sent|defwinproc|optional},
62 { WM_SETFOCUS, sent|defwinproc|optional},
63 { WM_NOTIFYFORMAT, sent},
64 { WM_QUERYUISTATE, sent|optional},
65 {0}
68 static const struct message buddy_window_test_seq[] = {
69 { TBM_GETBUDDY, sent|wparam, TRUE},
70 { TBM_SETBUDDY, sent|wparam, FALSE},
71 { WM_PAINT, sent|defwinproc},
72 { TBM_SETBUDDY, sent|wparam, FALSE},
73 { WM_PAINT, sent|defwinproc},
74 { TBM_GETBUDDY, sent|wparam, TRUE},
75 { TBM_SETBUDDY, sent|wparam, TRUE},
76 { WM_PAINT, sent|defwinproc},
77 { TBM_SETBUDDY, sent|wparam, TRUE},
78 { WM_PAINT, sent|defwinproc},
79 { TBM_GETBUDDY, sent|wparam, FALSE},
80 { TBM_GETBUDDY, sent|wparam, TRUE},
81 {0}
84 static const struct message parent_buddy_window_test_seq[] = {
85 { WM_CTLCOLORSTATIC, sent},
86 { WM_NOTIFY, sent},
87 { WM_CTLCOLORSTATIC, sent},
88 { WM_NOTIFY, sent},
89 { WM_CTLCOLORSTATIC, sent},
90 { WM_NOTIFY, sent},
91 { WM_CTLCOLORSTATIC, sent},
92 { WM_NOTIFY, sent},
93 {0}
96 static const struct message line_size_test_seq[] = {
97 { TBM_SETLINESIZE, sent|lparam, 0, 10},
98 { TBM_SETLINESIZE, sent|lparam, 0, 4},
99 { TBM_GETLINESIZE, sent},
103 static const struct message page_size_test_seq[] = {
104 { TBM_SETPAGESIZE, sent|lparam, 0, 10},
105 { TBM_SETPAGESIZE, sent|lparam, 0, -1},
106 { TBM_GETPAGESIZE, sent},
110 static const struct message position_test_seq[] = {
111 { TBM_SETPOS, sent|wparam|lparam, TRUE, -1},
112 { WM_PAINT, sent|defwinproc},
113 { TBM_GETPOS, sent},
114 { TBM_SETPOS, sent|wparam|lparam, TRUE, 5},
115 { WM_PAINT, sent|defwinproc},
116 { TBM_GETPOS, sent},
117 { TBM_SETPOS, sent|wparam|lparam, TRUE, 5},
118 { TBM_SETPOS, sent|wparam|lparam, TRUE, 1000},
119 { WM_PAINT, sent|defwinproc},
120 { TBM_GETPOS, sent},
121 { TBM_SETPOS, sent|wparam|lparam, FALSE, 20},
122 { TBM_GETPOS, sent},
123 { TBM_SETPOS, sent|wparam|lparam, TRUE, 20},
124 { TBM_GETPOS, sent},
128 static const struct message parent_position_test_seq[] = {
129 { WM_CTLCOLORSTATIC, sent},
130 { WM_NOTIFY, sent},
131 { WM_CTLCOLORSTATIC, sent},
132 { WM_NOTIFY, sent},
133 { WM_CTLCOLORSTATIC, sent},
134 { WM_NOTIFY, sent},
138 static const struct message range_test_seq[] = {
139 { TBM_SETRANGE, sent|wparam|lparam, TRUE, MAKELONG(0, 10)},
140 { WM_PAINT, sent|defwinproc},
141 { TBM_GETRANGEMAX, sent},
142 { TBM_GETRANGEMIN, sent},
143 { TBM_SETRANGE, sent|wparam|lparam, TRUE, MAKELONG(-1, 1000)},
144 { WM_PAINT, sent|defwinproc},
145 { TBM_GETRANGEMAX, sent},
146 { TBM_GETRANGEMIN, sent},
147 { TBM_SETRANGE, sent|wparam|lparam, TRUE, MAKELONG(10, 0)},
148 { WM_PAINT, sent|defwinproc},
149 { TBM_GETRANGEMAX, sent},
150 { TBM_GETRANGEMIN, sent},
151 { TBM_SETRANGE, sent|wparam|lparam, FALSE, MAKELONG(0, 10)},
152 { TBM_GETRANGEMAX, sent},
153 { TBM_GETRANGEMIN, sent},
154 { TBM_SETRANGEMAX, sent|wparam|lparam, TRUE, 10},
155 { WM_PAINT, sent|defwinproc},
156 { TBM_GETRANGEMAX, sent},
157 { TBM_SETRANGEMAX, sent|wparam|lparam, TRUE, -1},
158 { WM_PAINT, sent|defwinproc},
159 { TBM_GETRANGEMAX, sent},
160 { TBM_SETRANGEMAX, sent|wparam|lparam, FALSE, 10},
161 { TBM_GETRANGEMAX, sent},
162 { TBM_SETRANGEMIN, sent|wparam|lparam, TRUE, 0},
163 { WM_PAINT, sent|defwinproc},
164 { TBM_GETRANGEMIN, sent},
165 { TBM_SETRANGEMIN, sent|wparam|lparam, TRUE, 10},
166 { WM_PAINT, sent|defwinproc},
167 { TBM_GETRANGEMIN, sent},
168 { TBM_SETRANGEMIN, sent|wparam|lparam, TRUE, -10},
169 { WM_PAINT, sent|defwinproc},
170 { TBM_GETRANGEMIN, sent},
171 { TBM_SETRANGEMIN, sent|wparam|lparam, FALSE, 5},
172 { TBM_GETRANGEMIN, sent},
173 { TBM_GETRANGEMAX, sent},
174 { TBM_GETRANGEMIN, sent},
178 static const struct message parent_range_test_seq[] = {
179 { WM_CTLCOLORSTATIC, sent},
180 { WM_NOTIFY, sent},
181 { WM_CTLCOLORSTATIC, sent},
182 { WM_NOTIFY, sent},
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},
198 static const struct message selection_test_seq[] = {
199 { TBM_SETSEL, sent|wparam|lparam, TRUE, MAKELONG(0, 10)},
200 { WM_PAINT, sent|defwinproc},
201 { TBM_GETSELEND, sent},
202 { TBM_GETSELSTART, sent},
203 { TBM_SETSEL, sent|wparam|lparam, TRUE, MAKELONG(5, 20)},
204 { WM_PAINT, sent|defwinproc},
205 { TBM_GETSELEND, sent},
206 { TBM_GETSELSTART, sent},
207 { TBM_SETSEL, sent|wparam|lparam, FALSE, MAKELONG(5, 10)},
208 { TBM_GETSELEND, sent},
209 { TBM_GETSELSTART, sent},
210 { TBM_SETSELEND, sent|wparam|lparam, TRUE, 10},
211 { WM_PAINT, sent|defwinproc},
212 { TBM_GETSELEND, sent},
213 { TBM_SETSELEND, sent|wparam|lparam, TRUE, 20},
214 { WM_PAINT, sent|defwinproc},
215 { TBM_GETSELEND, sent},
216 { TBM_SETSELEND, sent|wparam|lparam, TRUE, 4},
217 { WM_PAINT, sent|defwinproc},
218 { TBM_GETSELEND, sent},
219 { TBM_SETSELEND, sent|wparam|lparam, FALSE, 2},
220 { TBM_GETSELEND, sent},
221 { TBM_GETSELEND, sent},
222 { TBM_SETSELSTART, sent|wparam|lparam, TRUE, 5},
223 { WM_PAINT, sent|defwinproc},
224 { TBM_GETSELSTART, sent},
225 { TBM_SETSELSTART, sent|wparam|lparam, TRUE, 0},
226 { WM_PAINT, sent|defwinproc},
227 { TBM_GETSELSTART, sent},
228 { TBM_SETSELSTART, sent|wparam|lparam, TRUE, 20},
229 { WM_PAINT, sent|defwinproc},
230 { TBM_GETSELSTART, sent},
231 { TBM_SETSELSTART, sent|wparam|lparam, FALSE, 8},
232 { TBM_GETSELSTART, sent},
233 { TBM_GETSELSTART, sent},
237 static const struct message parent_selection_test_seq[] = {
238 { WM_CTLCOLORSTATIC, sent},
239 { WM_NOTIFY, sent},
240 { WM_CTLCOLORSTATIC, sent},
241 { WM_NOTIFY, sent},
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},
257 static const struct message tic_settings_test_seq[] = {
258 { TBM_SETTIC, sent|lparam, 0, 0},
259 { TBM_SETTIC, sent|lparam, 0, 5},
260 { TBM_SETTIC, sent|lparam, 0, 10},
261 { TBM_SETTIC, sent|lparam, 0, 20},
262 { TBM_SETRANGE, sent|wparam|lparam, TRUE, MAKELONG(0,10)},
263 { WM_PAINT, sent|defwinproc},
264 { TBM_SETTICFREQ, sent|wparam, 2},
265 { WM_PAINT, sent|defwinproc},
266 { TBM_GETNUMTICS, sent},
267 { TBM_SETTICFREQ, sent|wparam, 5},
268 { WM_PAINT, sent|defwinproc},
269 { TBM_GETNUMTICS, sent},
270 { TBM_SETTICFREQ, sent|wparam, 15},
271 { WM_PAINT, sent|defwinproc},
272 { TBM_GETNUMTICS, sent},
273 { TBM_GETNUMTICS, sent},
277 static const struct message parent_tic_settings_test_seq[] = {
278 { WM_CTLCOLORSTATIC, sent},
279 { WM_NOTIFY, sent},
280 { WM_CTLCOLORSTATIC, sent},
281 { WM_NOTIFY, sent},
282 { WM_CTLCOLORSTATIC, sent},
283 { WM_NOTIFY, sent},
284 { WM_CTLCOLORSTATIC, sent},
285 { WM_NOTIFY, sent},
289 static const struct message thumb_length_test_seq[] = {
290 { TBM_SETTHUMBLENGTH, sent|wparam|lparam, 15, 0},
291 { WM_PAINT, sent|defwinproc},
292 { TBM_GETTHUMBLENGTH, sent},
293 { TBM_SETTHUMBLENGTH, sent|wparam|lparam, 20, 0},
294 { WM_PAINT, sent|defwinproc},
295 { TBM_GETTHUMBLENGTH, sent},
296 { TBM_GETTHUMBLENGTH, sent},
297 { WM_SIZE, sent},
298 { WM_PAINT, sent|defwinproc},
299 { TBM_GETTHUMBLENGTH, sent},
300 { WM_SIZE, sent},
301 { WM_PAINT, sent|defwinproc},
302 { TBM_GETTHUMBLENGTH, sent},
306 static const struct message parent_thumb_length_test_seq[] = {
307 { WM_CTLCOLORSTATIC, sent},
308 { WM_NOTIFY, sent},
309 { WM_CTLCOLORSTATIC, sent},
310 { WM_NOTIFY, sent},
311 { WM_CTLCOLORSTATIC, sent},
312 { WM_NOTIFY, sent},
313 { WM_CTLCOLORSTATIC, sent},
314 { WM_NOTIFY, sent},
318 static const struct message tic_placement_test_seq[] = {
319 { TBM_GETPTICS, sent},
320 { TBM_GETTIC, sent|wparam, 0},
321 { TBM_GETTIC, sent|wparam, 2},
322 { TBM_GETTIC, sent|wparam, 4},
323 { TBM_GETTICPOS, sent|wparam, 0},
324 { TBM_GETTICPOS, sent|wparam, 2},
328 static const struct message tool_tips_test_seq[] = {
329 { TBM_SETTIPSIDE, sent|wparam, TBTS_TOP},
330 { TBM_SETTIPSIDE, sent|wparam, TBTS_LEFT},
331 { TBM_SETTIPSIDE, sent|wparam, TBTS_BOTTOM},
332 { TBM_SETTIPSIDE, sent|wparam, TBTS_RIGHT},
333 { TBM_SETTOOLTIPS, sent},
334 { TBM_GETTOOLTIPS, sent},
335 { TBM_SETTOOLTIPS, sent},
336 { TBM_GETTOOLTIPS, sent},
337 { TBM_SETTOOLTIPS, sent},
338 { TBM_GETTOOLTIPS, sent},
339 { TBM_GETTOOLTIPS, sent},
343 static const struct message unicode_test_seq[] = {
344 { TBM_SETUNICODEFORMAT, sent|wparam, TRUE},
345 { TBM_SETUNICODEFORMAT, sent|wparam, FALSE},
346 { TBM_GETUNICODEFORMAT, sent},
350 static const struct message ignore_selection_test_seq[] = {
351 { TBM_SETSEL, sent|wparam|lparam, TRUE, MAKELONG(0,10)},
352 { TBM_GETSELEND, sent},
353 { TBM_GETSELSTART, sent},
354 { TBM_SETSEL, sent|wparam|lparam, FALSE, MAKELONG(0,10)},
355 { TBM_GETSELEND, sent},
356 { TBM_GETSELSTART, sent},
357 { TBM_SETSELEND, sent|wparam|lparam, TRUE,0},
358 { TBM_GETSELEND, sent},
359 { TBM_SETSELEND, sent|wparam|lparam, TRUE, 10},
360 { TBM_GETSELEND, sent},
361 { TBM_SETSELEND, sent|wparam|lparam, FALSE,0},
362 { TBM_GETSELEND, sent},
363 { TBM_SETSELSTART, sent|wparam|lparam, TRUE,0},
364 { TBM_GETSELSTART, sent},
365 { TBM_SETSELSTART, sent|wparam|lparam, TRUE, 10},
366 { TBM_GETSELSTART, sent},
367 { TBM_SETSELSTART, sent|wparam|lparam, FALSE,0},
368 { TBM_GETSELSTART, sent},
372 static LRESULT WINAPI parent_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){
373 static LONG defwndproc_counter = 0;
374 LRESULT ret;
375 struct message msg;
377 /* log system messages, except for painting */
378 if (message < WM_USER &&
379 message != WM_PAINT &&
380 message != WM_ERASEBKGND &&
381 message != WM_NCPAINT &&
382 message != WM_NCHITTEST &&
383 message != WM_GETTEXT &&
384 message != WM_GETICON &&
385 message != WM_DEVICECHANGE)
387 msg.message = message;
388 msg.flags = sent|wparam|lparam;
389 if (defwndproc_counter) msg.flags |= defwinproc;
390 msg.wParam = wParam;
391 msg.lParam = lParam;
392 msg.id = 0;
393 add_message(sequences, PARENT_SEQ_INDEX, &msg);
396 defwndproc_counter++;
397 ret = DefWindowProcA(hwnd, message, wParam, lParam);
398 defwndproc_counter--;
400 return ret;
403 static BOOL register_parent_wnd_class(void){
404 WNDCLASSA cls;
406 cls.style = 0;
407 cls.lpfnWndProc = parent_wnd_proc;
408 cls.cbClsExtra = 0;
409 cls.cbWndExtra = 0;
410 cls.hInstance = GetModuleHandleA(NULL);
411 cls.hIcon = 0;
412 cls.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW);
413 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
414 cls.lpszMenuName = NULL;
415 cls.lpszClassName = "Trackbar test parent class";
416 return RegisterClassA(&cls);
419 static HWND create_parent_window(void){
420 if (!register_parent_wnd_class())
421 return NULL;
423 return CreateWindowA("Trackbar test parent class", "Trackbar test parent window",
424 WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_VISIBLE,
425 0, 0, 100, 100, GetDesktopWindow(), NULL, GetModuleHandleA(NULL), NULL);
428 static LRESULT WINAPI trackbar_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){
429 WNDPROC oldproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_USERDATA);
430 static LONG defwndproc_counter = 0;
431 LRESULT ret;
432 struct message msg;
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 msg.id = 0;
440 add_message(sequences, TRACKBAR_SEQ_INDEX, &msg);
442 defwndproc_counter++;
443 ret = CallWindowProcA(oldproc, hwnd, message, wParam, lParam);
444 defwndproc_counter--;
446 return ret;
449 static HWND create_trackbar(DWORD style, HWND parent){
450 HWND hWndTrack;
451 WNDPROC oldproc;
452 RECT rect;
454 GetClientRect(parent, &rect);
455 hWndTrack = CreateWindowA(TRACKBAR_CLASSA, "Trackbar Control", style,
456 rect.right, rect.bottom, 100, 50,
457 parent, NULL, GetModuleHandleA(NULL), NULL);
459 if (!hWndTrack) return NULL;
461 oldproc = (WNDPROC)SetWindowLongPtrA(hWndTrack, GWLP_WNDPROC, (LONG_PTR)trackbar_subclass_proc);
462 SetWindowLongPtrA(hWndTrack, GWLP_USERDATA, (LONG_PTR)oldproc);
464 return hWndTrack;
467 /* test functions for setters, getters, and sequences */
469 static void test_trackbar_buddy(HWND hWndTrackbar){
470 HWND hWndLeftBuddy;
471 HWND hWndRightBuddy;
472 HWND hWndCurrentBuddy;
473 HWND rTest;
475 flush_sequences(sequences, NUM_MSG_SEQUENCE);
477 hWndLeftBuddy = CreateWindowA(STATUSCLASSNAMEA, NULL, 0, 0, 0, 300, 20, NULL, NULL, NULL, NULL);
478 ok(hWndLeftBuddy != NULL, "Expected non NULL value\n");
480 if (hWndLeftBuddy != NULL){
481 hWndCurrentBuddy = (HWND) SendMessageA(hWndTrackbar, TBM_GETBUDDY, TRUE, 0);
482 rTest = (HWND) SendMessageA(hWndTrackbar, TBM_SETBUDDY, FALSE, (LPARAM) hWndLeftBuddy);
483 ok(rTest == hWndCurrentBuddy, "Expected hWndCurrentBuddy\n");
484 rTest = (HWND) SendMessageA(hWndTrackbar, TBM_SETBUDDY, FALSE, (LPARAM) hWndLeftBuddy);
485 ok(rTest == hWndLeftBuddy, "Expected hWndLeftBuddy\n");
486 } else
487 skip ("left buddy control not present?\n");
489 hWndRightBuddy = CreateWindowA(STATUSCLASSNAMEA, NULL, 0, 0, 0, 300, 20, NULL, NULL, NULL, NULL);
491 ok(hWndRightBuddy != NULL, "expected non NULL value\n");
493 /* test TBM_SETBUDDY */
494 if (hWndRightBuddy != NULL){
495 hWndCurrentBuddy = (HWND) SendMessageA(hWndTrackbar, TBM_GETBUDDY, TRUE, 0);
496 rTest = (HWND) SendMessageA(hWndTrackbar, TBM_SETBUDDY, TRUE, (LPARAM) hWndRightBuddy);
497 ok(rTest == hWndCurrentBuddy, "Expected hWndCurrentBuddy\n");
498 rTest = (HWND) SendMessageA(hWndTrackbar, TBM_SETBUDDY, TRUE, (LPARAM) hWndRightBuddy);
499 ok(rTest == hWndRightBuddy, "Expected hWndRightbuddy\n");
500 } else
501 skip("Right buddy control not present?\n");
503 /* test TBM_GETBUDDY */
504 if (hWndLeftBuddy != NULL){
505 rTest = (HWND) SendMessageA(hWndTrackbar, TBM_GETBUDDY, FALSE, 0);
506 ok(rTest == hWndLeftBuddy, "Expected hWndLeftBuddy\n");
507 DestroyWindow(hWndLeftBuddy);
509 if (hWndRightBuddy != NULL){
510 rTest = (HWND) SendMessageA(hWndTrackbar, TBM_GETBUDDY, TRUE,0);
511 ok(rTest == hWndRightBuddy, "Expected hWndRightBuddy\n");
512 DestroyWindow(hWndRightBuddy);
515 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, buddy_window_test_seq, "buddy test sequence", TRUE);
516 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_buddy_window_test_seq, "parent buddy test seq", TRUE);
520 static void test_line_size(HWND hWndTrackbar){
521 int r;
523 flush_sequences(sequences, NUM_MSG_SEQUENCE);
525 /* test TBM_SETLINESIZE */
526 r = SendMessageA(hWndTrackbar, TBM_SETLINESIZE, 0, 10);
527 expect(1,r);
528 r = SendMessageA(hWndTrackbar, TBM_SETLINESIZE, 0, 4);
529 expect(10, r);
531 /* test TBM_GETLINESIZE */
532 r = SendMessageA(hWndTrackbar, TBM_GETLINESIZE, 0,0);
533 expect(4, r);
535 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, line_size_test_seq, "linesize test sequence", FALSE);
536 ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq, "parent line test sequence", FALSE);
540 static void test_page_size(HWND hWndTrackbar){
541 int r;
543 flush_sequences(sequences, NUM_MSG_SEQUENCE);
545 /* test TBM_SETPAGESIZE */
546 r = SendMessageA(hWndTrackbar, TBM_SETPAGESIZE, 0, 10);
547 expect(20, r);
548 r = SendMessageA(hWndTrackbar, TBM_SETPAGESIZE, 0, -1);
549 expect(10, r);
551 /* test TBM_GETPAGESIZE */
552 r = SendMessageA(hWndTrackbar, TBM_GETPAGESIZE, 0,0);
553 expect(20, r);
555 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, page_size_test_seq, "page size test sequence", FALSE);
556 ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq, "parent page size test sequence", FALSE);
558 /* check for zero page size */
559 r = SendMessageA(hWndTrackbar, TBM_SETPAGESIZE, 0, 0);
560 expect(20, r);
561 r = SendMessageA(hWndTrackbar, TBM_GETPAGESIZE, 0, 0);
562 expect(0, r);
563 /* revert to default */
564 r = SendMessageA(hWndTrackbar, TBM_SETPAGESIZE, 0, -1);
565 expect(0, r);
566 r = SendMessageA(hWndTrackbar, TBM_GETPAGESIZE, 0, 0);
567 expect(20, r);
568 /* < -1 */
569 r = SendMessageA(hWndTrackbar, TBM_SETPAGESIZE, 0, -2);
570 expect(20, r);
571 r = SendMessageA(hWndTrackbar, TBM_GETPAGESIZE, 0, 0);
572 expect(-2, r);
575 static void test_position(HWND hWndTrackbar){
576 int r;
578 flush_sequences(sequences, NUM_MSG_SEQUENCE);
579 /* test TBM_SETPOS */
580 SendMessageA(hWndTrackbar, TBM_SETPOS, TRUE, -1);
581 r = SendMessageA(hWndTrackbar, TBM_GETPOS, 0, 0);
582 expect(0, r);
583 SendMessageA(hWndTrackbar, TBM_SETPOS, TRUE, 5);
584 r = SendMessageA(hWndTrackbar, TBM_GETPOS, 0,0);
585 expect(5, r);
586 SendMessageA(hWndTrackbar, TBM_SETPOS, TRUE, 5);
587 SendMessageA(hWndTrackbar, TBM_SETPOS, TRUE, 1000);
588 r = SendMessageA(hWndTrackbar, TBM_GETPOS, 0,0);
589 expect(100, r);
590 SendMessageA(hWndTrackbar, TBM_SETPOS, FALSE, 20);
591 r = SendMessageA(hWndTrackbar, TBM_GETPOS, 0,0);
592 expect(20, r);
593 SendMessageA(hWndTrackbar, TBM_SETPOS, TRUE, 20);
595 /* test TBM_GETPOS */
596 r = SendMessageA(hWndTrackbar, TBM_GETPOS, 0,0);
597 expect(20, r);
599 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, position_test_seq, "position test sequence", TRUE);
600 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_position_test_seq, "parent position test sequence", TRUE);
603 static void test_range(HWND hWndTrackbar){
604 int r;
606 flush_sequences(sequences, NUM_MSG_SEQUENCE);
607 /* test TBM_SETRANGE */
608 SendMessageA(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(0, 10));
609 r = SendMessageA(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
610 expect(10, r);
611 r = SendMessageA(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
612 expect(0, r);
613 SendMessageA(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(-1, 1000));
614 r = SendMessageA(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
615 expect(1000, r);
616 r = SendMessageA(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
617 expect(-1, r);
618 SendMessageA(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(10, 0));
619 r = SendMessageA(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
620 expect(0, r);
621 r = SendMessageA(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
622 expect(10, r);
623 SendMessageA(hWndTrackbar, TBM_SETRANGE, FALSE, MAKELONG(0,10));
624 r = SendMessageA(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
625 expect(10, r);
626 r = SendMessageA(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
627 expect(0, r);
629 /*test TBM_SETRANGEMAX */
630 SendMessageA(hWndTrackbar, TBM_SETRANGEMAX, TRUE, 10);
631 r = SendMessageA(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
632 expect(10, r);
633 SendMessageA(hWndTrackbar, TBM_SETRANGEMAX, TRUE, -1);
634 r = SendMessageA(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
635 expect(-1, r);
636 SendMessageA(hWndTrackbar, TBM_SETRANGEMAX, FALSE, 10);
637 r = SendMessageA(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
638 expect(10, r);
640 /* testing TBM_SETRANGEMIN */
641 SendMessageA(hWndTrackbar, TBM_SETRANGEMIN, TRUE, 0);
642 r = SendMessageA(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
643 expect(0, r);
644 SendMessageA(hWndTrackbar, TBM_SETRANGEMIN, TRUE, 10);
645 r = SendMessageA(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
646 expect(10, r);
647 SendMessageA(hWndTrackbar, TBM_SETRANGEMIN, TRUE, -10);
648 r = SendMessageA(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
649 expect(-10, r);
650 SendMessageA(hWndTrackbar, TBM_SETRANGEMIN, FALSE, 5);
651 r = SendMessageA(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
652 expect(5, r);
654 /* test TBM_GETRANGEMAX */
655 r = SendMessageA(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
656 expect(10, r);
658 /* test TBM_GETRANGEMIN */
659 r = SendMessageA(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
660 expect(5, r);
662 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, range_test_seq, "range test sequence", TRUE);
663 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_range_test_seq, "parent range test sequence", TRUE);
666 static void test_selection(HWND hWndTrackbar){
667 int r;
669 flush_sequences(sequences, NUM_MSG_SEQUENCE);
670 /* test TBM_SETSEL */
671 SendMessageA(hWndTrackbar, TBM_SETSEL, TRUE, MAKELONG(0,10));
672 r = SendMessageA(hWndTrackbar, TBM_GETSELEND, 0,0);
673 expect(10, r);
674 r = SendMessageA(hWndTrackbar, TBM_GETSELSTART, 0,0);
675 expect(5, r);
676 SendMessageA(hWndTrackbar, TBM_SETSEL, TRUE, MAKELONG(5, 20));
677 r = SendMessageA(hWndTrackbar, TBM_GETSELEND, 0,0);
678 expect(10, r);
679 r = SendMessageA(hWndTrackbar, TBM_GETSELSTART, 0,0);
680 expect(5, r);
681 SendMessageA(hWndTrackbar, TBM_SETSEL, FALSE, MAKELONG(5, 10));
682 r = SendMessageA(hWndTrackbar, TBM_GETSELEND, 0,0);
683 expect(10, r);
684 r = SendMessageA(hWndTrackbar, TBM_GETSELSTART, 0,0);
685 expect(5, r);
687 /* test TBM_SETSELEND */
688 SendMessageA(hWndTrackbar, TBM_SETSELEND, TRUE, 10);
689 r = SendMessageA(hWndTrackbar, TBM_GETSELEND, 0,0);
690 expect(10, r);
691 SendMessageA(hWndTrackbar, TBM_SETSELEND, TRUE, 20);
692 r = SendMessageA(hWndTrackbar, TBM_GETSELEND, 0,0);
693 expect(10, r);
694 SendMessageA(hWndTrackbar, TBM_SETSELEND, TRUE, 4);
695 r = SendMessageA(hWndTrackbar, TBM_GETSELEND, 0,0);
696 expect(4, r);
697 SendMessageA(hWndTrackbar, TBM_SETSELEND, FALSE, 2);
698 r = SendMessageA(hWndTrackbar, TBM_GETSELEND, 0,0);
699 expect(2, r);
701 /* test TBM_GETSELEND */
702 r = SendMessageA(hWndTrackbar, TBM_GETSELEND, 0,0);
703 expect(2, r);
705 /* testing TBM_SETSELSTART */
706 SendMessageA(hWndTrackbar, TBM_SETSELSTART, TRUE, 5);
707 r = SendMessageA(hWndTrackbar, TBM_GETSELSTART, 0,0);
708 expect(5, r);
709 SendMessageA(hWndTrackbar, TBM_SETSELSTART, TRUE, 0);
710 r = SendMessageA(hWndTrackbar, TBM_GETSELSTART, 0,0);
711 expect(5, r);
712 SendMessageA(hWndTrackbar, TBM_SETSELSTART, TRUE, 20);
713 r = SendMessageA(hWndTrackbar, TBM_GETSELSTART, 0,0);
714 expect(20, r);
715 SendMessageA(hWndTrackbar, TBM_SETSELSTART, FALSE, 8);
716 r = SendMessageA(hWndTrackbar, TBM_GETSELSTART, 0,0);
717 expect(8, r);
719 /* test TBM_GETSELSTART */
720 r = SendMessageA(hWndTrackbar, TBM_GETSELSTART, 0,0);
721 expect(8, r);
723 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, selection_test_seq, "selection test sequence", TRUE);
724 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_selection_test_seq, "parent selection test sequence", TRUE);
727 static void test_thumb_length(HWND hWndTrackbar){
728 int r;
730 flush_sequences(sequences, NUM_MSG_SEQUENCE);
731 /* testing TBM_SETTHUMBLENGTH */
732 SendMessageA(hWndTrackbar, TBM_SETTHUMBLENGTH, 15, 0);
733 r = SendMessageA(hWndTrackbar, TBM_GETTHUMBLENGTH, 0,0);
734 expect(15, r);
735 SendMessageA(hWndTrackbar, TBM_SETTHUMBLENGTH, 20, 0);
736 r = SendMessageA(hWndTrackbar, TBM_GETTHUMBLENGTH, 0,0);
737 expect(20, r);
739 /* test TBM_GETTHUMBLENGTH */
740 r = SendMessageA(hWndTrackbar, TBM_GETTHUMBLENGTH, 0,0);
741 expect(20, r);
743 r = SendMessageA(hWndTrackbar, WM_SIZE, 0,0);
744 expect(0, r);
745 r = SendMessageA(hWndTrackbar, TBM_GETTHUMBLENGTH, 0,0);
746 expect(20, r);
747 r = SendMessageA(hWndTrackbar, WM_SIZE, 0, MAKELPARAM(50, 50) );
748 expect(0, r);
749 r = SendMessageA(hWndTrackbar, TBM_GETTHUMBLENGTH, 0,0);
750 expect(20, r);
752 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, thumb_length_test_seq, "thumb length test sequence", TRUE);
753 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_thumb_length_test_seq, "parent thumb length test sequence", TRUE);
756 static void test_tic_settings(HWND hWndTrackbar){
757 int r;
759 /* testing TBM_SETTIC */
760 /* Set tics at 5 and 10 */
761 /* 0 and 20 are out of range and should not be set */
762 r = SendMessageA(hWndTrackbar, TBM_GETRANGEMAX, 0, 0);
763 expect(10, r);
764 r = SendMessageA(hWndTrackbar, TBM_GETRANGEMIN, 0, 0);
765 expect(5, r);
767 flush_sequences(sequences, NUM_MSG_SEQUENCE);
768 r = SendMessageA(hWndTrackbar, TBM_SETTIC, 0, 0);
769 ok(r == FALSE, "Expected FALSE, got %d\n", r);
770 r = SendMessageA(hWndTrackbar, TBM_SETTIC, 0, 5);
771 ok(r == TRUE, "Expected TRUE, got %d\n", r);
772 r = SendMessageA(hWndTrackbar, TBM_SETTIC, 0, 10);
773 ok(r == TRUE, "Expected TRUE, got %d\n", r);
775 r = SendMessageA(hWndTrackbar, TBM_SETTIC, 0, 20);
776 ok(r == FALSE, "Expected FALSE, got %d\n", r);
778 /* test TBM_SETTICFREQ */
779 SendMessageA(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(0, 10));
780 SendMessageA(hWndTrackbar, TBM_SETTICFREQ, 2, 0);
781 r = SendMessageA(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
782 expect(6, r);
783 SendMessageA(hWndTrackbar, TBM_SETTICFREQ, 5, 0);
784 r = SendMessageA(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
785 expect(3, r);
786 SendMessageA(hWndTrackbar, TBM_SETTICFREQ, 15, 0);
787 r = SendMessageA(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
788 expect(2, r);
790 /* test TBM_GETNUMTICS */
791 /* since TIC FREQ is 15, there should be only 2 tics now */
792 r = SendMessageA(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
793 expect(2, r);
795 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, tic_settings_test_seq, "tic settings test sequence", TRUE);
796 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_tic_settings_test_seq, "parent tic settings test sequence", TRUE);
798 /* range [0,0], freq = 1 */
799 SendMessageA(hWndTrackbar, TBM_SETRANGEMAX, TRUE, 0);
800 SendMessageA(hWndTrackbar, TBM_SETRANGEMIN, TRUE, 0);
801 SendMessageA(hWndTrackbar, TBM_SETTICFREQ, 1, 0);
802 r = SendMessageA(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
803 expect(2, r);
804 /* range [0,1], freq = 1 */
805 SendMessageA(hWndTrackbar, TBM_SETRANGEMAX, TRUE, 1);
806 SendMessageA(hWndTrackbar, TBM_SETRANGEMIN, TRUE, 0);
807 SendMessageA(hWndTrackbar, TBM_SETTICFREQ, 1, 0);
808 r = SendMessageA(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
809 expect(2, r);
810 /* range [0,2], freq = 1 */
811 SendMessageA(hWndTrackbar, TBM_SETRANGEMAX, TRUE, 2);
812 SendMessageA(hWndTrackbar, TBM_SETRANGEMIN, TRUE, 0);
813 SendMessageA(hWndTrackbar, TBM_SETTICFREQ, 1, 0);
814 r = SendMessageA(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
815 expect(3, r);
818 static void test_tic_placement(HWND hWndTrackbar){
819 int r;
820 DWORD *rPTics;
821 DWORD numtics;
823 SendMessageA(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(1, 6));
824 SendMessageA(hWndTrackbar, TBM_SETTICFREQ, 1, 0);
826 numtics = SendMessageA(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
827 ok(numtics == 6, "Expected 6, got %d\n", numtics);
829 flush_sequences(sequences, NUM_MSG_SEQUENCE);
830 /* test TBM_GETPTICS */
831 rPTics = (DWORD *) SendMessageA(hWndTrackbar, TBM_GETPTICS, 0,0);
832 expect(2, rPTics[0]);
833 expect(3, rPTics[1]);
834 expect(4, rPTics[2]);
835 expect(5, rPTics[3]);
837 /* test TBM_GETTIC */
838 r = SendMessageA(hWndTrackbar, TBM_GETTIC, 0,0);
839 expect(2, r);
840 r = SendMessageA(hWndTrackbar, TBM_GETTIC, 2,0);
841 expect(4, r);
842 r = SendMessageA(hWndTrackbar, TBM_GETTIC, 4,0);
843 expect(-1, r);
845 /* test TBM_GETTICPIC */
846 r = SendMessageA(hWndTrackbar, TBM_GETTICPOS, 0, 0);
847 ok(r > 0, "Expected r > 0, got %d\n", r);
848 r = SendMessageA(hWndTrackbar, TBM_GETTICPOS, 2, 0);
849 ok(r > 0, "Expected r > 0, got %d\n", r);
851 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, tic_placement_test_seq, "get tic placement test sequence", FALSE);
852 ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq, "parent get tic placement test sequence", FALSE);
856 static void test_tool_tips(HWND hWndTrackbar){
857 int r;
858 HWND hWndTooltip;
859 HWND rTest;
861 flush_sequences(sequences, NUM_MSG_SEQUENCE);
862 /* testing TBM_SETTIPSIDE */
863 r = SendMessageA(hWndTrackbar, TBM_SETTIPSIDE, TBTS_TOP, 0);
864 expect(TBTS_TOP, r);
865 r = SendMessageA(hWndTrackbar, TBM_SETTIPSIDE, TBTS_LEFT, 0);
866 expect(TBTS_TOP, r);
867 r = SendMessageA(hWndTrackbar, TBM_SETTIPSIDE, TBTS_BOTTOM, 0);
868 expect(TBTS_LEFT, r);
869 r = SendMessageA(hWndTrackbar, TBM_SETTIPSIDE, TBTS_RIGHT, 0);
870 expect(TBTS_BOTTOM, r);
872 /* testing TBM_SETTOOLTIPS */
873 hWndTooltip = CreateWindowExA(WS_EX_TOPMOST, TOOLTIPS_CLASSA, NULL, 0,
874 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
875 NULL, NULL, NULL, NULL);
877 ok(hWndTooltip != NULL, "Expected non NULL value\n");
878 if (hWndTooltip != NULL){
879 SendMessageA(hWndTrackbar, TBM_SETTOOLTIPS, (LPARAM) hWndTooltip, 0);
880 rTest = (HWND) SendMessageA(hWndTrackbar, TBM_GETTOOLTIPS, 0,0);
881 ok(rTest == hWndTooltip, "Expected hWndToolTip, got\n");
882 SendMessageA(hWndTrackbar, TBM_SETTOOLTIPS, 0, 0);
883 rTest = (HWND) SendMessageA(hWndTrackbar, TBM_GETTOOLTIPS, 0,0);
884 ok(rTest == NULL, "Expected NULL\n");
885 SendMessageA(hWndTrackbar, TBM_SETTOOLTIPS, (LPARAM) hWndTooltip, 5);
886 rTest = (HWND) SendMessageA(hWndTrackbar, TBM_GETTOOLTIPS, 0,0);
887 ok(rTest == hWndTooltip, "Expected hWndTooltip, got\n");
888 } else
889 skip("tool tip control not present?\n");
891 /* test TBM_GETTOOLTIPS */
892 rTest = (HWND) SendMessageA(hWndTrackbar, TBM_GETTOOLTIPS, 0,0);
893 ok(rTest == hWndTooltip, "Expected hWndTooltip\n");
895 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, tool_tips_test_seq, "tool tips test sequence", FALSE);
896 ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq, "parent tool tips test sequence", FALSE);
900 static void test_unicode(HWND hWndTrackbar){
901 int r;
903 flush_sequences(sequences, NUM_MSG_SEQUENCE);
904 /* testing TBM_SETUNICODEFORMAT */
905 r = SendMessageA(hWndTrackbar, TBM_SETUNICODEFORMAT, TRUE, 0);
906 ok(r == FALSE, "Expected FALSE, got %d\n",r);
907 r = SendMessageA(hWndTrackbar, TBM_SETUNICODEFORMAT, FALSE, 0);
908 ok(r == TRUE, "Expected TRUE, got %d\n",r);
910 /* test TBM_GETUNICODEFORMAT */
911 r = SendMessageA(hWndTrackbar, TBM_GETUNICODEFORMAT, 0,0);
912 ok(r == FALSE, "Expected FALSE, got %d\n",r);
914 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, unicode_test_seq, "unicode test sequence", FALSE);
915 ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq, "parent unicode test sequence", FALSE);
918 static void test_ignore_selection(HWND hWndTrackbar){
919 int r;
921 flush_sequences(sequences, NUM_MSG_SEQUENCE);
922 /* test TBM_SETSEL ensure that it is ignored */
923 SendMessageA(hWndTrackbar, TBM_SETSEL, TRUE, MAKELONG(0,10));
924 r = SendMessageA(hWndTrackbar, TBM_GETSELEND, 0,0);
925 expect(0, r);
926 r = SendMessageA(hWndTrackbar, TBM_GETSELSTART, 0,0);
927 expect(0, r);
928 SendMessageA(hWndTrackbar, TBM_SETSEL, FALSE, MAKELONG(0,10));
929 r = SendMessageA(hWndTrackbar, TBM_GETSELEND, 0,0);
930 expect(0, r);
931 r = SendMessageA(hWndTrackbar, TBM_GETSELSTART, 0,0);
932 expect(0, r);
934 /* test TBM_SETSELEND, ensure that it is ignored */
935 SendMessageA(hWndTrackbar, TBM_SETSELEND, TRUE, 0);
936 r = SendMessageA(hWndTrackbar, TBM_GETSELEND, 0,0);
937 expect(0, r);
938 SendMessageA(hWndTrackbar, TBM_SETSELEND, TRUE, 10);
939 r = SendMessageA(hWndTrackbar, TBM_GETSELEND, 0,0);
940 expect(0,r);
941 SendMessageA(hWndTrackbar, TBM_SETSELEND, FALSE, 0);
942 r = SendMessageA(hWndTrackbar, TBM_GETSELEND, 0,0);
943 expect(0, r);
945 /* test TBM_SETSELSTART, ensure that it is ignored */
946 SendMessageA(hWndTrackbar, TBM_SETSELSTART, TRUE, 0);
947 r = SendMessageA(hWndTrackbar, TBM_GETSELSTART, 0,0);
948 expect(0, r);
949 SendMessageA(hWndTrackbar, TBM_SETSELSTART, TRUE, 10);
950 r = SendMessageA(hWndTrackbar, TBM_GETSELSTART, 0,0);
951 expect(0,r);
952 SendMessageA(hWndTrackbar, TBM_SETSELSTART, FALSE, 0);
953 r = SendMessageA(hWndTrackbar, TBM_GETSELSTART, 0,0);
954 expect(0, r);
956 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, ignore_selection_test_seq, "ignore selection setting test sequence", FALSE);
957 ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq, "parent ignore selection setting test sequence", FALSE);
960 static void test_initial_state(void)
962 HWND hWnd;
963 int ret;
965 hWnd = create_trackbar(0, hWndParent);
967 ret = SendMessageA(hWnd, TBM_GETNUMTICS, 0, 0);
968 expect(2, ret);
969 ret = SendMessageA(hWnd, TBM_GETTIC, 0, 0);
970 expect(-1, ret);
971 ret = SendMessageA(hWnd, TBM_GETTICPOS, 0, 0);
972 expect(-1, ret);
973 ret = SendMessageA(hWnd, TBM_GETRANGEMIN, 0, 0);
974 expect(0, ret);
975 ret = SendMessageA(hWnd, TBM_GETRANGEMAX, 0, 0);
976 expect(100, ret);
978 ret = SendMessageA(hWnd, TBM_SETRANGEMAX, TRUE, 200);
979 expect(0, ret);
981 ret = SendMessageA(hWnd, TBM_GETNUMTICS, 0, 0);
982 expect(2, ret);
984 ret = SendMessageA(hWnd, TBM_SETRANGEMIN, TRUE, 10);
985 expect(0, ret);
987 ret = SendMessageA(hWnd, TBM_GETNUMTICS, 0, 0);
988 expect(2, ret);
990 DestroyWindow(hWnd);
993 static void test_TBS_AUTOTICKS(void)
995 HWND hWnd;
996 int ret;
998 hWnd = create_trackbar(TBS_AUTOTICKS, hWndParent);
1000 ret = SendMessageA(hWnd, TBM_GETNUMTICS, 0, 0);
1001 expect(2, ret);
1002 ret = SendMessageA(hWnd, TBM_GETTIC, 0, 0);
1003 expect(-1, ret);
1004 ret = SendMessageA(hWnd, TBM_GETTICPOS, 0, 0);
1005 expect(-1, ret);
1006 ret = SendMessageA(hWnd, TBM_GETRANGEMIN, 0, 0);
1007 expect(0, ret);
1008 ret = SendMessageA(hWnd, TBM_GETRANGEMAX, 0, 0);
1009 expect(100, ret);
1011 /* TBM_SETRANGEMAX rebuilds tics */
1012 ret = SendMessageA(hWnd, TBM_SETRANGEMAX, TRUE, 200);
1013 expect(0, ret);
1014 ret = SendMessageA(hWnd, TBM_GETNUMTICS, 0, 0);
1015 expect(201, ret);
1017 /* TBM_SETRANGEMIN rebuilds tics */
1018 ret = SendMessageA(hWnd, TBM_SETRANGEMAX, TRUE, 100);
1019 expect(0, ret);
1020 ret = SendMessageA(hWnd, TBM_SETRANGEMIN, TRUE, 10);
1021 expect(0, ret);
1022 ret = SendMessageA(hWnd, TBM_GETNUMTICS, 0, 0);
1023 expect(91, ret);
1025 ret = SendMessageA(hWnd, TBM_SETRANGEMIN, TRUE, 0);
1026 expect(0, ret);
1028 /* TBM_SETRANGE rebuilds tics */
1029 ret = SendMessageA(hWnd, TBM_SETRANGE, TRUE, MAKELONG(10, 200));
1030 expect(0, ret);
1031 ret = SendMessageA(hWnd, TBM_GETNUMTICS, 0, 0);
1032 expect(191, ret);
1034 DestroyWindow(hWnd);
1037 START_TEST(trackbar)
1039 DWORD style = WS_VISIBLE | TBS_TOOLTIPS | TBS_ENABLESELRANGE | TBS_FIXEDLENGTH | TBS_AUTOTICKS;
1040 HWND hWndTrackbar;
1042 init_msg_sequences(sequences, NUM_MSG_SEQUENCE);
1043 InitCommonControls();
1045 /* create parent window */
1046 hWndParent = create_parent_window();
1047 ok(hWndParent != NULL, "Failed to create parent Window!\n");
1049 if(!hWndParent){
1050 skip("parent window not present\n");
1051 return;
1054 flush_sequences(sequences, NUM_MSG_SEQUENCE);
1056 /* create trackbar with set styles */
1057 hWndTrackbar = create_trackbar(style, hWndParent);
1059 ok(hWndTrackbar != NULL, "Expected non NULL value\n");
1061 if (!hWndTrackbar){
1062 skip("trackbar control not present?\n");
1063 return;
1066 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, empty_seq, "create Trackbar Window", FALSE);
1067 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_create_trackbar_wnd_seq, "parent trackbar window", TRUE);
1068 flush_sequences(sequences, NUM_MSG_SEQUENCE);
1070 /* TEST OF ALL SETTER and GETTER MESSAGES with required styles turned on*/
1071 test_trackbar_buddy(hWndTrackbar);
1072 test_line_size(hWndTrackbar);
1073 test_page_size(hWndTrackbar);
1074 test_position(hWndTrackbar);
1075 test_range(hWndTrackbar);
1076 test_selection(hWndTrackbar);
1077 test_thumb_length(hWndTrackbar);
1078 test_tic_settings(hWndTrackbar);
1079 test_tic_placement(hWndTrackbar);
1080 test_tool_tips(hWndTrackbar);
1081 test_unicode(hWndTrackbar);
1082 test_TBS_AUTOTICKS();
1084 flush_sequences(sequences, NUM_MSG_SEQUENCE);
1085 DestroyWindow(hWndTrackbar);
1087 /* test getters and setters without styles set */
1088 hWndTrackbar = create_trackbar(0, hWndParent);
1090 ok(hWndTrackbar != NULL, "Expected non NULL value\n");
1092 if (!hWndTrackbar){
1093 skip("trackbar control not present?\n");
1094 return;
1097 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_new_window_test_seq, "new trackbar window test sequence", TRUE);
1099 test_ignore_selection(hWndTrackbar);
1101 DestroyWindow(hWndTrackbar);
1103 test_initial_state();
1105 DestroyWindow(hWndParent);