1 /* Unit tests for the track bar control.
2 *
3 * Copyright 2007 Keith Stevens
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18 */
19
20 #include <assert.h>
21 #include <windows.h>
22 #include <commctrl.h>
23 #include <stdio.h>
24
25 #include "wine/test.h"
26 #include "msg.h"
27
28 #define expect(expected, got) ok(got == expected, "Expected %d, got %d\n", expected, got)
29 #define NUM_MSG_SEQUENCE 2
30 #define PARENT_SEQ_INDEX 0
31 #define TRACKBAR_SEQ_INDEX 1
32
33
34 static struct msg_sequence *sequences[NUM_MSG_SEQUENCE];
35
36 static const struct message create_parent_wnd_seq[] = {
37 { WM_GETMINMAXINFO, sent },
38 { WM_NCCREATE, sent },
39 { WM_NCCALCSIZE, sent|wparam, 0 },
40 { WM_CREATE, sent },
41 { WM_SHOWWINDOW, sent|wparam, 1 },
42 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
43 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
44 { WM_ACTIVATEAPP, sent|wparam, 1 },
45 { WM_NCACTIVATE, sent|wparam, 1 },
46 { WM_ACTIVATE, sent|wparam, 1 },
47 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
48 { WM_IME_NOTIFY, sent|defwinproc|optional },
49 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
50 /* Win9x adds SWP_NOZORDER below */
51 { WM_WINDOWPOSCHANGED, sent, /*|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE*/ },
52 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
53 { WM_SIZE, sent },
54 { WM_MOVE, sent },
55 { 0 }
56 };
57
58 static const struct message create_trackbar_wnd_seq[] = {
59 {0}
60 };
61
62 static const struct message parent_empty_test_seq[] = {
63 {0}
64 };
65
66 static const struct message parent_create_trackbar_wnd_seq[] = {
67 { WM_NOTIFYFORMAT, sent},
68 { 0x0129, sent}, /* should be WM_QUERYUISTATE instead of 0x0129 */
69 { WM_WINDOWPOSCHANGING, sent},
70 { WM_NCACTIVATE, sent},
71 { PBT_APMRESUMECRITICAL, sent},
72 { WM_WINDOWPOSCHANGING, sent},
73 { PBT_APMRESUMESTANDBY, sent},
74 { WM_IME_SETCONTEXT, sent|optional},
75 { WM_IME_NOTIFY, sent|optional},
76 { WM_CTLCOLORSTATIC, sent},
77 { WM_NOTIFY, sent},
78 {0}
79 };
80
81 static const struct message parent_new_window_test_seq[] = {
82 { WM_WINDOWPOSCHANGING, sent},
83 { WM_NCACTIVATE, sent},
84 { PBT_APMRESUMECRITICAL, sent},
85 { WM_IME_SETCONTEXT, sent|defwinproc|optional},
86 { WM_IME_NOTIFY, sent|defwinproc|optional},
87 { WM_SETFOCUS, sent|defwinproc},
88 { WM_NOTIFYFORMAT, sent},
89 { 0x0129, sent}, /* should be WM_QUERYUISTATE instead of 0x0129*/
90 {0}
91 };
92
93 static const struct message buddy_window_test_seq[] = {
94 { TBM_GETBUDDY, sent|wparam, TRUE},
95 { TBM_SETBUDDY, sent|wparam, FALSE},
96 { WM_PAINT, sent|defwinproc},
97 { TBM_SETBUDDY, sent|wparam, FALSE},
98 { WM_PAINT, sent|defwinproc},
99 { TBM_GETBUDDY, sent|wparam, TRUE},
100 { TBM_SETBUDDY, sent|wparam, TRUE},
101 { WM_PAINT, sent|defwinproc},
102 { TBM_SETBUDDY, sent|wparam, TRUE},
103 { WM_PAINT, sent|defwinproc},
104 { TBM_GETBUDDY, sent|wparam, FALSE},
105 { TBM_GETBUDDY, sent|wparam, TRUE},
106 {0}
107 };
108
109 static const struct message parent_buddy_window_test_seq[] = {
110 { WM_CTLCOLORSTATIC, sent},
111 { WM_NOTIFY, sent},
112 { WM_CTLCOLORSTATIC, sent},
113 { WM_NOTIFY, sent},
114 { WM_CTLCOLORSTATIC, sent},
115 { WM_NOTIFY, sent},
116 { WM_CTLCOLORSTATIC, sent},
117 { WM_NOTIFY, sent},
118 {0}
119 };
120
121 static const struct message line_size_test_seq[] = {
122 { TBM_SETLINESIZE, sent|lparam, 0, 10},
123 { TBM_SETLINESIZE, sent|lparam, 0, 4},
124 { TBM_GETLINESIZE, sent},
125 {0}
126 };
127
128 static const struct message page_size_test_seq[] = {
129 { TBM_SETPAGESIZE, sent|lparam, 0, 10},
130 { TBM_SETPAGESIZE, sent|lparam, 0, -1},
131 { TBM_GETPAGESIZE, sent},
132 {0}
133 };
134
135 static const struct message position_test_seq[] = {
136 { TBM_SETPOS, sent|wparam|lparam, TRUE, -1},
137 { WM_PAINT, sent|defwinproc},
138 { TBM_GETPOS, sent},
139 { TBM_SETPOS, sent|wparam|lparam, TRUE, 5},
140 { WM_PAINT, sent|defwinproc},
141 { TBM_GETPOS, sent},
142 { TBM_SETPOS, sent|wparam|lparam, TRUE, 1000},
143 { WM_PAINT, sent|defwinproc},
144 { TBM_GETPOS, sent},
145 { TBM_SETPOS, sent|wparam|lparam, FALSE, 20},
146 { TBM_GETPOS, sent},
147 { TBM_GETPOS, sent},
148 {0}
149 };
150
151 static const struct message parent_position_test_seq[] = {
152 { WM_CTLCOLORSTATIC, sent},
153 { WM_NOTIFY, sent},
154 { WM_CTLCOLORSTATIC, sent},
155 { WM_NOTIFY, sent},
156 { WM_CTLCOLORSTATIC, sent},
157 { WM_NOTIFY, sent},
158 {0}
159 };
160
161 static const struct message range_test_seq[] = {
162 { TBM_SETRANGE, sent|wparam|lparam, TRUE, MAKELONG(0, 10)},
163 { WM_PAINT, sent|defwinproc},
164 { TBM_GETRANGEMAX, sent},
165 { TBM_GETRANGEMIN, sent},
166 { TBM_SETRANGE, sent|wparam|lparam, TRUE, MAKELONG(-1, 1000)},
167 { WM_PAINT, sent|defwinproc},
168 { TBM_GETRANGEMAX, sent},
169 { TBM_GETRANGEMIN, sent},
170 { TBM_SETRANGE, sent|wparam|lparam, TRUE, MAKELONG(10, 0)},
171 { WM_PAINT, sent|defwinproc},
172 { TBM_GETRANGEMAX, sent},
173 { TBM_GETRANGEMIN, sent},
174 { TBM_SETRANGE, sent|wparam|lparam, FALSE, MAKELONG(0, 10)},
175 { TBM_GETRANGEMAX, sent},
176 { TBM_GETRANGEMIN, sent},
177 { TBM_SETRANGEMAX, sent|wparam|lparam, TRUE, 10},
178 { WM_PAINT, sent|defwinproc},
179 { TBM_GETRANGEMAX, sent},
180 { TBM_SETRANGEMAX, sent|wparam|lparam, TRUE, -1},
181 { WM_PAINT, sent|defwinproc},
182 { TBM_GETRANGEMAX, sent},
183 { TBM_SETRANGEMAX, sent|wparam|lparam, FALSE, 10},
184 { TBM_GETRANGEMAX, sent},
185 { TBM_SETRANGEMIN, sent|wparam|lparam, TRUE, 0},
186 { WM_PAINT, sent|defwinproc},
187 { TBM_GETRANGEMIN, sent},
188 { TBM_SETRANGEMIN, sent|wparam|lparam, TRUE, 10},
189 { WM_PAINT, sent|defwinproc},
190 { TBM_GETRANGEMIN, sent},
191 { TBM_SETRANGEMIN, sent|wparam|lparam, TRUE, -10},
192 { WM_PAINT, sent|defwinproc},
193 { TBM_GETRANGEMIN, sent},
194 { TBM_SETRANGEMIN, sent|wparam|lparam, FALSE, 5},
195 { TBM_GETRANGEMIN, sent},
196 { TBM_GETRANGEMAX, sent},
197 { TBM_GETRANGEMIN, sent},
198 {0}
199 };
200
201 static const struct message parent_range_test_seq[] = {
202 { WM_CTLCOLORSTATIC, sent},
203 { WM_NOTIFY, sent},
204 { WM_CTLCOLORSTATIC, sent},
205 { WM_NOTIFY, sent},
206 { WM_CTLCOLORSTATIC, sent},
207 { WM_NOTIFY, sent},
208 { WM_CTLCOLORSTATIC, sent},
209 { WM_NOTIFY, sent},
210 { WM_CTLCOLORSTATIC, sent},
211 { WM_NOTIFY, sent},
212 { WM_CTLCOLORSTATIC, sent},
213 { WM_NOTIFY, sent},
214 { WM_CTLCOLORSTATIC, sent},
215 { WM_NOTIFY, sent},
216 { WM_CTLCOLORSTATIC, sent},
217 { WM_NOTIFY, sent},
218 {0}
219 };
220
221 static const struct message selection_test_seq[] = {
222 { TBM_SETSEL, sent|wparam|lparam, TRUE, MAKELONG(0, 10)},
223 { WM_PAINT, sent|defwinproc},
224 { TBM_GETSELEND, sent},
225 { TBM_GETSELSTART, sent},
226 { TBM_SETSEL, sent|wparam|lparam, TRUE, MAKELONG(5, 20)},
227 { WM_PAINT, sent|defwinproc},
228 { TBM_GETSELEND, sent},
229 { TBM_GETSELSTART, sent},
230 { TBM_SETSEL, sent|wparam|lparam, FALSE, MAKELONG(5, 10)},
231 { TBM_GETSELEND, sent},
232 { TBM_GETSELSTART, sent},
233 { TBM_SETSELEND, sent|wparam|lparam, TRUE, 10},
234 { WM_PAINT, sent|defwinproc},
235 { TBM_GETSELEND, sent},
236 { TBM_SETSELEND, sent|wparam|lparam, TRUE, 20},
237 { WM_PAINT, sent|defwinproc},
238 { TBM_GETSELEND, sent},
239 { TBM_SETSELEND, sent|wparam|lparam, TRUE, 4},
240 { WM_PAINT, sent|defwinproc},
241 { TBM_GETSELEND, sent},
242 { TBM_SETSELEND, sent|wparam|lparam, FALSE, 2},
243 { TBM_GETSELEND, sent},
244 { TBM_GETSELEND, sent},
245 { TBM_SETSELSTART, sent|wparam|lparam, TRUE, 5},
246 { WM_PAINT, sent|defwinproc},
247 { TBM_GETSELSTART, sent},
248 { TBM_SETSELSTART, sent|wparam|lparam, TRUE, 0},
249 { WM_PAINT, sent|defwinproc},
250 { TBM_GETSELSTART, sent},
251 { TBM_SETSELSTART, sent|wparam|lparam, TRUE, 20},
252 { WM_PAINT, sent|defwinproc},
253 { TBM_GETSELSTART, sent},
254 { TBM_SETSELSTART, sent|wparam|lparam, FALSE, 8},
255 { TBM_GETSELSTART, sent},
256 { TBM_GETSELSTART, sent},
257 {0}
258 };
259
260 static const struct message parent_selection_test_seq[] = {
261 { WM_CTLCOLORSTATIC, sent},
262 { WM_NOTIFY, sent},
263 { WM_CTLCOLORSTATIC, sent},
264 { WM_NOTIFY, sent},
265 { WM_CTLCOLORSTATIC, sent},
266 { WM_NOTIFY, sent},
267 { WM_CTLCOLORSTATIC, sent},
268 { WM_NOTIFY, sent},
269 { WM_CTLCOLORSTATIC, sent},
270 { WM_NOTIFY, sent},
271 { WM_CTLCOLORSTATIC, sent},
272 { WM_NOTIFY, sent},
273 { WM_CTLCOLORSTATIC, sent},
274 { WM_NOTIFY, sent},
275 { WM_CTLCOLORSTATIC, sent},
276 { WM_NOTIFY, sent},
277 {0}
278 };
279
280 static const struct message tic_settings_test_seq[] = {
281 { TBM_SETTIC, sent|lparam, 0, 0},
282 { TBM_SETTIC, sent|lparam, 0, 5},
283 { TBM_SETTIC, sent|lparam, 0, 10},
284 { TBM_SETTIC, sent|lparam, 0, 20},
285 { TBM_SETRANGE, sent|wparam|lparam, TRUE, MAKELONG(0,10)},
286 { WM_PAINT, sent|defwinproc},
287 { TBM_SETTICFREQ, sent|wparam, 2},
288 { WM_PAINT, sent|defwinproc},
289 { TBM_GETNUMTICS, sent},
290 { TBM_SETTICFREQ, sent|wparam, 5},
291 { WM_PAINT, sent|defwinproc},
292 { TBM_GETNUMTICS, sent},
293 { TBM_SETTICFREQ, sent|wparam, 15},
294 { WM_PAINT, sent|defwinproc},
295 { TBM_GETNUMTICS, sent},
296 { TBM_GETNUMTICS, sent},
297 {0}
298 };
299
300 static const struct message parent_tic_settings_test_seq[] = {
301 { WM_CTLCOLORSTATIC, sent},
302 { WM_NOTIFY, sent},
303 { WM_CTLCOLORSTATIC, sent},
304 { WM_NOTIFY, sent},
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 thumb_length_test_seq[] = {
313 { TBM_SETTHUMBLENGTH, sent|wparam|lparam, 15, 0},
314 { WM_PAINT, sent|defwinproc},
315 { TBM_GETTHUMBLENGTH, sent},
316 { TBM_SETTHUMBLENGTH, sent|wparam|lparam, 20, 0},
317 { WM_PAINT, sent|defwinproc},
318 { TBM_GETTHUMBLENGTH, sent},
319 { TBM_GETTHUMBLENGTH, sent},
320 {0}
321 };
322
323 static const struct message parent_thumb_length_test_seq[] = {
324 { WM_CTLCOLORSTATIC, sent},
325 { WM_NOTIFY, sent},
326 { WM_CTLCOLORSTATIC, sent},
327 { WM_NOTIFY, sent},
328 {0}
329 };
330
331 static const struct message tic_placement_test_seq[] = {
332 { TBM_GETPTICS, sent},
333 { TBM_GETTIC, sent|wparam, 0},
334 { TBM_GETTIC, sent|wparam, 2},
335 { TBM_GETTIC, sent|wparam, 4},
336 { TBM_GETTICPOS, sent|wparam, 0},
337 { TBM_GETTICPOS, sent|wparam, 2},
338 {0}
339 };
340
341 static const struct message tool_tips_test_seq[] = {
342 { TBM_SETTIPSIDE, sent|wparam, TBTS_TOP},
343 { TBM_SETTIPSIDE, sent|wparam, TBTS_LEFT},
344 { TBM_SETTIPSIDE, sent|wparam, TBTS_BOTTOM},
345 { TBM_SETTIPSIDE, sent|wparam, TBTS_RIGHT},
346 { TBM_SETTOOLTIPS, sent},
347 { TBM_GETTOOLTIPS, sent},
348 { TBM_SETTOOLTIPS, sent},
349 { TBM_GETTOOLTIPS, sent},
350 { TBM_SETTOOLTIPS, sent},
351 { TBM_GETTOOLTIPS, sent},
352 { TBM_GETTOOLTIPS, sent},
353 {0}
354 };
355
356 static const struct message unicode_test_seq[] = {
357 { TBM_SETUNICODEFORMAT, sent|wparam, TRUE},
358 { TBM_SETUNICODEFORMAT, sent|wparam, FALSE},
359 { TBM_GETUNICODEFORMAT, sent},
360 {0}
361 };
362
363 static const struct message ignore_selection_test_seq[] = {
364 { TBM_SETSEL, sent|wparam|lparam, TRUE, MAKELONG(0,10)},
365 { TBM_GETSELEND, sent},
366 { TBM_GETSELSTART, sent},
367 { TBM_SETSEL, sent|wparam|lparam, FALSE, MAKELONG(0,10)},
368 { TBM_GETSELEND, sent},
369 { TBM_GETSELSTART, sent},
370 { TBM_SETSELEND, sent|wparam|lparam, TRUE,0},
371 { TBM_GETSELEND, sent},
372 { TBM_SETSELEND, sent|wparam|lparam, TRUE, 10},
373 { TBM_GETSELEND, sent},
374 { TBM_SETSELEND, sent|wparam|lparam, FALSE,0},
375 { TBM_GETSELEND, sent},
376 { TBM_SETSELSTART, sent|wparam|lparam, TRUE,0},
377 { TBM_GETSELSTART, sent},
378 { TBM_SETSELSTART, sent|wparam|lparam, TRUE, 10},
379 { TBM_GETSELSTART, sent},
380 { TBM_SETSELSTART, sent|wparam|lparam, FALSE,0},
381 { TBM_GETSELSTART, sent},
382 {0}
383 };
384
385 struct subclass_info
386 {
387 WNDPROC oldproc;
388 };
389
390 static LRESULT WINAPI parent_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){
391 static long defwndproc_counter = 0;
392 LRESULT ret;
393 struct message msg;
394
395 /* do not log painting messages */
396 if (message != WM_PAINT &&
397 message != WM_ERASEBKGND &&
398 message != WM_NCPAINT &&
399 message != WM_NCHITTEST &&
400 message != WM_GETTEXT &&
401 message != WM_GETICON &&
402 message != WM_DEVICECHANGE)
403 {
404 msg.message = message;
405 msg.flags = sent|wparam|lparam;
406 if (defwndproc_counter) msg.flags |= defwinproc;
407 msg.wParam = wParam;
408 msg.lParam = lParam;
409 add_message(sequences, PARENT_SEQ_INDEX, &msg);
410 }
411
412 defwndproc_counter++;
413 ret = DefWindowProcA(hwnd, message, wParam, lParam);
414 defwndproc_counter--;
415
416 return ret;
417 }
418
419 static BOOL register_parent_wnd_class(void){
420 WNDCLASSA cls;
421
422 cls.style = 0;
423 cls.lpfnWndProc = parent_wnd_proc;
424 cls.cbClsExtra = 0;
425 cls.cbWndExtra = 0;
426 cls.hInstance = GetModuleHandleA(NULL);
427 cls.hIcon = 0;
428 cls.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW);
429 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
430 cls.lpszMenuName = NULL;
431 cls.lpszClassName = "Trackbar test parent class";
432 return RegisterClassA(&cls);
433 }
434
435 static HWND create_parent_window(void){
436 if (!register_parent_wnd_class())
437 return NULL;
438
439 return CreateWindowEx(0, "Trackbar test parent class",
440 "Trackbar test parent window",
441 WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX |
442 WS_MAXIMIZEBOX | WS_VISIBLE,
443 0, 0, 100, 100,
444 GetDesktopWindow(), NULL, GetModuleHandleA(NULL), NULL);
445 }
446
447 static LRESULT WINAPI trackbar_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){
448 struct subclass_info *info = (struct subclass_info *) GetWindowLongPtrA(hwnd, GWLP_USERDATA);
449 static long defwndproc_counter = 0;
450 LRESULT ret;
451 struct message msg;
452
453 msg.message = message;
454 msg.flags = sent|wparam|lparam;
455 if (defwndproc_counter) msg.flags |= defwinproc;
456 msg.wParam = wParam;
457 msg.lParam = lParam;
458 add_message(sequences, TRACKBAR_SEQ_INDEX, &msg);
459
460 defwndproc_counter++;
461 ret = CallWindowProcA(info->oldproc, hwnd, message, wParam, lParam);
462 defwndproc_counter--;
463
464 return ret;
465 }
466
467 static HWND create_trackbar(DWORD style, HWND parent){
468 struct subclass_info *info;
469 HWND hWndTrack;
470 RECT rect;
471
472 info = HeapAlloc(GetProcessHeap(), 0, sizeof(struct subclass_info));
473 if (!info)
474 return NULL;
475
476 GetClientRect(parent, &rect);
477 hWndTrack = CreateWindowEx(
478 0, TRACKBAR_CLASS,"Trackbar Control", style,
479 rect.right,rect.bottom, 100, 50,
480 parent, NULL,GetModuleHandleA(NULL) ,NULL);
481
482 if (!hWndTrack)
483 {
484 HeapFree(GetProcessHeap(), 0, info);
485 return NULL;
486 }
487
488 info->oldproc = (WNDPROC)SetWindowLongPtrA(hWndTrack, GWLP_WNDPROC, (LONG_PTR)trackbar_subclass_proc);
489
490 SetWindowLongPtrA(hWndTrack, GWLP_USERDATA, (LONG_PTR)info);
491
492 return hWndTrack;
493 }
494
495 /* test functions for setters, getters, and sequences */
496
497 static void test_trackbar_buddy(HWND hWndTrackbar){
498 HWND hWndLeftBuddy;
499 HWND hWndRightBuddy;
500 HWND hWndCurrentBuddy;
501 HWND rTest;
502
503 flush_sequences(sequences, NUM_MSG_SEQUENCE);
504
505 hWndLeftBuddy = (HWND) CreateWindowEx(0, STATUSCLASSNAME, NULL, 0,
506 0,0,300,20, NULL, NULL, NULL, NULL);
507 ok(hWndLeftBuddy != NULL, "Expected non NULL value\n");
508
509 if (hWndLeftBuddy != NULL){
510 hWndCurrentBuddy = (HWND) SendMessage(hWndTrackbar, TBM_GETBUDDY, TRUE, 0);
511 rTest = (HWND) SendMessage(hWndTrackbar, TBM_SETBUDDY, FALSE, (LPARAM) hWndLeftBuddy);
512 ok(rTest == hWndCurrentBuddy, "Expected hWndCurrentBuddy\n");
513 rTest = (HWND) SendMessage(hWndTrackbar, TBM_SETBUDDY, FALSE, (LPARAM) hWndLeftBuddy);
514 ok(rTest == hWndLeftBuddy, "Expected hWndLeftBuddy\n");
515 } else
516 skip ("left buddy control not present?\n");
517
518 hWndRightBuddy = (HWND) CreateWindowEx(0, STATUSCLASSNAME, NULL, 0,
519 0,0,300,20,NULL,NULL, NULL, NULL);
520
521 ok(hWndRightBuddy != NULL, "expected non NULL value\n");
522
523 /* test TBM_SETBUDDY */
524 if (hWndRightBuddy != NULL){
525 hWndCurrentBuddy = (HWND) SendMessage(hWndTrackbar, TBM_GETBUDDY, TRUE, 0);
526 rTest = (HWND) SendMessage(hWndTrackbar, TBM_SETBUDDY, TRUE, (LPARAM) hWndRightBuddy);
527 ok(rTest == hWndCurrentBuddy, "Expected hWndCurrentBuddy\n");
528 rTest = (HWND) SendMessage(hWndTrackbar, TBM_SETBUDDY, TRUE, (LPARAM) hWndRightBuddy);
529 ok(rTest == hWndRightBuddy, "Expected hWndRightbuddy\n");
530 } else
531 skip("Right buddy control not present?\n");
532
533 /* test TBM_GETBUDDY */
534 if (hWndLeftBuddy != NULL){
535 rTest = (HWND) SendMessage(hWndTrackbar, TBM_GETBUDDY, FALSE, 0);
536 ok(rTest == hWndLeftBuddy, "Expected hWndLeftBuddy\n");
537 DestroyWindow(hWndLeftBuddy);
538 }
539 if (hWndRightBuddy != NULL){
540 rTest = (HWND) SendMessage(hWndTrackbar, TBM_GETBUDDY, TRUE,0);
541 ok(rTest == hWndRightBuddy, "Expected hWndRightBuddy\n");
542 DestroyWindow(hWndRightBuddy);
543 }
544
545 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, buddy_window_test_seq, "buddy test sequence", TRUE);
546 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_buddy_window_test_seq, "parent buddy test seq", TRUE);
547
548 }
549
550 static void test_line_size(HWND hWndTrackbar){
551 int r;
552
553 flush_sequences(sequences, NUM_MSG_SEQUENCE);
554
555 /* test TBM_SETLINESIZE */
556 r = SendMessage(hWndTrackbar, TBM_SETLINESIZE, 0, 10);
557 r = SendMessage(hWndTrackbar, TBM_SETLINESIZE, 0, 4);
558 expect(10, r);
559
560 /* test TBM_GETLINESIZE */
561 r = SendMessage(hWndTrackbar, TBM_GETLINESIZE, 0,0);
562 expect(4, r);
563
564 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, line_size_test_seq, "linesize test sequence", FALSE);
565 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_empty_test_seq, "parent line test sequence", FALSE);
566 }
567
568
569 static void test_page_size(HWND hWndTrackbar){
570 int r;
571
572 flush_sequences(sequences, NUM_MSG_SEQUENCE);
573
574 /* test TBM_SETPAGESIZE */
575 r = SendMessage(hWndTrackbar, TBM_SETPAGESIZE, 0, 10);
576 expect(20, r);
577 r = SendMessage(hWndTrackbar, TBM_SETPAGESIZE, 0, -1);
578 expect(10, r);
579
580 /* test TBM_GETPAGESIZE */
581 r = SendMessage(hWndTrackbar, TBM_GETPAGESIZE, 0,0);
582 todo_wine{
583 expect(20, r);
584 }
585
586 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, page_size_test_seq, "page size test sequence", FALSE);
587 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_empty_test_seq, "parent page size test sequence", FALSE);
588 }
589
590 static void test_position(HWND hWndTrackbar){
591 int r;
592
593 flush_sequences(sequences, NUM_MSG_SEQUENCE);
594 /* test TBM_SETPOS */
595 SendMessage(hWndTrackbar, TBM_SETPOS, TRUE, -1);
596 r = SendMessage(hWndTrackbar, TBM_GETPOS, 0, 0);
597 expect(0, r);
598 SendMessage(hWndTrackbar, TBM_SETPOS, TRUE, 5);
599 r = SendMessage(hWndTrackbar, TBM_GETPOS, 0,0);
600 expect(5, r);
601 SendMessage(hWndTrackbar, TBM_SETPOS, TRUE, 1000);
602 r = SendMessage(hWndTrackbar, TBM_GETPOS, 0,0);
603 expect(100, r);
604 SendMessage(hWndTrackbar, TBM_SETPOS, FALSE, 20);
605 r = SendMessage(hWndTrackbar, TBM_GETPOS, 0,0);
606 expect(20, r);
607
608 /* test TBM_GETPOS */
609 r = SendMessage(hWndTrackbar, TBM_GETPOS, 0,0);
610 expect(20, r);
611
612 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, position_test_seq, "position test sequence", TRUE);
613 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_position_test_seq, "parent position test sequence", TRUE);
614 }
615
616 static void test_range(HWND hWndTrackbar){
617 int r;
618
619 flush_sequences(sequences, NUM_MSG_SEQUENCE);
620 /* test TBM_SETRANGE */
621 SendMessage(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(0, 10));
622 r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
623 expect(10, r);
624 r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
625 expect(0, r);
626 SendMessage(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(-1, 1000));
627 r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
628 expect(1000, r);
629 r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
630 expect(-1, r);
631 SendMessage(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(10, 0));
632 r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
633 expect(0, r);
634 r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
635 expect(10, r);
636 SendMessage(hWndTrackbar, TBM_SETRANGE, FALSE, MAKELONG(0,10));
637 r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
638 expect(10, r);
639 r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
640 expect(0, r);
641
642 /*test TBM_SETRANGEMAX */
643 SendMessage(hWndTrackbar, TBM_SETRANGEMAX, TRUE, 10);
644 r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
645 expect(10, r);
646 SendMessage(hWndTrackbar, TBM_SETRANGEMAX, TRUE, -1);
647 r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
648 expect(-1, r);
649 SendMessage(hWndTrackbar, TBM_SETRANGEMAX, FALSE, 10);
650 r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
651 expect(10, r);
652
653 /* testing TBM_SETRANGEMIN */
654 SendMessage(hWndTrackbar, TBM_SETRANGEMIN, TRUE, 0);
655 r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
656 expect(0, r);
657 SendMessage(hWndTrackbar, TBM_SETRANGEMIN, TRUE, 10);
658 r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
659 expect(10, r);
660 SendMessage(hWndTrackbar, TBM_SETRANGEMIN, TRUE, -10);
661 r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
662 expect(-10, r);
663 SendMessage(hWndTrackbar, TBM_SETRANGEMIN, FALSE, 5);
664 r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
665 expect(5, r);
666
667 /* test TBM_GETRANGEMAX */
668 r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
669 expect(10, r);
670
671 /* test TBM_GETRANGEMIN */
672 r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
673 expect(5, r);
674
675 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, range_test_seq, "range test sequence", TRUE);
676 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_range_test_seq, "parent range test sequence", TRUE);
677 }
678
679 static void test_selection(HWND hWndTrackbar){
680 int r;
681
682 flush_sequences(sequences, NUM_MSG_SEQUENCE);
683 /* test TBM_SETSEL */
684 SendMessage(hWndTrackbar, TBM_SETSEL, TRUE, MAKELONG(0,10));
685 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
686 expect(10, r);
687 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
688 expect(5, r);
689 SendMessage(hWndTrackbar, TBM_SETSEL, TRUE, MAKELONG(5, 20));
690 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
691 expect(10, r);
692 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
693 expect(5, r);
694 SendMessage(hWndTrackbar, TBM_SETSEL, FALSE, MAKELONG(5, 10));
695 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
696 expect(10, r);
697 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
698 expect(5, r);
699
700 /* test TBM_SETSELEND */
701 SendMessage(hWndTrackbar, TBM_SETSELEND, TRUE, 10);
702 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
703 expect(10, r);
704 SendMessage(hWndTrackbar, TBM_SETSELEND, TRUE, 20);
705 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
706 expect(10, r);
707 SendMessage(hWndTrackbar, TBM_SETSELEND, TRUE, 4);
708 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
709 expect(4, r);
710 SendMessage(hWndTrackbar, TBM_SETSELEND, FALSE, 2);
711 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
712 expect(2, r);
713
714 /* test TBM_GETSELEND */
715 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
716 expect(2, r);
717
718 /* testing TBM_SETSELSTART */
719 SendMessage(hWndTrackbar, TBM_SETSELSTART, TRUE, 5);
720 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
721 expect(5, r);
722 SendMessage(hWndTrackbar, TBM_SETSELSTART, TRUE, 0);
723 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
724 expect(5, r);
725 SendMessage(hWndTrackbar, TBM_SETSELSTART, TRUE, 20);
726 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
727 expect(20, r);
728 SendMessage(hWndTrackbar, TBM_SETSELSTART, FALSE, 8);
729 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
730 expect(8, r);
731
732 /* test TBM_GETSELSTART */
733 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
734 expect(8, r);
735
736 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, selection_test_seq, "selection test sequence", TRUE);
737 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_selection_test_seq, "parent selection test seqence", TRUE);
738 }
739
740 static void test_thumb_length(HWND hWndTrackbar){
741 int r;
742
743 flush_sequences(sequences, NUM_MSG_SEQUENCE);
744 /* testing TBM_SETTHUMBLENGTH */
745 SendMessage(hWndTrackbar, TBM_SETTHUMBLENGTH, 15, 0);
746 r = SendMessage(hWndTrackbar, TBM_GETTHUMBLENGTH, 0,0);
747 expect(15, r);
748 SendMessage(hWndTrackbar, TBM_SETTHUMBLENGTH, 20, 0);
749 r = SendMessage(hWndTrackbar, TBM_GETTHUMBLENGTH, 0,0);
750 expect(20, r);
751
752 /* test TBM_GETTHUMBLENGTH */
753 r = SendMessage(hWndTrackbar, TBM_GETTHUMBLENGTH, 0,0);
754 expect(20, r);
755
756 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, thumb_length_test_seq, "thumb length test sequence", TRUE);
757 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_thumb_length_test_seq, "parent thumb lenth test sequence", TRUE);
758 }
759
760 static void test_tic_settings(HWND hWndTrackbar){
761 int r;
762
763 flush_sequences(sequences, NUM_MSG_SEQUENCE);
764 /* testing TBM_SETTIC */
765 /* Set tics at 5 and 10 */
766 /* 0 and 20 are out of range and should not be set */
767 r = SendMessage(hWndTrackbar, TBM_SETTIC, 0, 0);
768 ok(r == FALSE, "Expected FALSE, got %d\n", r);
769 r = SendMessage(hWndTrackbar, TBM_SETTIC, 0, 5);
770 todo_wine{
771 ok(