ReactOS 0.4.16-dev-319-g6cf4263
trackbar.c
Go to the documentation of this file.
1/* Unit tests for the track bar control.
2 *
3 * Copyright 2007 Keith Stevens
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18 */
19
20#include <windows.h>
21#include <commctrl.h>
22#include <stdio.h>
23
24#include "wine/test.h"
25#include "msg.h"
26#include "v6util.h"
27
28#define expect(expected, got) ok(got == expected, "Expected %d, got %d\n", expected, got)
29#define NUM_MSG_SEQUENCE 2
30#define PARENT_SEQ_INDEX 0
31#define TRACKBAR_SEQ_INDEX 1
32
35
37{
39
40 if (message == WM_PAINT)
41 return 0;
42
43 return CallWindowProcA(oldproc, hwnd, message, wParam, lParam);
44}
45
47
48static const struct message empty_seq[] = {
49 {0}
50};
51
52static const struct message parent_create_trackbar_wnd_seq[] = {
53 { WM_NOTIFYFORMAT, sent},
54 { WM_QUERYUISTATE, sent|optional},
63 { WM_NOTIFY, sent},
64 {0}
65};
66
67static const struct message parent_new_window_test_seq[] = {
75 { WM_NOTIFYFORMAT, sent},
76 { WM_QUERYUISTATE, sent|optional},
77 {0}
78};
79
80static const struct message buddy_window_test_seq[] = {
93 {0}
94};
95
96static const struct message parent_buddy_window_test_seq[] = {
98 { WM_NOTIFY, sent},
100 { WM_NOTIFY, sent},
102 { WM_NOTIFY, sent},
104 { WM_NOTIFY, sent},
105 {0}
106};
107
108static const struct message line_size_test_seq[] = {
109 { TBM_SETLINESIZE, sent|lparam, 0, 10},
110 { TBM_SETLINESIZE, sent|lparam, 0, 4},
112 {0}
113};
114
115static const struct message page_size_test_seq[] = {
116 { TBM_SETPAGESIZE, sent|lparam, 0, 10},
117 { TBM_SETPAGESIZE, sent|lparam, 0, -1},
119 {0}
120};
121
122static const struct message position_test_seq[] = {
125 { TBM_GETPOS, sent},
128 { TBM_GETPOS, sent},
130 { TBM_SETPOS, sent|wparam|lparam, TRUE, 1000},
132 { TBM_GETPOS, sent},
134 { TBM_GETPOS, sent},
136 { TBM_GETPOS, sent},
137 {0}
138};
139
140static const struct message parent_position_test_seq[] = {
142 { WM_NOTIFY, sent},
144 { WM_NOTIFY, sent},
146 { WM_NOTIFY, sent},
147 {0}
148};
149
150static const struct message range_test_seq[] = {
155 { TBM_SETRANGE, sent|wparam|lparam, TRUE, MAKELONG(-1, 1000)},
187 {0}
188};
189
190static const struct message parent_range_test_seq[] = {
192 { WM_NOTIFY, sent},
194 { WM_NOTIFY, sent},
196 { WM_NOTIFY, sent},
198 { WM_NOTIFY, sent},
200 { WM_NOTIFY, sent},
202 { WM_NOTIFY, sent},
204 { WM_NOTIFY, sent},
206 { WM_NOTIFY, sent},
207 {0}
208};
209
210static const struct message selection_test_seq[] = {
246 {0}
247};
248
249static const struct message parent_selection_test_seq[] = {
251 { WM_NOTIFY, sent},
253 { WM_NOTIFY, sent},
255 { WM_NOTIFY, sent},
257 { WM_NOTIFY, sent},
259 { WM_NOTIFY, sent},
261 { WM_NOTIFY, sent},
263 { WM_NOTIFY, sent},
265 { WM_NOTIFY, sent},
266 {0}
267};
268
269static const struct message tic_settings_test_seq[] = {
270 { TBM_SETTIC, sent|lparam, 0, 0},
271 { TBM_SETTIC, sent|lparam, 0, 5},
272 { TBM_SETTIC, sent|lparam, 0, 10},
273 { TBM_SETTIC, sent|lparam, 0, 20},
282 { TBM_SETTICFREQ, sent|wparam, 15},
286 {0}
287};
288
289static const struct message parent_tic_settings_test_seq[] = {
291 { WM_NOTIFY, sent},
293 { WM_NOTIFY, sent},
295 { WM_NOTIFY, sent},
297 { WM_NOTIFY, sent},
298 {0}
299};
300
301static const struct message thumb_length_test_seq[] = {
309 { WM_SIZE, sent},
312 { WM_SIZE, sent},
315 {0}
316};
317
318static const struct message parent_thumb_length_test_seq[] = {
320 { WM_NOTIFY, sent},
322 { WM_NOTIFY, sent},
324 { WM_NOTIFY, sent},
326 { WM_NOTIFY, sent},
327 {0}
328};
329
330static const struct message tic_placement_test_seq[] = {
331 { TBM_GETPTICS, sent},
332 { TBM_GETTIC, sent|wparam, 0},
333 { TBM_GETTIC, sent|wparam, 2},
334 { TBM_GETTIC, sent|wparam, 4},
337 {0}
338};
339
340static const struct message tool_tips_test_seq[] = {
352 {0}
353};
354
355static const struct message unicode_test_seq[] = {
359 {0}
360};
361
362static const struct message ignore_selection_test_seq[] = {
381 {0}
382};
383
385 static LONG defwndproc_counter = 0;
386 LRESULT ret;
387 struct message msg;
388
389 /* log system messages, except for painting */
390 if (message < WM_USER &&
391 message != WM_PAINT &&
393 message != WM_NCPAINT &&
395 message != WM_GETTEXT &&
396 message != WM_GETICON &&
398 {
399 msg.message = message;
400 msg.flags = sent|wparam|lparam;
401 if (defwndproc_counter) msg.flags |= defwinproc;
402 msg.wParam = wParam;
403 msg.lParam = lParam;
404 msg.id = 0;
406 }
407
408 defwndproc_counter++;
410 defwndproc_counter--;
411
412 return ret;
413}
414
416 WNDCLASSA cls;
417
418 cls.style = 0;
420 cls.cbClsExtra = 0;
421 cls.cbWndExtra = 0;
423 cls.hIcon = 0;
426 cls.lpszMenuName = NULL;
427 cls.lpszClassName = "Trackbar test parent class";
428 return RegisterClassA(&cls);
429}
430
433 return NULL;
434
435 return CreateWindowA("Trackbar test parent class", "Trackbar test parent window",
437 0, 0, 100, 100, GetDesktopWindow(), NULL, GetModuleHandleA(NULL), NULL);
438}
439
442 static LONG defwndproc_counter = 0;
443 struct message msg = { 0 };
444 LRESULT ret;
445
446 msg.message = message;
447 msg.flags = sent|wparam|lparam;
448 if (defwndproc_counter) msg.flags |= defwinproc;
449 msg.wParam = wParam;
450 msg.lParam = lParam;
452
453 defwndproc_counter++;
455 defwndproc_counter--;
456
457 return ret;
458}
459
461 HWND hWndTrack;
462 WNDPROC oldproc;
463 RECT rect;
464
466 hWndTrack = CreateWindowA(TRACKBAR_CLASSA, "Trackbar Control", style,
467 rect.right, rect.bottom, 100, 50,
469
470 if (!hWndTrack) return NULL;
471
473 SetWindowLongPtrA(hWndTrack, GWLP_USERDATA, (LONG_PTR)oldproc);
474
475 return hWndTrack;
476}
477
479{
480 RECT rect;
482 return CreateWindowA(TRACKBAR_CLASSA, "Trackbar Control", style,
483 rect.right, rect.bottom, 100, 50,
485}
486
487/* test functions for setters, getters, and sequences */
488
489static void test_trackbar_buddy(void)
490{
491 HWND hWndLeftBuddy, hWndTrackbar;
492 HWND hWndRightBuddy;
493 HWND hWndCurrentBuddy;
494 HWND rTest;
495
496 hWndTrackbar = create_trackbar(defaultstyle, hWndParent);
497 ok(hWndTrackbar != NULL, "Expected non NULL value\n");
498
500
501 hWndLeftBuddy = CreateWindowA(STATUSCLASSNAMEA, NULL, 0, 0, 0, 300, 20, NULL, NULL, NULL, NULL);
502 ok(hWndLeftBuddy != NULL, "Expected non NULL value\n");
503
504 if (hWndLeftBuddy != NULL){
505 hWndCurrentBuddy = (HWND) SendMessageA(hWndTrackbar, TBM_GETBUDDY, TRUE, 0);
506 rTest = (HWND) SendMessageA(hWndTrackbar, TBM_SETBUDDY, FALSE, (LPARAM) hWndLeftBuddy);
507 ok(rTest == hWndCurrentBuddy, "Expected hWndCurrentBuddy\n");
508 rTest = (HWND) SendMessageA(hWndTrackbar, TBM_SETBUDDY, FALSE, (LPARAM) hWndLeftBuddy);
509 ok(rTest == hWndLeftBuddy, "Expected hWndLeftBuddy\n");
510 } else
511 skip ("left buddy control not present?\n");
512
513 hWndRightBuddy = CreateWindowA(STATUSCLASSNAMEA, NULL, 0, 0, 0, 300, 20, NULL, NULL, NULL, NULL);
514
515 ok(hWndRightBuddy != NULL, "expected non NULL value\n");
516
517 /* test TBM_SETBUDDY */
518 if (hWndRightBuddy != NULL){
519 hWndCurrentBuddy = (HWND) SendMessageA(hWndTrackbar, TBM_GETBUDDY, TRUE, 0);
520 rTest = (HWND) SendMessageA(hWndTrackbar, TBM_SETBUDDY, TRUE, (LPARAM) hWndRightBuddy);
521 ok(rTest == hWndCurrentBuddy, "Expected hWndCurrentBuddy\n");
522 rTest = (HWND) SendMessageA(hWndTrackbar, TBM_SETBUDDY, TRUE, (LPARAM) hWndRightBuddy);
523 ok(rTest == hWndRightBuddy, "Expected hWndRightbuddy\n");
524 } else
525 skip("Right buddy control not present?\n");
526
527 /* test TBM_GETBUDDY */
528 if (hWndLeftBuddy != NULL){
529 rTest = (HWND) SendMessageA(hWndTrackbar, TBM_GETBUDDY, FALSE, 0);
530 ok(rTest == hWndLeftBuddy, "Expected hWndLeftBuddy\n");
531 DestroyWindow(hWndLeftBuddy);
532 }
533 if (hWndRightBuddy != NULL){
534 rTest = (HWND) SendMessageA(hWndTrackbar, TBM_GETBUDDY, TRUE,0);
535 ok(rTest == hWndRightBuddy, "Expected hWndRightBuddy\n");
536 DestroyWindow(hWndRightBuddy);
537 }
538
541
542 DestroyWindow(hWndTrackbar);
543}
544
545static void test_line_size(void)
546{
547 HWND hWndTrackbar;
548 int r;
549
550 hWndTrackbar = create_trackbar(defaultstyle, hWndParent);
551 ok(hWndTrackbar != NULL, "Expected non NULL value\n");
552
554
555 /* test TBM_SETLINESIZE */
556 r = SendMessageA(hWndTrackbar, TBM_SETLINESIZE, 0, 10);
557 expect(1,r);
558 r = SendMessageA(hWndTrackbar, TBM_SETLINESIZE, 0, 4);
559 expect(10, r);
560
561 /* test TBM_GETLINESIZE */
562 r = SendMessageA(hWndTrackbar, TBM_GETLINESIZE, 0,0);
563 expect(4, r);
564
566 ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq, "parent line test sequence", FALSE);
567
568 DestroyWindow(hWndTrackbar);
569}
570
571
572static void test_page_size(void)
573{
574 HWND hWndTrackbar;
575 int r;
576
577 hWndTrackbar = create_trackbar(defaultstyle, hWndParent);
578 ok(hWndTrackbar != NULL, "Expected non NULL value\n");
579
580 r = SendMessageA(hWndTrackbar, TBM_GETPAGESIZE, 0, 0);
581 ok(r == 20, "Unexpected page size %d.\n", r);
582
583 SendMessageA(hWndTrackbar, TBM_SETRANGE, 0, MAKELPARAM(0, 65));
584
585 r = SendMessageA(hWndTrackbar, TBM_GETPAGESIZE, 0, 0);
586 ok(r == 13, "Unexpected page size %d.\n", r);
587
588 SendMessageA(hWndTrackbar, TBM_SETRANGEMIN, 0, 10);
589
590 r = SendMessageA(hWndTrackbar, TBM_GETPAGESIZE, 0, 0);
591 ok(r == 11, "Unexpected page size %d.\n", r);
592
593 SendMessageA(hWndTrackbar, TBM_SETRANGEMAX, 0, 50);
594
595 r = SendMessageA(hWndTrackbar, TBM_GETPAGESIZE, 0, 0);
596 ok(r == 8, "Unexpected page size %d.\n", r);
597
598 r = SendMessageA(hWndTrackbar, TBM_SETPAGESIZE, 0, 10);
599 ok(r == 8, "Unexpected page size %d.\n", r);
600
601 SendMessageA(hWndTrackbar, TBM_SETRANGE, 0, MAKELPARAM(0, 30));
602
603 r = SendMessageA(hWndTrackbar, TBM_GETPAGESIZE, 0, 0);
604 ok(r == 10, "Unexpected page size %d.\n", r);
605
606 SendMessageA(hWndTrackbar, TBM_SETRANGEMIN, 0, 5);
607
608 r = SendMessageA(hWndTrackbar, TBM_GETPAGESIZE, 0, 0);
609 ok(r == 10, "Unexpected page size %d.\n", r);
610
611 SendMessageA(hWndTrackbar, TBM_SETRANGEMAX, 0, 40);
612
613 r = SendMessageA(hWndTrackbar, TBM_GETPAGESIZE, 0, 0);
614 ok(r == 10, "Unexpected page size %d.\n", r);
615
616 r = SendMessageA(hWndTrackbar, TBM_SETPAGESIZE, 0, -1);
617 ok(r == 10, "Unexpected page size %d.\n", r);
618
619 r = SendMessageA(hWndTrackbar, TBM_GETPAGESIZE, 0, 0);
620 ok(r == 7, "Unexpected page size %d.\n", r);
621
622 SendMessageA(hWndTrackbar, TBM_SETRANGEMAX, 0, 100);
623
624 r = SendMessageA(hWndTrackbar, TBM_GETPAGESIZE, 0, 0);
625 ok(r == 19, "Unexpected page size %d.\n", r);
626
627 DestroyWindow(hWndTrackbar);
628
629 hWndTrackbar = create_trackbar(defaultstyle, hWndParent);
630 ok(hWndTrackbar != NULL, "Failed to create trackbar window.\n");
631
633
634 /* test TBM_SETPAGESIZE */
635 r = SendMessageA(hWndTrackbar, TBM_SETPAGESIZE, 0, 10);
636 expect(20, r);
637 r = SendMessageA(hWndTrackbar, TBM_SETPAGESIZE, 0, -1);
638 expect(10, r);
639
640 /* test TBM_GETPAGESIZE */
641 r = SendMessageA(hWndTrackbar, TBM_GETPAGESIZE, 0,0);
642 expect(20, r);
643
644 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, page_size_test_seq, "page size test sequence", FALSE);
645 ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq, "parent page size test sequence", FALSE);
646
647 /* check for zero page size */
648 r = SendMessageA(hWndTrackbar, TBM_SETPAGESIZE, 0, 0);
649 expect(20, r);
650 r = SendMessageA(hWndTrackbar, TBM_GETPAGESIZE, 0, 0);
651 expect(0, r);
652 /* revert to default */
653 r = SendMessageA(hWndTrackbar, TBM_SETPAGESIZE, 0, -1);
654 expect(0, r);
655 r = SendMessageA(hWndTrackbar, TBM_GETPAGESIZE, 0, 0);
656 expect(20, r);
657 /* < -1 */
658 r = SendMessageA(hWndTrackbar, TBM_SETPAGESIZE, 0, -2);
659 expect(20, r);
660 r = SendMessageA(hWndTrackbar, TBM_GETPAGESIZE, 0, 0);
661 expect(-2, r);
662
663 DestroyWindow(hWndTrackbar);
664}
665
666static void test_position(void)
667{
668 HWND hWndTrackbar;
669 RECT rect, rect2;
670 WNDPROC oldproc;
671 int r;
672
673 hWndTrackbar = create_trackbar(defaultstyle, hWndParent);
674 ok(hWndTrackbar != NULL, "Expected non NULL value\n");
675
677
678 /* test TBM_SETPOS */
679 SendMessageA(hWndTrackbar, TBM_SETPOS, TRUE, -1);
680 r = SendMessageA(hWndTrackbar, TBM_GETPOS, 0, 0);
681 expect(0, r);
682 SendMessageA(hWndTrackbar, TBM_SETPOS, TRUE, 5);
683 r = SendMessageA(hWndTrackbar, TBM_GETPOS, 0,0);
684 expect(5, r);
685 SendMessageA(hWndTrackbar, TBM_SETPOS, TRUE, 5);
686 SendMessageA(hWndTrackbar, TBM_SETPOS, TRUE, 1000);
687 r = SendMessageA(hWndTrackbar, TBM_GETPOS, 0,0);
688 expect(100, r);
689 SendMessageA(hWndTrackbar, TBM_SETPOS, FALSE, 20);
690 r = SendMessageA(hWndTrackbar, TBM_GETPOS, 0,0);
691 expect(20, r);
692 SendMessageA(hWndTrackbar, TBM_SETPOS, TRUE, 20);
693
694 /* test TBM_GETPOS */
695 r = SendMessageA(hWndTrackbar, TBM_GETPOS, 0,0);
696 expect(20, r);
697
698 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, position_test_seq, "position test sequence", TRUE);
699 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_position_test_seq, "parent position test sequence", TRUE);
700
701 DestroyWindow(hWndTrackbar);
702
704 ok(hWndTrackbar != NULL, "Expected non NULL value\n");
705
706 /* subclassing procedure blocks WM_PAINT */
708 SetWindowLongPtrA(hWndTrackbar, GWLP_USERDATA, (LONG_PTR)oldproc);
709
712
713 SendMessageA(hWndTrackbar, TBM_GETTHUMBRECT, 0, (LPARAM)&rect);
714
715 /* without repaint */
716 SendMessageA(hWndTrackbar, TBM_SETPOS, FALSE, 25);
717 r = SendMessageA(hWndTrackbar, TBM_GETPOS, 0, 0);
718 ok(r == 25, "got %d\n", r);
719 SendMessageA(hWndTrackbar, TBM_GETTHUMBRECT, 0, (LPARAM)&rect2);
720 ok(rect.left == rect2.left, "got %d\n", rect.left);
721
722 /* with repaint */
723 SendMessageA(hWndTrackbar, TBM_SETPOS, TRUE, 30);
724 r = SendMessageA(hWndTrackbar, TBM_GETPOS, 0, 0);
725 ok(r == 30, "got %d\n", r);
726 SendMessageA(hWndTrackbar, TBM_GETTHUMBRECT, 0, (LPARAM)&rect2);
727 ok(rect.left != rect2.left, "got %d, expected %d\n", rect2.left, rect.left);
728
729 /* now move it with keys */
730 SendMessageA(hWndTrackbar, WM_KEYDOWN, VK_END, 0);
731 r = SendMessageA(hWndTrackbar, TBM_GETPOS, 0, 0);
732 ok(r == 100, "got %d\n", r);
733 SendMessageA(hWndTrackbar, TBM_GETTHUMBRECT, 0, (LPARAM)&rect);
734 ok(rect.left != rect2.left, "got %d, expected %d\n", rect.left, rect2.left);
735
736 DestroyWindow(hWndTrackbar);
737}
738
739static void test_range(void)
740{
741 HWND hWndTrackbar;
742 RECT rect1, rect2;
743 int r;
744
745 hWndTrackbar = create_trackbar(defaultstyle, hWndParent);
746 ok(hWndTrackbar != NULL, "Expected non NULL value\n");
747
749
750 /* test TBM_SETRANGE */
751 SendMessageA(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(0, 10));
752 r = SendMessageA(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
753 expect(10, r);
754 r = SendMessageA(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
755 expect(0, r);
756 SendMessageA(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(-1, 1000));
757 r = SendMessageA(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
758 expect(1000, r);
759 r = SendMessageA(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
760 expect(-1, r);
761 SendMessageA(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(10, 0));
762 r = SendMessageA(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
763 expect(0, r);
764 r = SendMessageA(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
765 expect(10, r);
766 SendMessageA(hWndTrackbar, TBM_SETRANGE, FALSE, MAKELONG(0,10));
767 r = SendMessageA(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
768 expect(10, r);
769 r = SendMessageA(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
770 expect(0, r);
771
772 /*test TBM_SETRANGEMAX */
773 SendMessageA(hWndTrackbar, TBM_SETRANGEMAX, TRUE, 10);
774 r = SendMessageA(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
775 expect(10, r);
776 SendMessageA(hWndTrackbar, TBM_SETRANGEMAX, TRUE, -1);
777 r = SendMessageA(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
778 expect(-1, r);
779 SendMessageA(hWndTrackbar, TBM_SETRANGEMAX, FALSE, 10);
780 r = SendMessageA(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
781 expect(10, r);
782
783 /* testing TBM_SETRANGEMIN */
784 SendMessageA(hWndTrackbar, TBM_SETRANGEMIN, TRUE, 0);
785 r = SendMessageA(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
786 expect(0, r);
787 SendMessageA(hWndTrackbar, TBM_SETRANGEMIN, TRUE, 10);
788 r = SendMessageA(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
789 expect(10, r);
790 SendMessageA(hWndTrackbar, TBM_SETRANGEMIN, TRUE, -10);
791 r = SendMessageA(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
792 expect(-10, r);
793 SendMessageA(hWndTrackbar, TBM_SETRANGEMIN, FALSE, 5);
794 r = SendMessageA(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
795 expect(5, r);
796
797 /* test TBM_GETRANGEMAX */
798 r = SendMessageA(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
799 expect(10, r);
800
801 /* test TBM_GETRANGEMIN */
802 r = SendMessageA(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
803 expect(5, r);
804
806 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_range_test_seq, "parent range test sequence", TRUE);
807
808 /* TBM_SETRANGE updates thumb visual position (rectangle) if needed */
809 r = SendMessageA(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(-10, 0));
810 ok(r == 0, "got %d\n", r);
811 SendMessageA(hWndTrackbar, TBM_SETPOS, TRUE, 0);
812
813 RedrawWindow(hWndTrackbar, NULL, 0, RDW_UPDATENOW);
814 SendMessageA(hWndTrackbar, TBM_GETTHUMBRECT, 0, (LPARAM)&rect1);
815
816 r = SendMessageA(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(-10, 10));
817 ok(r == 0, "got %d\n", r);
818 RedrawWindow(hWndTrackbar, NULL, 0, RDW_UPDATENOW);
819
820 SendMessageA(hWndTrackbar, TBM_GETTHUMBRECT, 0, (LPARAM)&rect2);
821 ok(!EqualRect(&rect1, &rect2), "thumb rectangle not updated\n");
822
823 /* change range back, don't force repaint */
824 r = SendMessageA(hWndTrackbar, TBM_SETRANGE, FALSE, MAKELONG(-10, 0));
825 ok(r == 0, "got %d\n", r);
826
827 SendMessageA(hWndTrackbar, TBM_GETTHUMBRECT, 0, (LPARAM)&rect1);
828 ok(EqualRect(&rect1, &rect2), "thumb rectangle not updated\n");
829
830 /* test position update on range change */
831
832 /* set to [20, 50], position at 30, reduce range to [20,25] */
833 SendMessageA(hWndTrackbar, TBM_SETRANGEMIN, FALSE, 20);
834 SendMessageA(hWndTrackbar, TBM_SETRANGEMAX, FALSE, 50);
835 SendMessageA(hWndTrackbar, TBM_SETPOS, FALSE, 30);
836 SendMessageA(hWndTrackbar, TBM_SETRANGEMAX, FALSE, 25);
837 r = SendMessageA(hWndTrackbar, TBM_GETPOS, 0, 0);
838 ok(r == 25, "Unexpected position %d\n", r);
839
840 /* set to [20, 50], position at 30, flip max to 10 */
841 SendMessageA(hWndTrackbar, TBM_SETRANGEMIN, FALSE, 20);
842 SendMessageA(hWndTrackbar, TBM_SETRANGEMAX, FALSE, 50);
843 SendMessageA(hWndTrackbar, TBM_SETPOS, FALSE, 30);
844 SendMessageA(hWndTrackbar, TBM_SETRANGEMAX, FALSE, 10);
845 r = SendMessageA(hWndTrackbar, TBM_GETPOS, 0, 0);
846 ok(r == 20, "Unexpected position %d\n", r);
847
848 /* set to [20, 50], position at 30, flip min to 70 */
849 SendMessageA(hWndTrackbar, TBM_SETRANGEMIN, FALSE, 20);
850 SendMessageA(hWndTrackbar, TBM_SETRANGEMAX, FALSE, 50);
851 SendMessageA(hWndTrackbar, TBM_SETPOS, FALSE, 30);
852 SendMessageA(hWndTrackbar, TBM_SETRANGEMIN, FALSE, 70);
853 r = SendMessageA(hWndTrackbar, TBM_GETPOS, 0, 0);
854 ok(r == 70, "Unexpected position %d\n", r);
855
856 DestroyWindow(hWndTrackbar);
857}
858
859static void test_selection(void)
860{
861 HWND hWndTrackbar;
862 int r;
863
864 hWndTrackbar = create_trackbar(defaultstyle, hWndParent);
865 ok(hWndTrackbar != NULL, "Expected non NULL value\n");
866
867 SendMessageA(hWndTrackbar, TBM_SETRANGEMIN, FALSE, 5);
868 SendMessageA(hWndTrackbar, TBM_SETRANGEMAX, FALSE, 10);
869
871
872 /* test TBM_SETSEL */
873 SendMessageA(hWndTrackbar, TBM_SETSEL, TRUE, MAKELONG(0,10));
874 r = SendMessageA(hWndTrackbar, TBM_GETSELEND, 0,0);
875 expect(10, r);
876 r = SendMessageA(hWndTrackbar, TBM_GETSELSTART, 0,0);
877 expect(5, r);
878 SendMessageA(hWndTrackbar, TBM_SETSEL, TRUE, MAKELONG(5, 20));
879 r = SendMessageA(hWndTrackbar, TBM_GETSELEND, 0,0);
880 expect(10, r);
881 r = SendMessageA(hWndTrackbar, TBM_GETSELSTART, 0,0);
882 expect(5, r);
883 SendMessageA(hWndTrackbar, TBM_SETSEL, FALSE, MAKELONG(5, 10));
884 r = SendMessageA(hWndTrackbar, TBM_GETSELEND, 0,0);
885 expect(10, r);
886 r = SendMessageA(hWndTrackbar, TBM_GETSELSTART, 0,0);
887 expect(5, r);
888
889 /* test TBM_SETSELEND */
890 SendMessageA(hWndTrackbar, TBM_SETSELEND, TRUE, 10);
891 r = SendMessageA(hWndTrackbar, TBM_GETSELEND, 0,0);
892 expect(10, r);
893 SendMessageA(hWndTrackbar, TBM_SETSELEND, TRUE, 20);
894 r = SendMessageA(hWndTrackbar, TBM_GETSELEND, 0,0);
895 expect(10, r);
896 SendMessageA(hWndTrackbar, TBM_SETSELEND, TRUE, 4);
897 r = SendMessageA(hWndTrackbar, TBM_GETSELEND, 0,0);
898 expect(4, r);
899 SendMessageA(hWndTrackbar, TBM_SETSELEND, FALSE, 2);
900 r = SendMessageA(hWndTrackbar, TBM_GETSELEND, 0,0);
901 expect(2, r);
902
903 /* test TBM_GETSELEND */
904 r = SendMessageA(hWndTrackbar, TBM_GETSELEND, 0,0);
905 expect(2, r);
906
907 /* testing TBM_SETSELSTART */
908 SendMessageA(hWndTrackbar, TBM_SETSELSTART, TRUE, 5);
909 r = SendMessageA(hWndTrackbar, TBM_GETSELSTART, 0,0);
910 expect(5, r);
911 SendMessageA(hWndTrackbar, TBM_SETSELSTART, TRUE, 0);
912 r = SendMessageA(hWndTrackbar, TBM_GETSELSTART, 0,0);
913 expect(5, r);
914 SendMessageA(hWndTrackbar, TBM_SETSELSTART, TRUE, 20);
915 r = SendMessageA(hWndTrackbar, TBM_GETSELSTART, 0,0);
916 expect(20, r);
917 SendMessageA(hWndTrackbar, TBM_SETSELSTART, FALSE, 8);
918 r = SendMessageA(hWndTrackbar, TBM_GETSELSTART, 0,0);
919 expect(8, r);
920
921 /* test TBM_GETSELSTART */
922 r = SendMessageA(hWndTrackbar, TBM_GETSELSTART, 0,0);
923 expect(8, r);
924
925 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, selection_test_seq, "selection test sequence", TRUE);
926 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_selection_test_seq, "parent selection test sequence", TRUE);
927
928 DestroyWindow(hWndTrackbar);
929}
930
931static void test_thumb_length(void)
932{
933 HWND hWndTrackbar;
934 int r, r2;
935
936 hWndTrackbar = create_trackbar(defaultstyle, hWndParent);
937 ok(hWndTrackbar != NULL, "Expected non NULL value\n");
938
940
941 /* testing TBM_SETTHUMBLENGTH */
942 SendMessageA(hWndTrackbar, TBM_SETTHUMBLENGTH, 15, 0);
943 r = SendMessageA(hWndTrackbar, TBM_GETTHUMBLENGTH, 0,0);
944 expect(15, r);
945 SendMessageA(hWndTrackbar, TBM_SETTHUMBLENGTH, 20, 0);
946 r = SendMessageA(hWndTrackbar, TBM_GETTHUMBLENGTH, 0,0);
947 expect(20, r);
948
949 /* test TBM_GETTHUMBLENGTH */
950 r = SendMessageA(hWndTrackbar, TBM_GETTHUMBLENGTH, 0,0);
951 expect(20, r);
952
953 r = SendMessageA(hWndTrackbar, WM_SIZE, 0,0);
954 expect(0, r);
955 r = SendMessageA(hWndTrackbar, TBM_GETTHUMBLENGTH, 0,0);
956 expect(20, r);
957 r = SendMessageA(hWndTrackbar, WM_SIZE, 0, MAKELPARAM(50, 50) );
958 expect(0, r);
959 r = SendMessageA(hWndTrackbar, TBM_GETTHUMBLENGTH, 0,0);
960 expect(20, r);
961
962 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, thumb_length_test_seq, "thumb length test sequence", TRUE);
963 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_thumb_length_test_seq, "parent thumb length test sequence", TRUE);
964
965 DestroyWindow(hWndTrackbar);
966
967 /* Fixed thumb length does not depend on window size. */
968 hWndTrackbar = CreateWindowA(TRACKBAR_CLASSA, "Trackbar Control", WS_VISIBLE | TBS_ENABLESELRANGE
970
971 r = SendMessageA(hWndTrackbar, TBM_GETTHUMBLENGTH, 0, 0);
972
973 DestroyWindow(hWndTrackbar);
974
975 hWndTrackbar = CreateWindowA(TRACKBAR_CLASSA, "Trackbar Control", WS_VISIBLE | TBS_ENABLESELRANGE
977
978 r2 = SendMessageA(hWndTrackbar, TBM_GETTHUMBLENGTH, 0, 0);
979 ok(r2 == r, "Unexpected thumb length %d.\n", r);
980
981 DestroyWindow(hWndTrackbar);
982}
983
984static void test_tic_settings(void)
985{
986 HWND hWndTrackbar;
987 int r, i;
988
989 hWndTrackbar = create_trackbar(defaultstyle, hWndParent);
990 ok(hWndTrackbar != NULL, "Expected non NULL value\n");
991
992 SendMessageA(hWndTrackbar, TBM_SETRANGEMIN, FALSE, 5);
993 SendMessageA(hWndTrackbar, TBM_SETRANGEMAX, FALSE, 10);
994
995 /* testing TBM_SETTIC */
996 /* Set tics at 5 and 10 */
997 /* 0 and 20 are out of range and should not be set */
998 r = SendMessageA(hWndTrackbar, TBM_GETRANGEMAX, 0, 0);
999 expect(10, r);
1000 r = SendMessageA(hWndTrackbar, TBM_GETRANGEMIN, 0, 0);
1001 expect(5, r);
1002
1004 r = SendMessageA(hWndTrackbar, TBM_SETTIC, 0, 0);
1005 ok(r == FALSE, "Expected FALSE, got %d\n", r);
1006 r = SendMessageA(hWndTrackbar, TBM_SETTIC, 0, 5);
1007 ok(r == TRUE, "Expected TRUE, got %d\n", r);
1008 r = SendMessageA(hWndTrackbar, TBM_SETTIC, 0, 10);
1009 ok(r == TRUE, "Expected TRUE, got %d\n", r);
1010
1011 r = SendMessageA(hWndTrackbar, TBM_SETTIC, 0, 20);
1012 ok(r == FALSE, "Expected FALSE, got %d\n", r);
1013
1014 /* test TBM_SETTICFREQ */
1015 SendMessageA(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(0, 10));
1016 SendMessageA(hWndTrackbar, TBM_SETTICFREQ, 2, 0);
1017 r = SendMessageA(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
1018 expect(6, r);
1019 SendMessageA(hWndTrackbar, TBM_SETTICFREQ, 5, 0);
1020 r = SendMessageA(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
1021 expect(3, r);
1022 SendMessageA(hWndTrackbar, TBM_SETTICFREQ, 15, 0);
1023 r = SendMessageA(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
1024 expect(2, r);
1025
1026 /* test TBM_GETNUMTICS */
1027 /* since TIC FREQ is 15, there should be only 2 tics now */
1028 r = SendMessageA(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
1029 expect(2, r);
1030
1031 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, tic_settings_test_seq, "tic settings test sequence", TRUE);
1032 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_tic_settings_test_seq, "parent tic settings test sequence", TRUE);
1033
1034 /* range [0,0], freq = 1 */
1035 SendMessageA(hWndTrackbar, TBM_SETRANGEMAX, TRUE, 0);
1036 SendMessageA(hWndTrackbar, TBM_SETRANGEMIN, TRUE, 0);
1037 SendMessageA(hWndTrackbar, TBM_SETTICFREQ, 1, 0);
1038 r = SendMessageA(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
1039 expect(2, r);
1040 /* range [0,1], freq = 1 */
1041 SendMessageA(hWndTrackbar, TBM_SETRANGEMAX, TRUE, 1);
1042 SendMessageA(hWndTrackbar, TBM_SETRANGEMIN, TRUE, 0);
1043 SendMessageA(hWndTrackbar, TBM_SETTICFREQ, 1, 0);
1044 r = SendMessageA(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
1045 expect(2, r);
1046 /* range [0,2], freq = 1 */
1047 SendMessageA(hWndTrackbar, TBM_SETRANGEMAX, TRUE, 2);
1048 SendMessageA(hWndTrackbar, TBM_SETRANGEMIN, TRUE, 0);
1049 SendMessageA(hWndTrackbar, TBM_SETTICFREQ, 1, 0);
1050 r = SendMessageA(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
1051 expect(3, r);
1052
1053 DestroyWindow(hWndTrackbar);
1054
1055 /* Test to show that TBM_SETTICFREQ updates thumb */
1056 for (i = 0; i < 2; i++)
1057 {
1058 DWORD style = i ? defaultstyle : defaultstyle & ~TBS_AUTOTICKS;
1059 RECT rect, rect1;
1060 WNDPROC oldproc;
1061
1062 hWndTrackbar = create_trackbar2(style, hWndParent);
1063 ok(hWndTrackbar != NULL, "Expected non NULL value\n");
1064
1066 SetWindowLongPtrA(hWndTrackbar, GWLP_USERDATA, (LONG_PTR)oldproc);
1067
1068 SendMessageA(hWndTrackbar, TBM_GETTHUMBRECT, 0, (LPARAM)&rect);
1069 SendMessageA(hWndTrackbar, TBM_SETPOS, FALSE, 0);
1070 SendMessageA(hWndTrackbar, TBM_GETTHUMBRECT, 0, (LPARAM)&rect1);
1071 ok(EqualRect(&rect, &rect1), "Unexpected thumb rectangle %s, previous %s\n",
1073
1074 SendMessageA(hWndTrackbar, TBM_GETTHUMBRECT, 0, (LPARAM)&rect);
1075 SendMessageA(hWndTrackbar, TBM_SETRANGE, FALSE, MAKELONG(-100, 100));
1076 SendMessageA(hWndTrackbar, TBM_GETTHUMBRECT, 0, (LPARAM)&rect1);
1077 ok(EqualRect(&rect, &rect1), "Unexpected thumb rectangle %s, previous %s\n",
1079 /* Old position is also 0, but thumb position will be different after range change */
1080 SendMessageA(hWndTrackbar, TBM_GETTHUMBRECT, 0, (LPARAM)&rect);
1081 SendMessageA(hWndTrackbar, TBM_SETPOS, TRUE, 0);
1082 SendMessageA(hWndTrackbar, TBM_GETTHUMBRECT, 0, (LPARAM)&rect1);
1083 ok(EqualRect(&rect, &rect1), "Unexpected thumb rectangle %s, previous %s\n",
1085 /* Previous frequency is also 1, yet thumb is updated */
1086 SendMessageA(hWndTrackbar, TBM_GETTHUMBRECT, 0, (LPARAM)&rect);
1087 SendMessageA(hWndTrackbar, TBM_SETTICFREQ, 1, 0);
1088 SendMessageA(hWndTrackbar, TBM_GETTHUMBRECT, 0, (LPARAM)&rect1);
1089 ok(!EqualRect(&rect, &rect1), "Unexpected thumb rectangle %s, previous %s\n",
1091
1092 SetWindowLongPtrA(hWndTrackbar, GWLP_WNDPROC, (LONG_PTR)oldproc);
1093
1094 DestroyWindow(hWndTrackbar);
1095 }
1096}
1097
1098static void test_tic_placement(void)
1099{
1100 HWND hWndTrackbar;
1101 int r;
1102 DWORD *rPTics;
1103 DWORD numtics;
1104
1105 hWndTrackbar = create_trackbar(defaultstyle, hWndParent);
1106 ok(hWndTrackbar != NULL, "Expected non NULL value\n");
1107
1108 SendMessageA(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(1, 6));
1109 SendMessageA(hWndTrackbar, TBM_SETTICFREQ, 1, 0);
1110
1111 numtics = SendMessageA(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
1112 ok(numtics == 6, "Expected 6, got %d\n", numtics);
1113
1115 /* test TBM_GETPTICS */
1116 rPTics = (DWORD *) SendMessageA(hWndTrackbar, TBM_GETPTICS, 0,0);
1117 expect(2, rPTics[0]);
1118 expect(3, rPTics[1]);
1119 expect(4, rPTics[2]);
1120 expect(5, rPTics[3]);
1121
1122 /* test TBM_GETTIC */
1123 r = SendMessageA(hWndTrackbar, TBM_GETTIC, 0,0);
1124 expect(2, r);
1125 r = SendMessageA(hWndTrackbar, TBM_GETTIC, 2,0);
1126 expect(4, r);
1127 r = SendMessageA(hWndTrackbar, TBM_GETTIC, 4,0);
1128 expect(-1, r);
1129
1130 /* test TBM_GETTICPIC */
1131 r = SendMessageA(hWndTrackbar, TBM_GETTICPOS, 0, 0);
1132 ok(r > 0, "Expected r > 0, got %d\n", r);
1133 r = SendMessageA(hWndTrackbar, TBM_GETTICPOS, 2, 0);
1134 ok(r > 0, "Expected r > 0, got %d\n", r);
1135
1136 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, tic_placement_test_seq, "get tic placement test sequence", FALSE);
1137 ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq, "parent get tic placement test sequence", FALSE);
1138
1139 DestroyWindow(hWndTrackbar);
1140}
1141
1142static void test_tool_tips(void)
1143{
1144 HWND hWndTooltip, hWndTrackbar;
1145 HWND rTest;
1146 int r;
1147
1148 hWndTrackbar = create_trackbar(defaultstyle, hWndParent);
1149 ok(hWndTrackbar != NULL, "Expected non NULL value\n");
1150
1152
1153 /* testing TBM_SETTIPSIDE */
1154 r = SendMessageA(hWndTrackbar, TBM_SETTIPSIDE, TBTS_TOP, 0);
1155 expect(TBTS_TOP, r);
1156 r = SendMessageA(hWndTrackbar, TBM_SETTIPSIDE, TBTS_LEFT, 0);
1157 expect(TBTS_TOP, r);
1158 r = SendMessageA(hWndTrackbar, TBM_SETTIPSIDE, TBTS_BOTTOM, 0);
1159 expect(TBTS_LEFT, r);
1160 r = SendMessageA(hWndTrackbar, TBM_SETTIPSIDE, TBTS_RIGHT, 0);
1162
1163 /* testing TBM_SETTOOLTIPS */
1166 NULL, NULL, NULL, NULL);
1167
1168 ok(hWndTooltip != NULL, "Expected non NULL value\n");
1169 if (hWndTooltip != NULL){
1170 SendMessageA(hWndTrackbar, TBM_SETTOOLTIPS, (LPARAM) hWndTooltip, 0);
1171 rTest = (HWND) SendMessageA(hWndTrackbar, TBM_GETTOOLTIPS, 0,0);
1172 ok(rTest == hWndTooltip, "Expected hWndToolTip, got\n");
1173 SendMessageA(hWndTrackbar, TBM_SETTOOLTIPS, 0, 0);
1174 rTest = (HWND) SendMessageA(hWndTrackbar, TBM_GETTOOLTIPS, 0,0);
1175 ok(rTest == NULL, "Expected NULL\n");
1176 SendMessageA(hWndTrackbar, TBM_SETTOOLTIPS, (LPARAM) hWndTooltip, 5);
1177 rTest = (HWND) SendMessageA(hWndTrackbar, TBM_GETTOOLTIPS, 0,0);
1178 ok(rTest == hWndTooltip, "Expected hWndTooltip, got\n");
1179 } else
1180 skip("tool tip control not present?\n");
1181
1182 /* test TBM_GETTOOLTIPS */
1183 rTest = (HWND) SendMessageA(hWndTrackbar, TBM_GETTOOLTIPS, 0,0);
1184 ok(rTest == hWndTooltip, "Expected hWndTooltip\n");
1185
1186 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, tool_tips_test_seq, "tool tips test sequence", FALSE);
1187 ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq, "parent tool tips test sequence", FALSE);
1188
1189 DestroyWindow(hWndTrackbar);
1190}
1191
1192
1193static void test_unicode(void)
1194{
1195 HWND hWndTrackbar;
1196 int r;
1197
1198 hWndTrackbar = create_trackbar(defaultstyle, hWndParent);
1199 ok(hWndTrackbar != NULL, "Expected non NULL value\n");
1200
1202
1203 /* testing TBM_SETUNICODEFORMAT */
1204 r = SendMessageA(hWndTrackbar, TBM_SETUNICODEFORMAT, TRUE, 0);
1205 ok(r == FALSE, "Expected FALSE, got %d\n",r);
1206 r = SendMessageA(hWndTrackbar, TBM_SETUNICODEFORMAT, FALSE, 0);
1207 ok(r == TRUE, "Expected TRUE, got %d\n",r);
1208
1209 /* test TBM_GETUNICODEFORMAT */
1210 r = SendMessageA(hWndTrackbar, TBM_GETUNICODEFORMAT, 0,0);
1211 ok(r == FALSE, "Expected FALSE, got %d\n",r);
1212
1213 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, unicode_test_seq, "unicode test sequence", FALSE);
1214 ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq, "parent unicode test sequence", FALSE);
1215
1216 DestroyWindow(hWndTrackbar);
1217}
1218
1219static void test_ignore_selection(void)
1220{
1221 HWND hWndTrackbar;
1222 int r;
1223
1224 hWndTrackbar = create_trackbar(0, hWndParent);
1225 ok(hWndTrackbar != NULL, "Expected non NULL value\n");
1226
1228 /* test TBM_SETSEL ensure that it is ignored */
1229 SendMessageA(hWndTrackbar, TBM_SETSEL, TRUE, MAKELONG(0,10));
1230 r = SendMessageA(hWndTrackbar, TBM_GETSELEND, 0,0);
1231 expect(0, r);
1232 r = SendMessageA(hWndTrackbar, TBM_GETSELSTART, 0,0);
1233 expect(0, r);
1234 SendMessageA(hWndTrackbar, TBM_SETSEL, FALSE, MAKELONG(0,10));
1235 r = SendMessageA(hWndTrackbar, TBM_GETSELEND, 0,0);
1236 expect(0, r);
1237 r = SendMessageA(hWndTrackbar, TBM_GETSELSTART, 0,0);
1238 expect(0, r);
1239
1240 /* test TBM_SETSELEND, ensure that it is ignored */
1241 SendMessageA(hWndTrackbar, TBM_SETSELEND, TRUE, 0);
1242 r = SendMessageA(hWndTrackbar, TBM_GETSELEND, 0,0);
1243 expect(0, r);
1244 SendMessageA(hWndTrackbar, TBM_SETSELEND, TRUE, 10);
1245 r = SendMessageA(hWndTrackbar, TBM_GETSELEND, 0,0);
1246 expect(0,r);
1247 SendMessageA(hWndTrackbar, TBM_SETSELEND, FALSE, 0);
1248 r = SendMessageA(hWndTrackbar, TBM_GETSELEND, 0,0);
1249 expect(0, r);
1250
1251 /* test TBM_SETSELSTART, ensure that it is ignored */
1252 SendMessageA(hWndTrackbar, TBM_SETSELSTART, TRUE, 0);
1253 r = SendMessageA(hWndTrackbar, TBM_GETSELSTART, 0,0);
1254 expect(0, r);
1255 SendMessageA(hWndTrackbar, TBM_SETSELSTART, TRUE, 10);
1256 r = SendMessageA(hWndTrackbar, TBM_GETSELSTART, 0,0);
1257 expect(0,r);
1258 SendMessageA(hWndTrackbar, TBM_SETSELSTART, FALSE, 0);
1259 r = SendMessageA(hWndTrackbar, TBM_GETSELSTART, 0,0);
1260 expect(0, r);
1261
1262 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, ignore_selection_test_seq, "ignore selection setting test sequence", FALSE);
1263 ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq, "parent ignore selection setting test sequence", FALSE);
1264
1265 DestroyWindow(hWndTrackbar);
1266}
1267
1268static void test_initial_state(void)
1269{
1270 HWND hWnd;
1271 int ret;
1272
1274
1276 expect(2, ret);
1277 ret = SendMessageA(hWnd, TBM_GETTIC, 0, 0);
1278 expect(-1, ret);
1280 expect(-1, ret);
1282 expect(0, ret);
1284 expect(100, ret);
1285
1287 expect(0, ret);
1288
1290 expect(2, ret);
1291
1293 expect(0, ret);
1294
1296 expect(2, ret);
1297
1299}
1300
1301static void test_TBS_AUTOTICKS(void)
1302{
1303 HWND hWnd;
1304 int ret;
1305
1307
1309 expect(2, ret);
1310 ret = SendMessageA(hWnd, TBM_GETTIC, 0, 0);
1311 expect(-1, ret);
1313 expect(-1, ret);
1315 expect(0, ret);
1317 expect(100, ret);
1318
1319 /* TBM_SETRANGEMAX rebuilds tics */
1321 expect(0, ret);
1323 expect(201, ret);
1324
1325 /* TBM_SETRANGEMIN rebuilds tics */
1327 expect(0, ret);
1329 expect(0, ret);
1331 expect(91, ret);
1332
1334 expect(0, ret);
1335
1336 /* TBM_SETRANGE rebuilds tics */
1338 expect(0, ret);
1340 expect(191, ret);
1341
1343}
1344
1345static void test_create(void)
1346{
1347 HWND hWndTrackbar;
1348
1350
1351 hWndTrackbar = create_trackbar(defaultstyle, hWndParent);
1352 ok(hWndTrackbar != NULL, "Expected non NULL value\n");
1353 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, empty_seq, "create Trackbar Window", FALSE);
1355
1356 DestroyWindow(hWndTrackbar);
1357
1358 /* no style bits */
1360 hWndTrackbar = create_trackbar(0, hWndParent);
1361 ok(hWndTrackbar != NULL, "Expected non NULL value\n");
1362 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_new_window_test_seq, "new trackbar window test sequence", TRUE);
1363 DestroyWindow(hWndTrackbar);
1364}
1365
1366START_TEST(trackbar)
1367{
1369 HANDLE ctxt;
1370
1371 LoadLibraryA("comctl32.dll");
1372
1374
1375 /* create parent window */
1377 ok(hWndParent != NULL, "Failed to create parent Window!\n");
1378
1379 if(!hWndParent){
1380 skip("parent window not present\n");
1381 return;
1382 }
1383
1384 test_create();
1388 test_position();
1389 test_range();
1395 test_unicode();
1399
1400 if (!load_v6_module(&cookie, &ctxt))
1401 return;
1402
1406 test_position();
1407 test_range();
1413 test_unicode();
1417
1418 unload_v6_module(cookie, ctxt);
1419
1421}
@ sent
Definition: SystemMenu.c:27
@ defwinproc
Definition: SystemMenu.c:32
@ lparam
Definition: SystemMenu.c:31
@ wparam
Definition: SystemMenu.c:30
@ optional
Definition: SystemMenu.c:34
#define add_message(msg)
Definition: SystemMenu.c:98
#define ok_sequence(exp, contx, todo)
Definition: SystemMenu.c:275
Arabic default style
Definition: afstyles.h:94
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define START_TEST(x)
Definition: atltest.h:75
static const char * wine_dbgstr_rect(const RECT *prc)
Definition: atltest.h:160
#define msg(x)
Definition: auth_time.c:54
HWND hWnd
Definition: settings.c:17
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
static void init_msg_sequences(struct msg_sequence **seq, int n)
Definition: msg.h:393
static void flush_sequences(struct msg_sequence **seq, int n)
Definition: msg.h:99
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
HANDLE HWND
Definition: compat.h:19
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
r parent
Definition: btrfs.c:3010
RECT rect2
Definition: edittest.c:51
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static void test_page_size(void)
Definition: trackbar.c:572
static struct msg_sequence * sequences[NUM_MSG_SEQUENCE]
Definition: trackbar.c:46
static void test_position(void)
Definition: trackbar.c:666
static HWND create_parent_window(void)
Definition: trackbar.c:431
static const struct message parent_buddy_window_test_seq[]
Definition: trackbar.c:96
static void test_trackbar_buddy(void)
Definition: trackbar.c:489
static BOOL register_parent_wnd_class(void)
Definition: trackbar.c:415
static void test_ignore_selection(void)
Definition: trackbar.c:1219
static const struct message parent_tic_settings_test_seq[]
Definition: trackbar.c:289
static void test_create(void)
Definition: trackbar.c:1345
static HWND create_trackbar2(DWORD style, HWND parent)
Definition: trackbar.c:478
static const struct message selection_test_seq[]
Definition: trackbar.c:210
static const struct message tic_settings_test_seq[]
Definition: trackbar.c:269
static void test_tic_settings(void)
Definition: trackbar.c:984
static void test_tool_tips(void)
Definition: trackbar.c:1142
static const struct message page_size_test_seq[]
Definition: trackbar.c:115
static void test_initial_state(void)
Definition: trackbar.c:1268
#define TRACKBAR_SEQ_INDEX
Definition: trackbar.c:31
static LRESULT WINAPI parent_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: trackbar.c:384
static const struct message parent_selection_test_seq[]
Definition: trackbar.c:249
static const struct message parent_thumb_length_test_seq[]
Definition: trackbar.c:318
#define NUM_MSG_SEQUENCE
Definition: trackbar.c:29
static const struct message range_test_seq[]
Definition: trackbar.c:150
static void test_TBS_AUTOTICKS(void)
Definition: trackbar.c:1301
static void test_range(void)
Definition: trackbar.c:739
static HWND create_trackbar(DWORD style, HWND parent)
Definition: trackbar.c:460
#define expect(expected, got)
Definition: trackbar.c:28
#define PARENT_SEQ_INDEX
Definition: trackbar.c:30
static const struct message tic_placement_test_seq[]
Definition: trackbar.c:330
static const struct message parent_new_window_test_seq[]
Definition: trackbar.c:67
static const struct message line_size_test_seq[]
Definition: trackbar.c:108
static const struct message position_test_seq[]
Definition: trackbar.c:122
static LRESULT WINAPI trackbar_no_wmpaint_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: trackbar.c:36
static const struct message parent_position_test_seq[]
Definition: trackbar.c:140
static void test_thumb_length(void)
Definition: trackbar.c:931
static const struct message thumb_length_test_seq[]
Definition: trackbar.c:301
static LRESULT WINAPI trackbar_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: trackbar.c:440
static const struct message unicode_test_seq[]
Definition: trackbar.c:355
static void test_selection(void)
Definition: trackbar.c:859
static const struct message parent_range_test_seq[]
Definition: trackbar.c:190
static void test_tic_placement(void)
Definition: trackbar.c:1098
static const struct message buddy_window_test_seq[]
Definition: trackbar.c:80
static HWND hWndParent
Definition: trackbar.c:34
static void test_line_size(void)
Definition: trackbar.c:545
static const struct message ignore_selection_test_seq[]
Definition: trackbar.c:362
static const struct message tool_tips_test_seq[]
Definition: trackbar.c:340
static const struct message parent_create_trackbar_wnd_seq[]
Definition: trackbar.c:52
static const DWORD defaultstyle
Definition: trackbar.c:33
static const struct message empty_seq[]
Definition: trackbar.c:48
static void test_unicode(void)
Definition: trackbar.c:1193
static DNS_RECORDW r2
Definition: record.c:38
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
unsigned int UINT
Definition: ndis.h:50
#define PBT_APMRESUMESTANDBY
Definition: pbt.h:12
#define PBT_APMRESUMECRITICAL
Definition: pbt.h:10
#define WS_CAPTION
Definition: pedump.c:624
#define WS_MAXIMIZEBOX
Definition: pedump.c:632
#define WS_SYSMENU
Definition: pedump.c:629
#define WS_VISIBLE
Definition: pedump.c:620
#define WS_EX_TOPMOST
Definition: pedump.c:647
long LONG
Definition: pedump.c:60
#define WS_MINIMIZEBOX
Definition: pedump.c:631
#define TBS_TOOLTIPS
Definition: commctrl.h:2032
#define TBM_GETBUDDY
Definition: commctrl.h:2074
#define TBM_GETSELSTART
Definition: commctrl.h:2052
#define TBS_FIXEDLENGTH
Definition: commctrl.h:2030
#define TBM_SETPAGESIZE
Definition: commctrl.h:2056
#define TBTS_RIGHT
Definition: commctrl.h:2071
#define TBTS_BOTTOM
Definition: commctrl.h:2070
#define TRACKBAR_CLASSA
Definition: commctrl.h:2015
#define TBM_SETTIC
Definition: commctrl.h:2040
#define TBM_SETSELSTART
Definition: commctrl.h:2047
#define TBM_GETPOS
Definition: commctrl.h:2036
#define TBM_GETSELEND
Definition: commctrl.h:2053
#define TBM_SETSELEND
Definition: commctrl.h:2048
#define TBM_SETTOOLTIPS
Definition: commctrl.h:2064
#define TBM_SETLINESIZE
Definition: commctrl.h:2058
#define TBM_GETTHUMBRECT
Definition: commctrl.h:2060
#define TBTS_LEFT
Definition: commctrl.h:2069
#define TBM_SETRANGEMIN
Definition: commctrl.h:2043
#define TBM_SETSEL
Definition: commctrl.h:2046
#define TOOLTIPS_CLASSA
Definition: commctrl.h:1708
#define TBM_GETLINESIZE
Definition: commctrl.h:2059
#define TBM_GETRANGEMAX
Definition: commctrl.h:2038
#define STATUSCLASSNAMEA
Definition: commctrl.h:1942
#define TBS_ENABLESELRANGE
Definition: commctrl.h:2029
#define TBM_SETRANGE
Definition: commctrl.h:2042
#define TBM_SETPOS
Definition: commctrl.h:2041
#define TBS_AUTOTICKS
Definition: commctrl.h:2020
#define TBM_GETPTICS
Definition: commctrl.h:2049
#define TBM_GETTIC
Definition: commctrl.h:2039
#define TBM_SETTICFREQ
Definition: commctrl.h:2055
#define TBM_GETNUMTICS
Definition: commctrl.h:2051
#define TBM_SETRANGEMAX
Definition: commctrl.h:2044
#define TBM_GETUNICODEFORMAT
Definition: commctrl.h:2076
#define TBM_SETTIPSIDE
Definition: commctrl.h:2066
#define TBTS_TOP
Definition: commctrl.h:2068
#define TBM_GETTICPOS
Definition: commctrl.h:2050
#define TBM_SETUNICODEFORMAT
Definition: commctrl.h:2075
#define TBM_GETRANGEMIN
Definition: commctrl.h:2037
#define TBM_SETTHUMBLENGTH
Definition: commctrl.h:2062
#define TBM_GETPAGESIZE
Definition: commctrl.h:2057
#define TBM_SETBUDDY
Definition: commctrl.h:2073
#define TBM_GETTOOLTIPS
Definition: commctrl.h:2065
#define TBM_GETTHUMBLENGTH
Definition: commctrl.h:2063
#define WM_NOTIFY
Definition: richedit.h:61
& rect
Definition: startmenu.cpp:1413
HBRUSH hbrBackground
Definition: winuser.h:3173
HICON hIcon
Definition: winuser.h:3171
HINSTANCE hInstance
Definition: winuser.h:3170
HCURSOR hCursor
Definition: winuser.h:3172
int cbWndExtra
Definition: winuser.h:3169
UINT style
Definition: winuser.h:3166
LPCSTR lpszMenuName
Definition: winuser.h:3174
LPCSTR lpszClassName
Definition: winuser.h:3175
WNDPROC lpfnWndProc
Definition: winuser.h:3167
int cbClsExtra
Definition: winuser.h:3168
Definition: cookie.c:34
Definition: tftpd.h:60
UINT message
Definition: SystemMenu.c:42
LONG left
Definition: windef.h:306
#define GWLP_WNDPROC
Definition: treelist.c:66
#define GWLP_USERDATA
Definition: treelist.c:63
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define MAKELONG(a, b)
Definition: typedefs.h:249
static BOOL load_v6_module(ULONG_PTR *pcookie, HANDLE *hCtx)
Definition: v6util.h:73
static void unload_v6_module(ULONG_PTR cookie, HANDLE hCtx)
Definition: v6util.h:65
int ret
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
UINT_PTR WPARAM
Definition: windef.h:207
#define WINAPI
Definition: msvc.h:6
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define WHITE_BRUSH
Definition: wingdi.h:902
#define WM_PAINT
Definition: winuser.h:1623
#define WM_ERASEBKGND
Definition: winuser.h:1628
#define WM_QUERYNEWPALETTE
Definition: winuser.h:1881
#define SetWindowLongPtrA
Definition: winuser.h:5357
#define WM_CTLCOLORSTATIC
Definition: winuser.h:1775
BOOL WINAPI RedrawWindow(_In_opt_ HWND, _In_opt_ LPCRECT, _In_opt_ HRGN, _In_ UINT)
#define MAKELPARAM(l, h)
Definition: winuser.h:4011
HWND WINAPI CreateWindowExA(_In_ DWORD dwExStyle, _In_opt_ LPCSTR lpClassName, _In_opt_ LPCSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
#define WM_IME_NOTIFY
Definition: winuser.h:1833
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_WINDOWPOSCHANGING
Definition: winuser.h:1664
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4318
#define WM_SIZE
Definition: winuser.h:1614
#define IDC_ARROW
Definition: winuser.h:687
#define WM_NCHITTEST
Definition: winuser.h:1689
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_SETFOCUS
Definition: winuser.h:1616
#define WM_GETTEXT
Definition: winuser.h:1621
#define RDW_UPDATENOW
Definition: winuser.h:1223
#define GetWindowLongPtrA
Definition: winuser.h:4831
#define WM_DEVICECHANGE
Definition: winuser.h:1814
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:628
#define WM_IME_SETCONTEXT
Definition: winuser.h:1832
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define WM_NCACTIVATE
Definition: winuser.h:1691
ATOM WINAPI RegisterClassA(_In_ CONST WNDCLASSA *)
#define VK_END
Definition: winuser.h:2225
BOOL WINAPI SetRectEmpty(_Out_ LPRECT)
#define CW_USEDEFAULT
Definition: winuser.h:225
#define WM_USER
Definition: winuser.h:1898
#define WM_KEYDOWN
Definition: winuser.h:1718
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2909
BOOL WINAPI DestroyWindow(_In_ HWND)
BOOL WINAPI EqualRect(_In_ LPCRECT, _In_ LPCRECT)
LRESULT WINAPI CallWindowProcA(_In_ WNDPROC, _In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
HCURSOR WINAPI LoadCursorA(_In_opt_ HINSTANCE, _In_ LPCSTR)
Definition: cursoricon.c:2142
#define WM_NCPAINT
Definition: winuser.h:1690
const char * LPCSTR
Definition: xmlstorage.h:183