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
33 static HWND hWndParent;
35 static struct msg_sequence *sequences[NUM_MSG_SEQUENCE];
37 static const struct message create_trackbar_wnd_seq[] = {
41 static const struct message parent_empty_test_seq[] = {
45 static const struct message parent_create_trackbar_wnd_seq[] = {
46 { WM_NOTIFYFORMAT, sent},
47 { WM_QUERYUISTATE, sent|optional},
48 { WM_WINDOWPOSCHANGING, sent},
49 { WM_NCACTIVATE, sent},
50 { PBT_APMRESUMECRITICAL, sent},
51 { WM_WINDOWPOSCHANGING, sent},
52 { PBT_APMRESUMESTANDBY, sent},
53 { WM_IME_SETCONTEXT, sent|optional},
54 { WM_IME_NOTIFY, sent|optional},
55 { WM_CTLCOLORSTATIC, sent},
60 static const struct message parent_new_window_test_seq[] = {
61 { WM_QUERYNEWPALETTE, sent|optional },
62 { WM_WINDOWPOSCHANGING, sent|optional},
63 { WM_NCACTIVATE, sent|optional},
64 { PBT_APMRESUMECRITICAL, sent|optional},
65 { WM_IME_SETCONTEXT, sent|defwinproc|optional},
66 { WM_IME_NOTIFY, sent|defwinproc|optional},
67 { WM_SETFOCUS, sent|defwinproc|optional},
68 { WM_NOTIFYFORMAT, sent},
69 { WM_QUERYUISTATE, sent|optional},
73 static const struct message buddy_window_test_seq[] = {
74 { TBM_GETBUDDY, sent|wparam, TRUE},
75 { TBM_SETBUDDY, sent|wparam, FALSE},
76 { WM_PAINT, sent|defwinproc},
77 { TBM_SETBUDDY, sent|wparam, FALSE},
78 { WM_PAINT, sent|defwinproc},
79 { TBM_GETBUDDY, sent|wparam, TRUE},
80 { TBM_SETBUDDY, sent|wparam, TRUE},
81 { WM_PAINT, sent|defwinproc},
82 { TBM_SETBUDDY, sent|wparam, TRUE},
83 { WM_PAINT, sent|defwinproc},
84 { TBM_GETBUDDY, sent|wparam, FALSE},
85 { TBM_GETBUDDY, sent|wparam, TRUE},
89 static const struct message parent_buddy_window_test_seq[] = {
90 { WM_CTLCOLORSTATIC, sent},
92 { WM_CTLCOLORSTATIC, sent},
94 { WM_CTLCOLORSTATIC, sent},
96 { WM_CTLCOLORSTATIC, sent},
101 static const struct message line_size_test_seq[] = {
102 { TBM_SETLINESIZE, sent|lparam, 0, 10},
103 { TBM_SETLINESIZE, sent|lparam, 0, 4},
104 { TBM_GETLINESIZE, sent},
108 static const struct message page_size_test_seq[] = {
109 { TBM_SETPAGESIZE, sent|lparam, 0, 10},
110 { TBM_SETPAGESIZE, sent|lparam, 0, -1},
111 { TBM_GETPAGESIZE, sent},
115 static const struct message position_test_seq[] = {
116 { TBM_SETPOS, sent|wparam|lparam, TRUE, -1},
117 { WM_PAINT, sent|defwinproc},
119 { TBM_SETPOS, sent|wparam|lparam, TRUE, 5},
120 { WM_PAINT, sent|defwinproc},
122 { TBM_SETPOS, sent|wparam|lparam, TRUE, 5},
123 { TBM_SETPOS, sent|wparam|lparam, TRUE, 1000},
124 { WM_PAINT, sent|defwinproc},
126 { TBM_SETPOS, sent|wparam|lparam, FALSE, 20},
128 { TBM_SETPOS, sent|wparam|lparam, TRUE, 20},
133 static const struct message parent_position_test_seq[] = {
134 { WM_CTLCOLORSTATIC, sent},
136 { WM_CTLCOLORSTATIC, sent},
138 { WM_CTLCOLORSTATIC, sent},
143 static const struct message range_test_seq[] = {
144 { TBM_SETRANGE, sent|wparam|lparam, TRUE, MAKELONG(0, 10)},
145 { WM_PAINT, sent|defwinproc},
146 { TBM_GETRANGEMAX, sent},
147 { TBM_GETRANGEMIN, sent},
148 { TBM_SETRANGE, sent|wparam|lparam, TRUE, MAKELONG(-1, 1000)},
149 { WM_PAINT, sent|defwinproc},
150 { TBM_GETRANGEMAX, sent},
151 { TBM_GETRANGEMIN, sent},
152 { TBM_SETRANGE, sent|wparam|lparam, TRUE, MAKELONG(10, 0)},
153 { WM_PAINT, sent|defwinproc},
154 { TBM_GETRANGEMAX, sent},
155 { TBM_GETRANGEMIN, sent},
156 { TBM_SETRANGE, sent|wparam|lparam, FALSE, MAKELONG(0, 10)},
157 { TBM_GETRANGEMAX, sent},
158 { TBM_GETRANGEMIN, sent},
159 { TBM_SETRANGEMAX, sent|wparam|lparam, TRUE, 10},
160 { WM_PAINT, sent|defwinproc},
161 { TBM_GETRANGEMAX, sent},
162 { TBM_SETRANGEMAX, sent|wparam|lparam, TRUE, -1},
163 { WM_PAINT, sent|defwinproc},
164 { TBM_GETRANGEMAX, sent},
165 { TBM_SETRANGEMAX, sent|wparam|lparam, FALSE, 10},
166 { TBM_GETRANGEMAX, sent},
167 { TBM_SETRANGEMIN, sent|wparam|lparam, TRUE, 0},
168 { WM_PAINT, sent|defwinproc},
169 { TBM_GETRANGEMIN, sent},
170 { TBM_SETRANGEMIN, sent|wparam|lparam, TRUE, 10},
171 { WM_PAINT, sent|defwinproc},
172 { TBM_GETRANGEMIN, sent},
173 { TBM_SETRANGEMIN, sent|wparam|lparam, TRUE, -10},
174 { WM_PAINT, sent|defwinproc},
175 { TBM_GETRANGEMIN, sent},
176 { TBM_SETRANGEMIN, sent|wparam|lparam, FALSE, 5},
177 { TBM_GETRANGEMIN, sent},
178 { TBM_GETRANGEMAX, sent},
179 { TBM_GETRANGEMIN, sent},
183 static const struct message parent_range_test_seq[] = {
184 { WM_CTLCOLORSTATIC, sent},
186 { WM_CTLCOLORSTATIC, sent},
188 { WM_CTLCOLORSTATIC, sent},
190 { WM_CTLCOLORSTATIC, sent},
192 { WM_CTLCOLORSTATIC, sent},
194 { WM_CTLCOLORSTATIC, sent},
196 { WM_CTLCOLORSTATIC, sent},
198 { WM_CTLCOLORSTATIC, sent},
203 static const struct message selection_test_seq[] = {
204 { TBM_SETSEL, sent|wparam|lparam, TRUE, MAKELONG(0, 10)},
205 { WM_PAINT, sent|defwinproc},
206 { TBM_GETSELEND, sent},
207 { TBM_GETSELSTART, sent},
208 { TBM_SETSEL, sent|wparam|lparam, TRUE, MAKELONG(5, 20)},
209 { WM_PAINT, sent|defwinproc},
210 { TBM_GETSELEND, sent},
211 { TBM_GETSELSTART, sent},
212 { TBM_SETSEL, sent|wparam|lparam, FALSE, MAKELONG(5, 10)},
213 { TBM_GETSELEND, sent},
214 { TBM_GETSELSTART, sent},
215 { TBM_SETSELEND, sent|wparam|lparam, TRUE, 10},
216 { WM_PAINT, sent|defwinproc},
217 { TBM_GETSELEND, sent},
218 { TBM_SETSELEND, sent|wparam|lparam, TRUE, 20},
219 { WM_PAINT, sent|defwinproc},
220 { TBM_GETSELEND, sent},
221 { TBM_SETSELEND, sent|wparam|lparam, TRUE, 4},
222 { WM_PAINT, sent|defwinproc},
223 { TBM_GETSELEND, sent},
224 { TBM_SETSELEND, sent|wparam|lparam, FALSE, 2},
225 { TBM_GETSELEND, sent},
226 { TBM_GETSELEND, sent},
227 { TBM_SETSELSTART, sent|wparam|lparam, TRUE, 5},
228 { WM_PAINT, sent|defwinproc},
229 { TBM_GETSELSTART, sent},
230 { TBM_SETSELSTART, sent|wparam|lparam, TRUE, 0},
231 { WM_PAINT, sent|defwinproc},
232 { TBM_GETSELSTART, sent},
233 { TBM_SETSELSTART, sent|wparam|lparam, TRUE, 20},
234 { WM_PAINT, sent|defwinproc},
235 { TBM_GETSELSTART, sent},
236 { TBM_SETSELSTART, sent|wparam|lparam, FALSE, 8},
237 { TBM_GETSELSTART, sent},
238 { TBM_GETSELSTART, sent},
242 static const struct message parent_selection_test_seq[] = {
243 { WM_CTLCOLORSTATIC, sent},
245 { WM_CTLCOLORSTATIC, sent},
247 { WM_CTLCOLORSTATIC, sent},
249 { WM_CTLCOLORSTATIC, sent},
251 { WM_CTLCOLORSTATIC, sent},
253 { WM_CTLCOLORSTATIC, sent},
255 { WM_CTLCOLORSTATIC, sent},
257 { WM_CTLCOLORSTATIC, sent},
262 static const struct message tic_settings_test_seq[] = {
263 { TBM_SETTIC, sent|lparam, 0, 0},
264 { TBM_SETTIC, sent|lparam, 0, 5},
265 { TBM_SETTIC, sent|lparam, 0, 10},
266 { TBM_SETTIC, sent|lparam, 0, 20},
267 { TBM_SETRANGE, sent|wparam|lparam, TRUE, MAKELONG(0,10)},
268 { WM_PAINT, sent|defwinproc},
269 { TBM_SETTICFREQ, sent|wparam, 2},
270 { WM_PAINT, sent|defwinproc},
271 { TBM_GETNUMTICS, sent},
272 { TBM_SETTICFREQ, sent|wparam, 5},
273 { WM_PAINT, sent|defwinproc},
274 { TBM_GETNUMTICS, sent},
275 { TBM_SETTICFREQ, sent|wparam, 15},
276 { WM_PAINT, sent|defwinproc},
277 { TBM_GETNUMTICS, sent},
278 { TBM_GETNUMTICS, sent},
282 static const struct message parent_tic_settings_test_seq[] = {
283 { WM_CTLCOLORSTATIC, sent},
285 { WM_CTLCOLORSTATIC, sent},
287 { WM_CTLCOLORSTATIC, sent},
289 { WM_CTLCOLORSTATIC, sent},
294 static const struct message thumb_length_test_seq[] = {
295 { TBM_SETTHUMBLENGTH, sent|wparam|lparam, 15, 0},
296 { WM_PAINT, sent|defwinproc},
297 { TBM_GETTHUMBLENGTH, sent},
298 { TBM_SETTHUMBLENGTH, sent|wparam|lparam, 20, 0},
299 { WM_PAINT, sent|defwinproc},
300 { TBM_GETTHUMBLENGTH, sent},
301 { TBM_GETTHUMBLENGTH, sent},
305 static const struct message parent_thumb_length_test_seq[] = {
306 { WM_CTLCOLORSTATIC, sent},
308 { WM_CTLCOLORSTATIC, sent},
313 static const struct message tic_placement_test_seq[] = {
314 { TBM_GETPTICS, sent},
315 { TBM_GETTIC, sent|wparam, 0},
316 { TBM_GETTIC, sent|wparam, 2},
317 { TBM_GETTIC, sent|wparam, 4},
318 { TBM_GETTICPOS, sent|wparam, 0},
319 { TBM_GETTICPOS, sent|wparam, 2},
323 static const struct message tool_tips_test_seq[] = {
324 { TBM_SETTIPSIDE, sent|wparam, TBTS_TOP},
325 { TBM_SETTIPSIDE, sent|wparam, TBTS_LEFT},
326 { TBM_SETTIPSIDE, sent|wparam, TBTS_BOTTOM},
327 { TBM_SETTIPSIDE, sent|wparam, TBTS_RIGHT},
328 { TBM_SETTOOLTIPS, sent},
329 { TBM_GETTOOLTIPS, sent},
330 { TBM_SETTOOLTIPS, sent},
331 { TBM_GETTOOLTIPS, sent},
332 { TBM_SETTOOLTIPS, sent},
333 { TBM_GETTOOLTIPS, sent},
334 { TBM_GETTOOLTIPS, sent},
338 static const struct message unicode_test_seq[] = {
339 { TBM_SETUNICODEFORMAT, sent|wparam, TRUE},
340 { TBM_SETUNICODEFORMAT, sent|wparam, FALSE},
341 { TBM_GETUNICODEFORMAT, sent},
345 static const struct message ignore_selection_test_seq[] = {
346 { TBM_SETSEL, sent|wparam|lparam, TRUE, MAKELONG(0,10)},
347 { TBM_GETSELEND, sent},
348 { TBM_GETSELSTART, sent},
349 { TBM_SETSEL, sent|wparam|lparam, FALSE, MAKELONG(0,10)},
350 { TBM_GETSELEND, sent},
351 { TBM_GETSELSTART, sent},
352 { TBM_SETSELEND, sent|wparam|lparam, TRUE,0},
353 { TBM_GETSELEND, sent},
354 { TBM_SETSELEND, sent|wparam|lparam, TRUE, 10},
355 { TBM_GETSELEND, sent},
356 { TBM_SETSELEND, sent|wparam|lparam, FALSE,0},
357 { TBM_GETSELEND, sent},
358 { TBM_SETSELSTART, sent|wparam|lparam, TRUE,0},
359 { TBM_GETSELSTART, sent},
360 { TBM_SETSELSTART, sent|wparam|lparam, TRUE, 10},
361 { TBM_GETSELSTART, sent},
362 { TBM_SETSELSTART, sent|wparam|lparam, FALSE,0},
363 { TBM_GETSELSTART, sent},
367 static LRESULT WINAPI parent_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){
368 static LONG defwndproc_counter = 0;
372 /* log system messages, except for painting */
373 if (message < WM_USER &&
374 message != WM_PAINT &&
375 message != WM_ERASEBKGND &&
376 message != WM_NCPAINT &&
377 message != WM_NCHITTEST &&
378 message != WM_GETTEXT &&
379 message != WM_GETICON &&
380 message != WM_DEVICECHANGE)
382 trace("parent: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
384 msg.message = message;
385 msg.flags = sent|wparam|lparam;
386 if (defwndproc_counter) msg.flags |= defwinproc;
389 add_message(sequences, PARENT_SEQ_INDEX, &msg);
392 defwndproc_counter++;
393 ret = DefWindowProcA(hwnd, message, wParam, lParam);
394 defwndproc_counter--;
399 static BOOL register_parent_wnd_class(void){
403 cls.lpfnWndProc = parent_wnd_proc;
406 cls.hInstance = GetModuleHandleA(NULL);
408 cls.hCursor = LoadCursorA(0, IDC_ARROW);
409 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
410 cls.lpszMenuName = NULL;
411 cls.lpszClassName = "Trackbar test parent class";
412 return RegisterClassA(&cls);
415 static HWND create_parent_window(void){
416 if (!register_parent_wnd_class())
419 return CreateWindowEx(0, "Trackbar test parent class",
420 "Trackbar test parent window",
421 WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX |
422 WS_MAXIMIZEBOX | WS_VISIBLE,
424 GetDesktopWindow(), NULL, GetModuleHandleA(NULL), NULL);
427 static LRESULT WINAPI trackbar_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){
428 WNDPROC oldproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_USERDATA);
429 static LONG defwndproc_counter = 0;
433 trace("trackbar: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
435 msg.message = message;
436 msg.flags = sent|wparam|lparam;
437 if (defwndproc_counter) msg.flags |= defwinproc;
440 add_message(sequences, TRACKBAR_SEQ_INDEX, &msg);
442 defwndproc_counter++;
443 ret = CallWindowProcA(oldproc, hwnd, message, wParam, lParam);
444 defwndproc_counter--;
449 static HWND create_trackbar(DWORD style, HWND parent){
454 GetClientRect(parent, &rect);
455 hWndTrack = CreateWindowEx(
456 0, TRACKBAR_CLASS,"Trackbar Control", style,
457 rect.right,rect.bottom, 100, 50,
458 parent, NULL,GetModuleHandleA(NULL) ,NULL);
460 if (!hWndTrack) return NULL;
462 oldproc = (WNDPROC)SetWindowLongPtrA(hWndTrack, GWLP_WNDPROC, (LONG_PTR)trackbar_subclass_proc);
463 SetWindowLongPtrA(hWndTrack, GWLP_USERDATA, (LONG_PTR)oldproc);
468 /* test functions for setters, getters, and sequences */
470 static void test_trackbar_buddy(HWND hWndTrackbar){
473 HWND hWndCurrentBuddy;
476 flush_sequences(sequences, NUM_MSG_SEQUENCE);
478 hWndLeftBuddy = CreateWindowEx(0, STATUSCLASSNAME, NULL, 0,
479 0,0,300,20, NULL, NULL, NULL, NULL);
480 ok(hWndLeftBuddy != NULL, "Expected non NULL value\n");
482 if (hWndLeftBuddy != NULL){
483 hWndCurrentBuddy = (HWND) SendMessage(hWndTrackbar, TBM_GETBUDDY, TRUE, 0);
484 rTest = (HWND) SendMessage(hWndTrackbar, TBM_SETBUDDY, FALSE, (LPARAM) hWndLeftBuddy);
485 ok(rTest == hWndCurrentBuddy, "Expected hWndCurrentBuddy\n");
486 rTest = (HWND) SendMessage(hWndTrackbar, TBM_SETBUDDY, FALSE, (LPARAM) hWndLeftBuddy);
487 ok(rTest == hWndLeftBuddy, "Expected hWndLeftBuddy\n");
489 skip ("left buddy control not present?\n");
491 hWndRightBuddy = CreateWindowEx(0, STATUSCLASSNAME, NULL, 0,
492 0,0,300,20,NULL,NULL, NULL, NULL);
494 ok(hWndRightBuddy != NULL, "expected non NULL value\n");
496 /* test TBM_SETBUDDY */
497 if (hWndRightBuddy != NULL){
498 hWndCurrentBuddy = (HWND) SendMessage(hWndTrackbar, TBM_GETBUDDY, TRUE, 0);
499 rTest = (HWND) SendMessage(hWndTrackbar, TBM_SETBUDDY, TRUE, (LPARAM) hWndRightBuddy);
500 ok(rTest == hWndCurrentBuddy, "Expected hWndCurrentBuddy\n");
501 rTest = (HWND) SendMessage(hWndTrackbar, TBM_SETBUDDY, TRUE, (LPARAM) hWndRightBuddy);
502 ok(rTest == hWndRightBuddy, "Expected hWndRightbuddy\n");
504 skip("Right buddy control not present?\n");
506 /* test TBM_GETBUDDY */
507 if (hWndLeftBuddy != NULL){
508 rTest = (HWND) SendMessage(hWndTrackbar, TBM_GETBUDDY, FALSE, 0);
509 ok(rTest == hWndLeftBuddy, "Expected hWndLeftBuddy\n");
510 DestroyWindow(hWndLeftBuddy);
512 if (hWndRightBuddy != NULL){
513 rTest = (HWND) SendMessage(hWndTrackbar, TBM_GETBUDDY, TRUE,0);
514 ok(rTest == hWndRightBuddy, "Expected hWndRightBuddy\n");
515 DestroyWindow(hWndRightBuddy);
518 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, buddy_window_test_seq, "buddy test sequence", TRUE);
519 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_buddy_window_test_seq, "parent buddy test seq", TRUE);
523 static void test_line_size(HWND hWndTrackbar){
526 flush_sequences(sequences, NUM_MSG_SEQUENCE);
528 /* test TBM_SETLINESIZE */
529 r = SendMessage(hWndTrackbar, TBM_SETLINESIZE, 0, 10);
531 r = SendMessage(hWndTrackbar, TBM_SETLINESIZE, 0, 4);
534 /* test TBM_GETLINESIZE */
535 r = SendMessage(hWndTrackbar, TBM_GETLINESIZE, 0,0);
538 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, line_size_test_seq, "linesize test sequence", FALSE);
539 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_empty_test_seq, "parent line test sequence", FALSE);
543 static void test_page_size(HWND hWndTrackbar){
546 flush_sequences(sequences, NUM_MSG_SEQUENCE);
548 /* test TBM_SETPAGESIZE */
549 r = SendMessage(hWndTrackbar, TBM_SETPAGESIZE, 0, 10);
551 r = SendMessage(hWndTrackbar, TBM_SETPAGESIZE, 0, -1);
554 /* test TBM_GETPAGESIZE */
555 r = SendMessage(hWndTrackbar, TBM_GETPAGESIZE, 0,0);
558 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, page_size_test_seq, "page size test sequence", FALSE);
559 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_empty_test_seq, "parent page size test sequence", FALSE);
561 /* check for zero page size */
562 r = SendMessage(hWndTrackbar, TBM_SETPAGESIZE, 0, 0);
564 r = SendMessage(hWndTrackbar, TBM_GETPAGESIZE, 0, 0);
566 /* revert to default */
567 r = SendMessage(hWndTrackbar, TBM_SETPAGESIZE, 0, -1);
569 r = SendMessage(hWndTrackbar, TBM_GETPAGESIZE, 0, 0);
572 r = SendMessage(hWndTrackbar, TBM_SETPAGESIZE, 0, -2);
574 r = SendMessage(hWndTrackbar, TBM_GETPAGESIZE, 0, 0);
578 static void test_position(HWND hWndTrackbar){
581 flush_sequences(sequences, NUM_MSG_SEQUENCE);
582 /* test TBM_SETPOS */
583 SendMessage(hWndTrackbar, TBM_SETPOS, TRUE, -1);
584 r = SendMessage(hWndTrackbar, TBM_GETPOS, 0, 0);
586 SendMessage(hWndTrackbar, TBM_SETPOS, TRUE, 5);
587 r = SendMessage(hWndTrackbar, TBM_GETPOS, 0,0);
589 SendMessage(hWndTrackbar, TBM_SETPOS, TRUE, 5);
590 SendMessage(hWndTrackbar, TBM_SETPOS, TRUE, 1000);
591 r = SendMessage(hWndTrackbar, TBM_GETPOS, 0,0);
593 SendMessage(hWndTrackbar, TBM_SETPOS, FALSE, 20);
594 r = SendMessage(hWndTrackbar, TBM_GETPOS, 0,0);
596 SendMessage(hWndTrackbar, TBM_SETPOS, TRUE, 20);
598 /* test TBM_GETPOS */
599 r = SendMessage(hWndTrackbar, TBM_GETPOS, 0,0);
602 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, position_test_seq, "position test sequence", TRUE);
603 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_position_test_seq, "parent position test sequence", TRUE);
606 static void test_range(HWND hWndTrackbar){
609 flush_sequences(sequences, NUM_MSG_SEQUENCE);
610 /* test TBM_SETRANGE */
611 SendMessage(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(0, 10));
612 r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
614 r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
616 SendMessage(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(-1, 1000));
617 r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
619 r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
621 SendMessage(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(10, 0));
622 r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
624 r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
626 SendMessage(hWndTrackbar, TBM_SETRANGE, FALSE, MAKELONG(0,10));
627 r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
629 r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
632 /*test TBM_SETRANGEMAX */
633 SendMessage(hWndTrackbar, TBM_SETRANGEMAX, TRUE, 10);
634 r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
636 SendMessage(hWndTrackbar, TBM_SETRANGEMAX, TRUE, -1);
637 r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
639 SendMessage(hWndTrackbar, TBM_SETRANGEMAX, FALSE, 10);
640 r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
643 /* testing TBM_SETRANGEMIN */
644 SendMessage(hWndTrackbar, TBM_SETRANGEMIN, TRUE, 0);
645 r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
647 SendMessage(hWndTrackbar, TBM_SETRANGEMIN, TRUE, 10);
648 r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
650 SendMessage(hWndTrackbar, TBM_SETRANGEMIN, TRUE, -10);
651 r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
653 SendMessage(hWndTrackbar, TBM_SETRANGEMIN, FALSE, 5);
654 r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
657 /* test TBM_GETRANGEMAX */
658 r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
661 /* test TBM_GETRANGEMIN */
662 r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
665 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, range_test_seq, "range test sequence", TRUE);
666 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_range_test_seq, "parent range test sequence", TRUE);
669 static void test_selection(HWND hWndTrackbar){
672 flush_sequences(sequences, NUM_MSG_SEQUENCE);
673 /* test TBM_SETSEL */
674 SendMessage(hWndTrackbar, TBM_SETSEL, TRUE, MAKELONG(0,10));
675 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
677 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
679 SendMessage(hWndTrackbar, TBM_SETSEL, TRUE, MAKELONG(5, 20));
680 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
682 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
684 SendMessage(hWndTrackbar, TBM_SETSEL, FALSE, MAKELONG(5, 10));
685 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
687 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
690 /* test TBM_SETSELEND */
691 SendMessage(hWndTrackbar, TBM_SETSELEND, TRUE, 10);
692 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
694 SendMessage(hWndTrackbar, TBM_SETSELEND, TRUE, 20);
695 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
697 SendMessage(hWndTrackbar, TBM_SETSELEND, TRUE, 4);
698 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
700 SendMessage(hWndTrackbar, TBM_SETSELEND, FALSE, 2);
701 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
704 /* test TBM_GETSELEND */
705 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
708 /* testing TBM_SETSELSTART */
709 SendMessage(hWndTrackbar, TBM_SETSELSTART, TRUE, 5);
710 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
712 SendMessage(hWndTrackbar, TBM_SETSELSTART, TRUE, 0);
713 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
715 SendMessage(hWndTrackbar, TBM_SETSELSTART, TRUE, 20);
716 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
718 SendMessage(hWndTrackbar, TBM_SETSELSTART, FALSE, 8);
719 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
722 /* test TBM_GETSELSTART */
723 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
726 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, selection_test_seq, "selection test sequence", TRUE);
727 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_selection_test_seq, "parent selection test seqence", TRUE);
730 static void test_thumb_length(HWND hWndTrackbar){
733 flush_sequences(sequences, NUM_MSG_SEQUENCE);
734 /* testing TBM_SETTHUMBLENGTH */
735 SendMessage(hWndTrackbar, TBM_SETTHUMBLENGTH, 15, 0);
736 r = SendMessage(hWndTrackbar, TBM_GETTHUMBLENGTH, 0,0);
738 SendMessage(hWndTrackbar, TBM_SETTHUMBLENGTH, 20, 0);
739 r = SendMessage(hWndTrackbar, TBM_GETTHUMBLENGTH, 0,0);
742 /* test TBM_GETTHUMBLENGTH */
743 r = SendMessage(hWndTrackbar, TBM_GETTHUMBLENGTH, 0,0);
746 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, thumb_length_test_seq, "thumb length test sequence", TRUE);
747 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_thumb_length_test_seq, "parent thumb lenth test sequence", TRUE);
750 static void test_tic_settings(HWND hWndTrackbar){
753 /* testing TBM_SETTIC */
754 /* Set tics at 5 and 10 */
755 /* 0 and 20 are out of range and should not be set */
756 r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0, 0);
758 r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0, 0);
761 flush_sequences(sequences, NUM_MSG_SEQUENCE);
762 r = SendMessage(hWndTrackbar, TBM_SETTIC, 0, 0);
763 ok(r == FALSE, "Expected FALSE, got %d\n", r);
764 r = SendMessage(hWndTrackbar, TBM_SETTIC, 0, 5);
765 ok(r == TRUE, "Expected TRUE, got %d\n", r);
766 r = SendMessage(hWndTrackbar, TBM_SETTIC, 0, 10);
767 ok(r == TRUE, "Expected TRUE, got %d\n", r);
769 r = SendMessage(hWndTrackbar, TBM_SETTIC, 0, 20);
770 ok(r == FALSE, "Expected False, got %d\n", r);
772 /* test TBM_SETTICFREQ */
773 SendMessage(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(0, 10));
774 SendMessage(hWndTrackbar, TBM_SETTICFREQ, 2, 0);
775 r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
777 SendMessage(hWndTrackbar, TBM_SETTICFREQ, 5, 0);
778 r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
780 SendMessage(hWndTrackbar, TBM_SETTICFREQ, 15, 0);
781 r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
784 /* test TBM_GETNUMTICS */
785 /* since TIC FREQ is 15, there should be only 2 tics now */
786 r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
789 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, tic_settings_test_seq, "tic settings test sequence", TRUE);
790 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_tic_settings_test_seq, "parent tic settings test sequence", TRUE);
792 /* range [0,0], freq = 1 */
793 SendMessage(hWndTrackbar, TBM_SETRANGEMAX, TRUE, 0);
794 SendMessage(hWndTrackbar, TBM_SETRANGEMIN, TRUE, 0);
795 SendMessage(hWndTrackbar, TBM_SETTICFREQ, 1, 0);
796 r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
798 /* range [0,1], freq = 1 */
799 SendMessage(hWndTrackbar, TBM_SETRANGEMAX, TRUE, 1);
800 SendMessage(hWndTrackbar, TBM_SETRANGEMIN, TRUE, 0);
801 SendMessage(hWndTrackbar, TBM_SETTICFREQ, 1, 0);
802 r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
804 /* range [0,2], freq = 1 */
805 SendMessage(hWndTrackbar, TBM_SETRANGEMAX, TRUE, 2);
806 SendMessage(hWndTrackbar, TBM_SETRANGEMIN, TRUE, 0);
807 SendMessage(hWndTrackbar, TBM_SETTICFREQ, 1, 0);
808 r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
812 static void test_tic_placement(HWND hWndTrackbar){
817 SendMessage(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(1, 6));
818 SendMessage(hWndTrackbar, TBM_SETTICFREQ, 1, 0);
820 numtics = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
821 ok(numtics == 6, "Expected 6, got %d\n", numtics);
823 flush_sequences(sequences, NUM_MSG_SEQUENCE);
824 /* test TBM_GETPTICS */
825 rPTics = (DWORD *) SendMessage(hWndTrackbar, TBM_GETPTICS, 0,0);
826 expect(2, rPTics[0]);
827 expect(3, rPTics[1]);
828 expect(4, rPTics[2]);
829 expect(5, rPTics[3]);
831 /* test TBM_GETTIC */
832 r = SendMessage(hWndTrackbar, TBM_GETTIC, 0,0);
834 r = SendMessage(hWndTrackbar, TBM_GETTIC, 2,0);
836 r = SendMessage(hWndTrackbar, TBM_GETTIC, 4,0);
839 /* test TBM_GETTICPIC */
840 r = SendMessage(hWndTrackbar, TBM_GETTICPOS, 0, 0);
841 ok(r > 0, "Expected r > 0, got %d\n", r);
842 r = SendMessage(hWndTrackbar, TBM_GETTICPOS, 2, 0);
843 ok(r > 0, "Expected r > 0, got %d\n", r);
845 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, tic_placement_test_seq, "get tic placement test sequence", FALSE);
846 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_empty_test_seq, "parent get tic placement test sequence", FALSE);
850 static void test_tool_tips(HWND hWndTrackbar){
855 flush_sequences(sequences, NUM_MSG_SEQUENCE);
856 /* testing TBM_SETTIPSIDE */
857 r = SendMessage(hWndTrackbar, TBM_SETTIPSIDE, TBTS_TOP, 0);
859 r = SendMessage(hWndTrackbar, TBM_SETTIPSIDE, TBTS_LEFT, 0);
861 r = SendMessage(hWndTrackbar, TBM_SETTIPSIDE, TBTS_BOTTOM, 0);
862 expect(TBTS_LEFT, r);
863 r = SendMessage(hWndTrackbar, TBM_SETTIPSIDE, TBTS_RIGHT, 0);
864 expect(TBTS_BOTTOM, r);
866 /* testing TBM_SETTOOLTIPS */
867 hWndTooltip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, 0,
868 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
869 NULL, NULL, NULL, NULL);
871 ok(hWndTooltip != NULL, "Expected non NULL value\n");
872 if (hWndTooltip != NULL){
873 SendMessage(hWndTrackbar, TBM_SETTOOLTIPS, (LPARAM) hWndTooltip, 0);
874 rTest = (HWND) SendMessage(hWndTrackbar, TBM_GETTOOLTIPS, 0,0);
875 ok(rTest == hWndTooltip, "Expected hWndToolTip, got\n");
876 SendMessage(hWndTrackbar, TBM_SETTOOLTIPS, 0, 0);
877 rTest = (HWND) SendMessage(hWndTrackbar, TBM_GETTOOLTIPS, 0,0);
878 ok(rTest == NULL, "Expected NULL\n");
879 SendMessage(hWndTrackbar, TBM_SETTOOLTIPS, (LPARAM) hWndTooltip, 5);
880 rTest = (HWND) SendMessage(hWndTrackbar, TBM_GETTOOLTIPS, 0,0);
881 ok(rTest == hWndTooltip, "Expected hWndTooltip, got\n");
883 skip("tool tip control not present?\n");
885 /* test TBM_GETTOOLTIPS */
886 rTest = (HWND) SendMessage(hWndTrackbar, TBM_GETTOOLTIPS, 0,0);
887 ok(rTest == hWndTooltip, "Expected hWndTooltip\n");
889 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, tool_tips_test_seq, "tool tips test sequence", FALSE);
890 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_empty_test_seq, "parent tool tips test sequence", FALSE);
894 static void test_unicode(HWND hWndTrackbar){
897 flush_sequences(sequences, NUM_MSG_SEQUENCE);
898 /* testing TBM_SETUNICODEFORMAT */
899 r = SendMessage(hWndTrackbar, TBM_SETUNICODEFORMAT, TRUE, 0);
900 ok(r == FALSE, "Expected FALSE, got %d\n",r);
901 r = SendMessage(hWndTrackbar, TBM_SETUNICODEFORMAT, FALSE, 0);
902 ok(r == TRUE, "Expected TRUE, got %d\n",r);
904 /* test TBM_GETUNICODEFORMAT */
905 r = SendMessage(hWndTrackbar, TBM_GETUNICODEFORMAT, 0,0);
906 ok(r == FALSE, "Expected FALSE, got %d\n",r);
908 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, unicode_test_seq, "unicode test sequence", FALSE);
909 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_empty_test_seq, "parent unicode test sequence", FALSE);
912 static void test_ignore_selection(HWND hWndTrackbar){
915 flush_sequences(sequences, NUM_MSG_SEQUENCE);
916 /* test TBM_SETSEL ensure that it is ignored */
917 SendMessage(hWndTrackbar, TBM_SETSEL, TRUE, MAKELONG(0,10));
918 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
920 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
922 SendMessage(hWndTrackbar, TBM_SETSEL, FALSE, MAKELONG(0,10));
923 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
925 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
928 /* test TBM_SETSELEND, ensure that it is ignored */
929 SendMessage(hWndTrackbar, TBM_SETSELEND, TRUE, 0);
930 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
932 SendMessage(hWndTrackbar, TBM_SETSELEND, TRUE, 10);
933 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
935 SendMessage(hWndTrackbar, TBM_SETSELEND, FALSE, 0);
936 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
939 /* test TBM_SETSELSTART, ensure that it is ignored */
940 SendMessage(hWndTrackbar, TBM_SETSELSTART, TRUE, 0);
941 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
943 SendMessage(hWndTrackbar, TBM_SETSELSTART, TRUE, 10);
944 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
946 SendMessage(hWndTrackbar, TBM_SETSELSTART, FALSE, 0);
947 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
950 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, ignore_selection_test_seq, "ignore selection setting test sequence", FALSE);
951 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_empty_test_seq, "parent ignore selection setting test sequence", FALSE);
954 static void test_initial_state(void)
959 hWnd = create_trackbar(0, hWndParent);
961 ret = SendMessage(hWnd, TBM_GETNUMTICS, 0, 0);
963 ret = SendMessage(hWnd, TBM_GETTIC, 0, 0);
965 ret = SendMessage(hWnd, TBM_GETTICPOS, 0, 0);
973 DWORD style = WS_VISIBLE | TBS_TOOLTIPS | TBS_ENABLESELRANGE | TBS_FIXEDLENGTH | TBS_AUTOTICKS;
976 init_msg_sequences(sequences, NUM_MSG_SEQUENCE);
977 InitCommonControls();
979 /* create parent window */
980 hWndParent = create_parent_window();
981 ok(hWndParent != NULL, "Failed to create parent Window!\n");
984 skip("parent window not present\n");
988 flush_sequences(sequences, NUM_MSG_SEQUENCE);
990 /* create trackbar with set styles */
991 hWndTrackbar = create_trackbar(style, hWndParent);
993 ok(hWndTrackbar != NULL, "Expected non NULL value\n");
996 skip("trackbar control not present?\n");
1000 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, create_trackbar_wnd_seq, "create Trackbar Window", FALSE);
1001 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_create_trackbar_wnd_seq, "parent trackbar window", TRUE);
1002 flush_sequences(sequences, NUM_MSG_SEQUENCE);
1004 /* TEST OF ALL SETTER and GETTER MESSAGES with required styles turned on*/
1005 test_trackbar_buddy(hWndTrackbar);
1006 test_line_size(hWndTrackbar);
1007 test_page_size(hWndTrackbar);
1008 test_position(hWndTrackbar);
1009 test_range(hWndTrackbar);
1010 test_selection(hWndTrackbar);
1011 test_thumb_length(hWndTrackbar);
1012 test_tic_settings(hWndTrackbar);
1013 test_tic_placement(hWndTrackbar);
1014 test_tool_tips(hWndTrackbar);
1015 test_unicode(hWndTrackbar);
1017 flush_sequences(sequences, NUM_MSG_SEQUENCE);
1018 DestroyWindow(hWndTrackbar);
1020 /* test getters and setters without styles set */
1021 hWndTrackbar = create_trackbar(0, hWndParent);
1023 ok(hWndTrackbar != NULL, "Expected non NULL value\n");
1026 skip("trackbar control not present?\n");
1030 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_new_window_test_seq, "new trackbar window test sequence", TRUE);
1032 test_ignore_selection(hWndTrackbar);
1034 DestroyWindow(hWndTrackbar);
1036 test_initial_state();
1038 DestroyWindow(hWndParent);