1 /* Unit test suite for tab control.
3 * Copyright 2003 Vitaliy Margolen
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include "wine/test.h"
28 #define TAB_DEFAULT_WIDTH 96
29 #define TAB_PADDING_X 2
30 #define TAB_PADDING_Y 2
33 #define WAIT Sleep (1000)
34 #define REDRAW(hwnd) RedrawWindow (hwnd, NULL, 0, RDW_UPDATENOW)
35 #define trace_tab(str) trace(str)
39 #define trace_tab(str)
43 create_tabcontrol (DWORD style
)
48 handle
= CreateWindow (
51 WS_CLIPSIBLINGS
| WS_CLIPCHILDREN
| TCS_FOCUSNEVER
| style
,
57 SetWindowLong(handle
, GWL_STYLE
, WS_CLIPSIBLINGS
| WS_CLIPCHILDREN
| TCS_FOCUSNEVER
| style
);
59 tcNewTab
.mask
= TCIF_TEXT
| TCIF_IMAGE
;
60 tcNewTab
.pszText
= "Tab 1";
62 SendMessage (handle
, TCM_INSERTITEM
, 0, (LPARAM
) &tcNewTab
);
63 tcNewTab
.pszText
= "Wide Tab 2";
65 SendMessage (handle
, TCM_INSERTITEM
, 1, (LPARAM
) &tcNewTab
);
66 tcNewTab
.pszText
= "T 3";
68 SendMessage (handle
, TCM_INSERTITEM
, 2, (LPARAM
) &tcNewTab
);
71 ShowWindow (handle
, SW_SHOW
);
79 void CheckSize(HWND hwnd
, INT width
, INT height
)
83 r1
.left
=r1
.top
=r1
.right
=r1
.bottom
=0;
84 SendMessage (hwnd
, TCM_GETITEMRECT
, 0, (LPARAM
) &rTab
);
85 SendMessage (hwnd
, TCM_ADJUSTRECT
, FALSE
, (LPARAM
) &r1
);
86 /* trace ("Got (%ld,%ld)-(%ld,%ld)\n", rTab.left, rTab.top, rTab.right, rTab.bottom); */
87 trace (" (%ld,%ld)-(%ld,%ld)\n", r1
.left
, r1
.top
, r1
.right
, r1
.bottom
);
88 if ((width
>= 0) && (height
< 0))
89 ok (width
== rTab
.right
- rTab
.left
, "Expected [%d] got [%ld]\n", width
, rTab
.right
- rTab
.left
);
90 else if ((height
>= 0) && (width
< 0))
91 ok (height
== rTab
.bottom
- rTab
.top
, "Expected [%d] got [%ld]\n", height
, rTab
.bottom
- rTab
.top
);
93 ok ((width
== rTab
.right
- rTab
.left
) &&
94 (height
== rTab
.bottom
- rTab
.top
),
95 "Expected [%d,%d] got [%ld,%ld]\n", width
, height
, rTab
.right
- rTab
.left
, rTab
.bottom
- rTab
.top
);
98 void TabCheckSetSize(HWND hwnd
, INT SetWidth
, INT SetHeight
, INT ExpWidth
, INT ExpHeight
)
100 SendMessage (hwnd
, TCM_SETITEMSIZE
, 0,
101 (LPARAM
) MAKELPARAM((SetWidth
>= 0) ? SetWidth
:0, (SetHeight
>= 0) ? SetHeight
:0));
103 CheckSize(hwnd
, ExpWidth
, ExpHeight
);
110 HIMAGELIST himl
= ImageList_Create(21, 21, ILC_COLOR
, 3, 4);
112 InitCommonControls();
115 hwTab
= create_tabcontrol(TCS_FIXEDWIDTH
);
117 trace_tab ("Testing TCS_FIXEDWIDTH tabs no icon...\n");
118 trace_tab (" default width...\n");
119 CheckSize(hwTab
, TAB_DEFAULT_WIDTH
, -1);
120 trace_tab (" set size...\n");
121 TabCheckSetSize(hwTab
, 50, 20, 50, 20);
123 trace_tab (" min size...\n");
124 TabCheckSetSize(hwTab
, 0, 1, 0, 1);
127 SendMessage(hwTab
, TCM_SETIMAGELIST
, 0, (LPARAM
)himl
);
129 trace_tab ("Testing TCS_FIXEDWIDTH tabs with icon...\n");
130 trace_tab (" set size > icon...\n");
131 TabCheckSetSize(hwTab
, 50, 30, 50, 30);
132 trace_tab (" set size < icon...\n");
133 TabCheckSetSize(hwTab
, 20, 20, 25, 20);
134 trace_tab (" min size...\n");
135 TabCheckSetSize(hwTab
, 0, 1, 25, 1);
137 DestroyWindow (hwTab
);
139 trace_tab ("Testing TCS_FIXEDWIDTH buttons no icon...\n");
140 hwTab
= create_tabcontrol(TCS_FIXEDWIDTH
| TCS_BUTTONS
);
142 trace_tab (" default width...\n");
143 CheckSize(hwTab
, TAB_DEFAULT_WIDTH
, -1);
144 trace_tab (" set size 1...\n");
145 TabCheckSetSize(hwTab
, 20, 20, 20, 20);
146 trace_tab (" set size 2...\n");
147 TabCheckSetSize(hwTab
, 10, 50, 10, 50);
148 trace_tab (" min size...\n");
149 TabCheckSetSize(hwTab
, 0, 1, 0, 1);
151 SendMessage(hwTab
, TCM_SETIMAGELIST
, 0, (LPARAM
)himl
);
153 trace_tab ("Testing TCS_FIXEDWIDTH buttons with icon...\n");
154 trace_tab (" set size > icon...\n");
155 TabCheckSetSize(hwTab
, 50, 30, 50, 30);
156 trace_tab (" set size < icon...\n");
157 TabCheckSetSize(hwTab
, 20, 20, 25, 20);
158 trace_tab (" min size...\n");
159 TabCheckSetSize(hwTab
, 0, 1, 25, 1);
160 trace_tab (" Add padding...\n");
161 SendMessage(hwTab
, TCM_SETPADDING
, 0, MAKELPARAM(4,4));
162 trace_tab (" min size...\n");
163 TabCheckSetSize(hwTab
, 0, 1, 25, 1);
165 DestroyWindow (hwTab
);
167 hwTab
= create_tabcontrol(TCS_FIXEDWIDTH
| TCS_BOTTOM
);
168 trace_tab ("Testing TCS_FIXEDWIDTH | TCS_BOTTOM tabs no icon...\n");
170 trace_tab (" default width...\n");
171 CheckSize(hwTab
, TAB_DEFAULT_WIDTH
, -1);
172 trace_tab (" set size 1...\n");
173 TabCheckSetSize(hwTab
, 20, 20, 20, 20);
174 trace_tab (" set size 2...\n");
175 TabCheckSetSize(hwTab
, 10, 50, 10, 50);
176 trace_tab (" min size...\n");
177 TabCheckSetSize(hwTab
, 0, 1, 0, 1);
179 SendMessage(hwTab
, TCM_SETIMAGELIST
, 0, (LPARAM
)himl
);
181 trace_tab ("Testing TCS_FIXEDWIDTH | TCS_BOTTOM tabs with icon...\n");
182 trace_tab (" set size > icon...\n");
183 TabCheckSetSize(hwTab
, 50, 30, 50, 30);
184 trace_tab (" set size < icon...\n");
185 TabCheckSetSize(hwTab
, 20, 20, 25, 20);
186 trace_tab (" min size...\n");
187 TabCheckSetSize(hwTab
, 0, 1, 25, 1);
188 trace_tab (" Add padding...\n");
189 SendMessage(hwTab
, TCM_SETPADDING
, 0, MAKELPARAM(4,4));
190 trace_tab (" min size...\n");
191 TabCheckSetSize(hwTab
, 0, 1, 25, 1);
193 DestroyWindow (hwTab
);
196 ImageList_Destroy(himl
);