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