1 /* Unit tests for the track bar control.
3 * Copyright 2007 Keith Stevens
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 #include "wine/test.h"
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
34 static struct msg_sequence *sequences[NUM_MSG_SEQUENCE];
36 static const struct message create_parent_wnd_seq[] = {
37 { WM_GETMINMAXINFO, sent },
38 { WM_NCCREATE, sent },
39 { WM_NCCALCSIZE, sent|wparam, 0 },
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 },
58 static const struct message create_trackbar_wnd_seq[] = {
62 static const struct message parent_empty_test_seq[] = {
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},
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*/
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},
109 static const struct message parent_buddy_window_test_seq[] = {
110 { WM_CTLCOLORSTATIC, sent},
112 { WM_CTLCOLORSTATIC, sent},
114 { WM_CTLCOLORSTATIC, sent},
116 { WM_CTLCOLORSTATIC, sent},
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},
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},
135 static const struct message position_test_seq[] = {
136 { TBM_SETPOS, sent|wparam|lparam, TRUE, -1},
137 { WM_PAINT, sent|defwinproc},
139 { TBM_SETPOS, sent|wparam|lparam, TRUE, 5},
140 { WM_PAINT, sent|defwinproc},
142 { TBM_SETPOS, sent|wparam|lparam, TRUE, 1000},
143 { WM_PAINT, sent|defwinproc},
145 { TBM_SETPOS, sent|wparam|lparam, FALSE, 20},
151 static const struct message parent_position_test_seq[] = {
152 { WM_CTLCOLORSTATIC, sent},
154 { WM_CTLCOLORSTATIC, sent},
156 { WM_CTLCOLORSTATIC, sent},
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},
201 static const struct message parent_range_test_seq[] = {
202 { WM_CTLCOLORSTATIC, sent},
204 { WM_CTLCOLORSTATIC, sent},
206 { WM_CTLCOLORSTATIC, sent},
208 { WM_CTLCOLORSTATIC, sent},
210 { WM_CTLCOLORSTATIC, sent},
212 { WM_CTLCOLORSTATIC, sent},
214 { WM_CTLCOLORSTATIC, sent},
216 { WM_CTLCOLORSTATIC, sent},
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},
260 static const struct message parent_selection_test_seq[] = {
261 { WM_CTLCOLORSTATIC, sent},
263 { WM_CTLCOLORSTATIC, sent},
265 { WM_CTLCOLORSTATIC, sent},
267 { WM_CTLCOLORSTATIC, sent},
269 { WM_CTLCOLORSTATIC, sent},
271 { WM_CTLCOLORSTATIC, sent},
273 { WM_CTLCOLORSTATIC, sent},
275 { WM_CTLCOLORSTATIC, sent},
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},
300 static const struct message parent_tic_settings_test_seq[] = {
301 { WM_CTLCOLORSTATIC, sent},
303 { WM_CTLCOLORSTATIC, sent},
305 { WM_CTLCOLORSTATIC, sent},
307 { WM_CTLCOLORSTATIC, sent},
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},
323 static const struct message parent_thumb_length_test_seq[] = {
324 { WM_CTLCOLORSTATIC, sent},
326 { WM_CTLCOLORSTATIC, sent},
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},
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},
356 static const struct message unicode_test_seq[] = {
357 { TBM_SETUNICODEFORMAT, sent|wparam, TRUE},
358 { TBM_SETUNICODEFORMAT, sent|wparam, FALSE},
359 { TBM_GETUNICODEFORMAT, sent},
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},
390 static LRESULT WINAPI parent_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){
391 static long defwndproc_counter = 0;
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)
404 msg.message = message;
405 msg.flags = sent|wparam|lparam;
406 if (defwndproc_counter) msg.flags |= defwinproc;
409 add_message(sequences, PARENT_SEQ_INDEX, &msg);
412 defwndproc_counter++;
413 ret = DefWindowProcA(hwnd, message, wParam, lParam);
414 defwndproc_counter--;
419 static BOOL register_parent_wnd_class(void){
423 cls.lpfnWndProc = parent_wnd_proc;
426 cls.hInstance = GetModuleHandleA(NULL);
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);
435 static HWND create_parent_window(void){
436 if (!register_parent_wnd_class())
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,
444 GetDesktopWindow(), NULL, GetModuleHandleA(NULL), NULL);
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;
453 msg.message = message;
454 msg.flags = sent|wparam|lparam;
455 if (defwndproc_counter) msg.flags |= defwinproc;
458 add_message(sequences, TRACKBAR_SEQ_INDEX, &msg);
460 defwndproc_counter++;
461 ret = CallWindowProcA(info->oldproc, hwnd, message, wParam, lParam);
462 defwndproc_counter--;
467 static HWND create_trackbar(DWORD style, HWND parent){
468 struct subclass_info *info;
472 info = HeapAlloc(GetProcessHeap(), 0, sizeof(struct subclass_info));
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);
484 HeapFree(GetProcessHeap(), 0, info);
488 info->oldproc = (WNDPROC)SetWindowLongPtrA(hWndTrack, GWLP_WNDPROC, (LONG_PTR)trackbar_subclass_proc);
490 SetWindowLongPtrA(hWndTrack, GWLP_USERDATA, (LONG_PTR)info);
495 /* test functions for setters, getters, and sequences */
497 static void test_trackbar_buddy(HWND hWndTrackbar){
500 HWND hWndCurrentBuddy;
503 flush_sequences(sequences, NUM_MSG_SEQUENCE);
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");
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");
516 skip ("left buddy control not present?\n");
518 hWndRightBuddy = (HWND) CreateWindowEx(0, STATUSCLASSNAME, NULL, 0,
519 0,0,300,20,NULL,NULL, NULL, NULL);
521 ok(hWndRightBuddy != NULL, "expected non NULL value\n");
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");
531 skip("Right buddy control not present?\n");
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);
539 if (hWndRightBuddy != NULL){
540 rTest = (HWND) SendMessage(hWndTrackbar, TBM_GETBUDDY, TRUE,0);
541 ok(rTest == hWndRightBuddy, "Expected hWndRightBuddy\n");
542 DestroyWindow(hWndRightBuddy);
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);
550 static void test_line_size(HWND hWndTrackbar){
553 flush_sequences(sequences, NUM_MSG_SEQUENCE);
555 /* test TBM_SETLINESIZE */
556 r = SendMessage(hWndTrackbar, TBM_SETLINESIZE, 0, 10);
557 r = SendMessage(hWndTrackbar, TBM_SETLINESIZE, 0, 4);
560 /* test TBM_GETLINESIZE */
561 r = SendMessage(hWndTrackbar, TBM_GETLINESIZE, 0,0);
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);
569 static void test_page_size(HWND hWndTrackbar){
572 flush_sequences(sequences, NUM_MSG_SEQUENCE);
574 /* test TBM_SETPAGESIZE */
575 r = SendMessage(hWndTrackbar, TBM_SETPAGESIZE, 0, 10);
577 r = SendMessage(hWndTrackbar, TBM_SETPAGESIZE, 0, -1);
580 /* test TBM_GETPAGESIZE */
581 r = SendMessage(hWndTrackbar, TBM_GETPAGESIZE, 0,0);
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);
590 static void test_position(HWND hWndTrackbar){
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);
598 SendMessage(hWndTrackbar, TBM_SETPOS, TRUE, 5);
599 r = SendMessage(hWndTrackbar, TBM_GETPOS, 0,0);
601 SendMessage(hWndTrackbar, TBM_SETPOS, TRUE, 1000);
602 r = SendMessage(hWndTrackbar, TBM_GETPOS, 0,0);
604 SendMessage(hWndTrackbar, TBM_SETPOS, FALSE, 20);
605 r = SendMessage(hWndTrackbar, TBM_GETPOS, 0,0);
608 /* test TBM_GETPOS */
609 r = SendMessage(hWndTrackbar, TBM_GETPOS, 0,0);
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);
616 static void test_range(HWND hWndTrackbar){
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);
624 r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
626 SendMessage(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(-1, 1000));
627 r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
629 r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
631 SendMessage(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(10, 0));
632 r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
634 r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
636 SendMessage(hWndTrackbar, TBM_SETRANGE, FALSE, MAKELONG(0,10));
637 r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
639 r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
642 /*test TBM_SETRANGEMAX */
643 SendMessage(hWndTrackbar, TBM_SETRANGEMAX, TRUE, 10);
644 r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
646 SendMessage(hWndTrackbar, TBM_SETRANGEMAX, TRUE, -1);
647 r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
649 SendMessage(hWndTrackbar, TBM_SETRANGEMAX, FALSE, 10);
650 r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
653 /* testing TBM_SETRANGEMIN */
654 SendMessage(hWndTrackbar, TBM_SETRANGEMIN, TRUE, 0);
655 r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
657 SendMessage(hWndTrackbar, TBM_SETRANGEMIN, TRUE, 10);
658 r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
660 SendMessage(hWndTrackbar, TBM_SETRANGEMIN, TRUE, -10);
661 r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
663 SendMessage(hWndTrackbar, TBM_SETRANGEMIN, FALSE, 5);
664 r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
667 /* test TBM_GETRANGEMAX */
668 r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
671 /* test TBM_GETRANGEMIN */
672 r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
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);
679 static void test_selection(HWND hWndTrackbar){
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);
687 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
689 SendMessage(hWndTrackbar, TBM_SETSEL, TRUE, MAKELONG(5, 20));
690 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
692 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
694 SendMessage(hWndTrackbar, TBM_SETSEL, FALSE, MAKELONG(5, 10));
695 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
697 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
700 /* test TBM_SETSELEND */
701 SendMessage(hWndTrackbar, TBM_SETSELEND, TRUE, 10);
702 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
704 SendMessage(hWndTrackbar, TBM_SETSELEND, TRUE, 20);
705 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
707 SendMessage(hWndTrackbar, TBM_SETSELEND, TRUE, 4);
708 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
710 SendMessage(hWndTrackbar, TBM_SETSELEND, FALSE, 2);
711 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
714 /* test TBM_GETSELEND */
715 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
718 /* testing TBM_SETSELSTART */
719 SendMessage(hWndTrackbar, TBM_SETSELSTART, TRUE, 5);
720 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
722 SendMessage(hWndTrackbar, TBM_SETSELSTART, TRUE, 0);
723 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
725 SendMessage(hWndTrackbar, TBM_SETSELSTART, TRUE, 20);
726 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
728 SendMessage(hWndTrackbar, TBM_SETSELSTART, FALSE, 8);
729 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
732 /* test TBM_GETSELSTART */
733 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
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);
740 static void test_thumb_length(HWND hWndTrackbar){
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);
748 SendMessage(hWndTrackbar, TBM_SETTHUMBLENGTH, 20, 0);
749 r = SendMessage(hWndTrackbar, TBM_GETTHUMBLENGTH, 0,0);
752 /* test TBM_GETTHUMBLENGTH */
753 r = SendMessage(hWndTrackbar, TBM_GETTHUMBLENGTH, 0,0);
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);
760 static void test_tic_settings(HWND hWndTrackbar){
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);
771 ok(r == TRUE, "Expected TRUE, got %d\n", r);
772 r = SendMessage(hWndTrackbar, TBM_SETTIC, 0, 10);
773 ok(r == TRUE, "Expected TRUE, got %d\n", r);
775 r = SendMessage(hWndTrackbar, TBM_SETTIC, 0, 20);
776 ok(r == FALSE, "Expected False, got %d\n", r);
778 /* test TBM_SETTICFREQ */
779 SendMessage(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(0, 10));
780 SendMessage(hWndTrackbar, TBM_SETTICFREQ, 2, 0);
781 r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0,0);
783 SendMessage(hWndTrackbar, TBM_SETTICFREQ, 5, 0);
784 r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0,0);
786 SendMessage(hWndTrackbar, TBM_SETTICFREQ, 15, 0);
787 r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0,0);
790 /* test TBM_GETNUMTICS */
791 /* since TIC FREQ is 15, there should be only 2 tics now */
792 r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0,0);
795 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, tic_settings_test_seq, "tic settings test sequence", TRUE);
796 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_tic_settings_test_seq, "parent tic settings test sequence", TRUE);
799 static void test_tic_placement(HWND hWndTrackbar){
804 SendMessage(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(1, 6));
805 SendMessage(hWndTrackbar, TBM_SETTICFREQ, 1, 0);
807 numtics = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
808 ok(numtics == 6, "Expected 6, got %d\n", numtics);
810 flush_sequences(sequences, NUM_MSG_SEQUENCE);
811 /* test TBM_GETPTICS */
812 rPTics = (DWORD *) SendMessage(hWndTrackbar, TBM_GETPTICS, 0,0);
813 expect(2, rPTics[0]);
814 expect(3, rPTics[1]);
815 expect(4, rPTics[2]);
816 expect(5, rPTics[3]);
818 /* test TBM_GETTIC */
819 r = SendMessage(hWndTrackbar, TBM_GETTIC, 0,0);
821 r = SendMessage(hWndTrackbar, TBM_GETTIC, 2,0);
823 r = SendMessage(hWndTrackbar, TBM_GETTIC, 4,0);
828 /* test TBM_GETTICPIC */
829 r = SendMessage(hWndTrackbar, TBM_GETTICPOS, 0, 0);
830 ok(r > 0, "Expected r > 0, got %d\n", r);
831 r = SendMessage(hWndTrackbar, TBM_GETTICPOS, 2, 0);
832 ok(r > 0, "Expected r > 0, got %d\n", r);
834 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, tic_placement_test_seq, "get tic placement test sequence", FALSE);
835 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_empty_test_seq, "parent get tic placement test sequence", FALSE);
839 static void test_tool_tips(HWND hWndTrackbar){
844 flush_sequences(sequences, NUM_MSG_SEQUENCE);
845 /* testing TBM_SETTIPSIDE */
846 r = SendMessage(hWndTrackbar, TBM_SETTIPSIDE, TBTS_TOP, 0);
850 r = SendMessage(hWndTrackbar, TBM_SETTIPSIDE, TBTS_LEFT, 0);
852 r = SendMessage(hWndTrackbar, TBM_SETTIPSIDE, TBTS_BOTTOM, 0);
854 r = SendMessage(hWndTrackbar, TBM_SETTIPSIDE, TBTS_RIGHT, 0);
857 /* testing TBM_SETTOOLTIPS */
858 hWndTooltip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, 0,
859 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
860 NULL, NULL, NULL, NULL);
862 ok(hWndTooltip != NULL, "Expected non NULL value\n");
863 if (hWndTooltip != NULL){
864 SendMessage(hWndTrackbar, TBM_SETTOOLTIPS, (LPARAM) hWndTooltip, 0);
865 rTest = (HWND) SendMessage(hWndTrackbar, TBM_GETTOOLTIPS, 0,0);
866 ok(rTest == hWndTooltip, "Expected hWndToolTip, got\n");
867 SendMessage(hWndTrackbar, TBM_SETTOOLTIPS, (LPARAM) NULL, 0);
868 rTest = (HWND) SendMessage(hWndTrackbar, TBM_GETTOOLTIPS, 0,0);
869 ok(rTest == NULL, "Expected NULL\n");
870 SendMessage(hWndTrackbar, TBM_SETTOOLTIPS, (LPARAM) hWndTooltip, 5);
871 rTest = (HWND) SendMessage(hWndTrackbar, TBM_GETTOOLTIPS, 0,0);
872 ok(rTest == hWndTooltip, "Expected hWndTooltip, got\n");
874 skip("tool tip control not present?\n");
876 /* test TBM_GETTOOLTIPS */
877 rTest = (HWND) SendMessage(hWndTrackbar, TBM_GETTOOLTIPS, 0,0);
878 ok(rTest == hWndTooltip, "Expected hWndTooltip\n");
880 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, tool_tips_test_seq, "tool tips test sequence", FALSE);
881 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_empty_test_seq, "parent tool tips test sequence", FALSE);
885 static void test_unicode(HWND hWndTrackbar){
888 flush_sequences(sequences, NUM_MSG_SEQUENCE);
889 /* testing TBM_SETUNICODEFORMAT */
890 r = SendMessage(hWndTrackbar, TBM_SETUNICODEFORMAT, TRUE, 0);
891 ok(r == FALSE, "Expected FALSE, got %d\n",r);
892 r = SendMessage(hWndTrackbar, TBM_SETUNICODEFORMAT, FALSE, 0);
893 ok(r == TRUE, "Expected TRUE, got %d\n",r);
895 /* test TBM_GETUNICODEFORMAT */
896 r = SendMessage(hWndTrackbar, TBM_GETUNICODEFORMAT, 0,0);
897 ok(r == FALSE, "Expected FALSE, got %d\n",r);
899 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, unicode_test_seq, "unicode test sequence", FALSE);
900 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_empty_test_seq, "parent unicode test sequence", FALSE);
903 static void test_ignore_selection(HWND hWndTrackbar){
906 flush_sequences(sequences, NUM_MSG_SEQUENCE);
907 /* test TBM_SETSEL ensure that it is ignored */
908 SendMessage(hWndTrackbar, TBM_SETSEL, TRUE, MAKELONG(0,10));
909 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
911 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
913 SendMessage(hWndTrackbar, TBM_SETSEL, FALSE, MAKELONG(0,10));
914 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
916 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
919 /* test TBM_SETSELEND, ensure that it is ignored */
920 SendMessage(hWndTrackbar, TBM_SETSELEND, TRUE, 0);
921 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
923 SendMessage(hWndTrackbar, TBM_SETSELEND, TRUE, 10);
924 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
926 SendMessage(hWndTrackbar, TBM_SETSELEND, FALSE, 0);
927 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
930 /* test TBM_SETSELSTART, ensure that it is ignored */
931 SendMessage(hWndTrackbar, TBM_SETSELSTART, TRUE, 0);
932 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
934 SendMessage(hWndTrackbar, TBM_SETSELSTART, TRUE, 10);
935 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
937 SendMessage(hWndTrackbar, TBM_SETSELSTART, FALSE, 0);
938 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
941 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, ignore_selection_test_seq, "ignore selection setting test sequence", FALSE);
942 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_empty_test_seq, "parent ignore selection setting test sequence", FALSE);
947 DWORD style = WS_VISIBLE | TBS_TOOLTIPS | TBS_ENABLESELRANGE | TBS_FIXEDLENGTH | TBS_AUTOTICKS;
951 init_msg_sequences(sequences, NUM_MSG_SEQUENCE);
952 InitCommonControls();
954 flush_sequences(sequences, NUM_MSG_SEQUENCE);
956 /* create parent window */
957 hWndParent = create_parent_window();
958 ok(hWndParent != NULL, "Failed to create parent Window!\n");
961 skip("parent window not present\n");
965 ok_sequence(sequences, PARENT_SEQ_INDEX, create_parent_wnd_seq, "create Parent Window", TRUE);
966 flush_sequences(sequences, NUM_MSG_SEQUENCE);
968 /* create trackbar with set styles */
969 hWndTrackbar = create_trackbar(style, hWndParent);
971 ok(hWndTrackbar != NULL, "Expected non NULL value\n");
974 skip("trackbar control not present?\n");
978 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, create_trackbar_wnd_seq, "create Trackbar Window", FALSE);
979 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_create_trackbar_wnd_seq, "parent trackbar window", TRUE);
980 flush_sequences(sequences, NUM_MSG_SEQUENCE);
982 /* TEST OF ALL SETTER and GETTER MESSAGES with required styles turned on*/
983 test_trackbar_buddy(hWndTrackbar);
984 test_line_size(hWndTrackbar);
985 test_page_size(hWndTrackbar);
986 test_position(hWndTrackbar);
987 test_range(hWndTrackbar);
988 test_selection(hWndTrackbar);
989 test_thumb_length(hWndTrackbar);
990 test_tic_settings(hWndTrackbar);
991 test_tic_placement(hWndTrackbar);
992 test_tool_tips(hWndTrackbar);
993 test_unicode(hWndTrackbar);
995 flush_sequences(sequences, NUM_MSG_SEQUENCE);
996 DestroyWindow(hWndTrackbar);
998 /* test getters and setters without styles set */
999 hWndTrackbar = create_trackbar(0, hWndParent);
1001 ok(hWndTrackbar != NULL, "Expected non NULL value\n");
1004 skip("trackbar control not present?\n");
1008 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_new_window_test_seq, "new trackbar window test sequence", TRUE);
1010 test_ignore_selection(hWndTrackbar);
1012 DestroyWindow(hWndTrackbar);
1014 DestroyWindow(hWndParent);