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