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