TESTING -- override pthreads to fix gstreamer v5
[wine/multimedia.git] / dlls / comctl32 / tests / rebar.c
bloba01629856094acb6beb1aa5e80a7ef37f1c86d33
1 /* Unit tests for rebar.
3 * Copyright 2007 Mikolaj Zalewski
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 /* make sure the structures work with a comctl32 v5.x */
21 #define _WIN32_WINNT 0x500
22 #define _WIN32_IE 0x500
24 #include <assert.h>
25 #include <stdarg.h>
27 #include <windows.h>
28 #include <commctrl.h>
29 #include <uxtheme.h>
31 #include "wine/test.h"
33 static RECT height_change_notify_rect;
34 static HWND hMainWnd;
35 static int system_font_height;
38 #define check_rect(name, val, exp) ok(val.top == exp.top && val.bottom == exp.bottom && \
39 val.left == exp.left && val.right == exp.right, "invalid rect (" name ") (%d,%d) (%d,%d) - expected (%d,%d) (%d,%d)\n", \
40 val.left, val.top, val.right, val.bottom, exp.left, exp.top, exp.right, exp.bottom);
42 #define check_rect_no_top(name, val, exp) { \
43 ok((val.bottom - val.top == exp.bottom - exp.top) && \
44 val.left == exp.left && val.right == exp.right, "invalid rect (" name ") (%d,%d) (%d,%d) - expected (%d,%d) (%d,%d), ignoring top\n", \
45 val.left, val.top, val.right, val.bottom, exp.left, exp.top, exp.right, exp.bottom); \
48 #define compare(val, exp, format) ok((val) == (exp), #val " value " format " expected " format "\n", (val), (exp));
50 #define expect_eq(line, expr, value, type, format) { type ret = expr;\
51 ok((value) == ret, #expr " expected " format " got " format " from line %d\n", (value), (ret), line); }
53 static INT CALLBACK is_font_installed_proc(const LOGFONTA *elf, const TEXTMETRICA *ntm, DWORD type, LPARAM lParam)
55 return 0;
58 static BOOL is_font_installed(const char *name)
60 HDC hdc = GetDC(0);
61 BOOL ret = FALSE;
63 if(!EnumFontFamiliesA(hdc, name, is_font_installed_proc, 0))
64 ret = TRUE;
66 ReleaseDC(0, hdc);
67 return ret;
70 static void init_system_font_height(void) {
71 HDC hDC;
72 TEXTMETRICA tm;
74 hDC = CreateCompatibleDC(NULL);
75 GetTextMetricsA(hDC, &tm);
76 DeleteDC(NULL);
78 system_font_height = tm.tmHeight;
81 static HWND create_rebar_control(void)
83 HWND hwnd;
85 hwnd = CreateWindowA(REBARCLASSNAMEA, NULL, WS_CHILD | WS_VISIBLE, 0, 0, 0, 0,
86 hMainWnd, (HMENU)17, GetModuleHandleA(NULL), NULL);
87 ok(hwnd != NULL, "Failed to create Rebar\n");
89 SendMessageA(hwnd, WM_SETFONT, (WPARAM)GetStockObject(SYSTEM_FONT), 0);
91 return hwnd;
94 static HWND build_toolbar(int nr, HWND hParent)
96 TBBUTTON btns[8];
97 HWND hToolbar = CreateWindowExA(0, TOOLBARCLASSNAMEA, NULL, WS_CHILD | WS_VISIBLE | CCS_NORESIZE, 0, 0, 0, 0,
98 hParent, (HMENU)5, GetModuleHandleA(NULL), NULL);
99 int iBitmapId = 0;
100 int i;
102 ok(hToolbar != NULL, "Toolbar creation problem\n");
103 ok(SendMessageA(hToolbar, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0) == 0, "TB_BUTTONSTRUCTSIZE failed\n");
104 ok(SendMessageA(hToolbar, TB_AUTOSIZE, 0, 0) == 0, "TB_AUTOSIZE failed\n");
105 ok(SendMessageA(hToolbar, WM_SETFONT, (WPARAM)GetStockObject(SYSTEM_FONT), 0)==1, "WM_SETFONT\n");
107 for (i=0; i<5+nr; i++)
109 btns[i].iBitmap = i;
110 btns[i].idCommand = i;
111 btns[i].fsStyle = BTNS_BUTTON;
112 btns[i].fsState = TBSTATE_ENABLED;
113 btns[i].iString = 0;
116 switch (nr)
118 case 0: iBitmapId = IDB_HIST_SMALL_COLOR; break;
119 case 1: iBitmapId = IDB_VIEW_SMALL_COLOR; break;
120 case 2: iBitmapId = IDB_STD_SMALL_COLOR; break;
122 ok(SendMessageA(hToolbar, TB_LOADIMAGES, iBitmapId, (LPARAM)HINST_COMMCTRL) == 0, "TB_LOADIMAGES failed\n");
123 ok(SendMessageA(hToolbar, TB_ADDBUTTONSA, 5+nr, (LPARAM)btns), "TB_ADDBUTTONSA failed\n");
124 return hToolbar;
127 static int g_parent_measureitem;
129 static LRESULT CALLBACK parent_wndproc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
131 switch (msg)
133 case WM_NOTIFY:
135 NMHDR *lpnm = (NMHDR *)lParam;
136 if (lpnm->code == RBN_HEIGHTCHANGE)
137 GetClientRect(lpnm->hwndFrom, &height_change_notify_rect);
139 break;
140 case WM_MEASUREITEM:
141 g_parent_measureitem++;
142 break;
144 return DefWindowProcA(hWnd, msg, wParam, lParam);
147 #if 0 /* use this to generate more tests*/
149 static void dump_sizes(HWND hRebar)
151 SIZE sz;
152 RECT r;
153 int count;
154 int i, h;
156 GetClientRect(hRebar, &r);
157 count = SendMessageA(hRebar, RB_GETROWCOUNT, 0, 0);
158 printf(" { {%d, %d, %d, %d}, %d, %d, {", r.left, r.top, r.right, r.bottom,
159 SendMessageA(hRebar, RB_GETBARHEIGHT, 0, 0), count);
160 if (count == 0)
161 printf("0, ");
162 for (i = 0; i < count; i++) /* rows */
163 printf("%d, ", SendMessageA(hRebar, RB_GETROWHEIGHT, i, 0));
164 printf("}, ");
166 count = SendMessageA(hRebar, RB_GETBANDCOUNT, 0, 0);
167 printf("%d, {", count);
168 if (count == 0)
169 printf("{{0, 0, 0, 0}, 0, 0},");
170 for (i=0; i<count; i++)
172 REBARBANDINFOA rbi;
173 rbi.cbSize = REBARBANDINFOA_V6_SIZE;
174 rbi.fMask = RBBIM_SIZE | RBBIM_CHILDSIZE | RBBIM_STYLE;
175 ok(SendMessageA(hRebar, RB_GETBANDINFOA, i, (LPARAM)&rbi), "RB_GETBANDINFOA failed\n");
176 ok(SendMessageA(hRebar, RB_GETRECT, i, (LPARAM)&r), "RB_GETRECT failed\n");
177 printf("%s{ {%3d, %3d, %3d, %3d}, 0x%02x, %d}, ", (i%2==0 ? "\n " : ""), r.left, r.top, r.right, r.bottom,
178 rbi.fStyle, rbi.cx);
180 printf("\n }, },\n");
183 #define check_sizes() dump_sizes(hRebar);
184 #define check_sizes_todo(todomask) dump_sizes(hRebar);
186 #else
188 static int string_width(const CHAR *s) {
189 SIZE sz;
190 HDC hdc;
192 hdc = CreateCompatibleDC(NULL);
193 GetTextExtentPoint32A(hdc, s, strlen(s), &sz);
194 DeleteDC(hdc);
196 return sz.cx;
199 typedef struct {
200 RECT rc;
201 DWORD fStyle;
202 UINT cx;
203 } rbband_result_t;
205 typedef struct {
206 RECT rcClient;
207 int cyBarHeight;
208 int nRows;
209 int *cyRowHeights;
210 int nBands;
211 rbband_result_t *bands;
212 } rbsize_result_t;
214 static rbsize_result_t rbsize_init(int cleft, int ctop, int cright, int cbottom, int cyBarHeight, int nRows, int nBands)
216 rbsize_result_t ret;
218 SetRect(&ret.rcClient, cleft, ctop, cright, cbottom);
219 ret.cyBarHeight = cyBarHeight;
220 ret.nRows = 0;
221 ret.cyRowHeights = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, nRows*sizeof(int));
222 ret.nBands = 0;
223 ret.bands = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, nBands*sizeof(rbband_result_t));
225 return ret;
228 static void rbsize_add_row(rbsize_result_t *rbsr, int rowHeight) {
229 rbsr->cyRowHeights[rbsr->nRows] = rowHeight;
230 rbsr->nRows++;
233 static void rbsize_add_band(rbsize_result_t *rbsr, int left, int top, int right, int bottom, DWORD fStyle, UINT cx)
235 SetRect(&(rbsr->bands[rbsr->nBands].rc), left, top, right, bottom);
236 rbsr->bands[rbsr->nBands].fStyle = fStyle;
237 rbsr->bands[rbsr->nBands].cx = cx;
238 rbsr->nBands++;
241 static rbsize_result_t *rbsize_results;
243 #define rbsize_results_num 27
245 static void rbsize_results_init(void)
247 rbsize_results = HeapAlloc(GetProcessHeap(), 0, rbsize_results_num*sizeof(rbsize_result_t));
249 rbsize_results[0] = rbsize_init(0, 0, 672, 0, 0, 0, 0);
251 rbsize_results[1] = rbsize_init(0, 0, 672, 4, 4, 1, 1);
252 rbsize_add_row(&rbsize_results[1], 4);
253 rbsize_add_band(&rbsize_results[1], 0, 0, 672, 4, 0x00, 200);
255 rbsize_results[2] = rbsize_init(0, 0, 672, 4, 4, 1, 2);
256 rbsize_add_row(&rbsize_results[2], 4);
257 rbsize_add_band(&rbsize_results[2], 0, 0, 200, 4, 0x00, 200);
258 rbsize_add_band(&rbsize_results[2], 200, 0, 672, 4, 0x04, 200);
260 rbsize_results[3] = rbsize_init(0, 0, 672, 30, 30, 1, 3);
261 rbsize_add_row(&rbsize_results[3], 30);
262 rbsize_add_band(&rbsize_results[3], 0, 0, 200, 30, 0x00, 200);
263 rbsize_add_band(&rbsize_results[3], 200, 0, 400, 30, 0x04, 200);
264 rbsize_add_band(&rbsize_results[3], 400, 0, 672, 30, 0x00, 200);
266 rbsize_results[4] = rbsize_init(0, 0, 672, 34, 34, 1, 4);
267 rbsize_add_row(&rbsize_results[4], 34);
268 rbsize_add_band(&rbsize_results[4], 0, 0, 200, 34, 0x00, 200);
269 rbsize_add_band(&rbsize_results[4], 200, 0, 400, 34, 0x04, 200);
270 rbsize_add_band(&rbsize_results[4], 400, 0, 604, 34, 0x00, 200);
271 rbsize_add_band(&rbsize_results[4], 604, 0, 672, 34, 0x04, 68);
273 rbsize_results[5] = rbsize_init(0, 0, 672, 34, 34, 1, 4);
274 rbsize_add_row(&rbsize_results[5], 34);
275 rbsize_add_band(&rbsize_results[5], 0, 0, 200, 34, 0x00, 200);
276 rbsize_add_band(&rbsize_results[5], 200, 0, 400, 34, 0x04, 200);
277 rbsize_add_band(&rbsize_results[5], 400, 0, 604, 34, 0x00, 200);
278 rbsize_add_band(&rbsize_results[5], 604, 0, 672, 34, 0x04, 68);
280 rbsize_results[6] = rbsize_init(0, 0, 672, 34, 34, 1, 4);
281 rbsize_add_row(&rbsize_results[6], 34);
282 rbsize_add_band(&rbsize_results[6], 0, 0, 200, 34, 0x00, 200);
283 rbsize_add_band(&rbsize_results[6], 202, 0, 402, 34, 0x04, 200);
284 rbsize_add_band(&rbsize_results[6], 404, 0, 604, 34, 0x00, 200);
285 rbsize_add_band(&rbsize_results[6], 606, 0, 672, 34, 0x04, 66);
287 rbsize_results[7] = rbsize_init(0, 0, 672, 70, 70, 2, 5);
288 rbsize_add_row(&rbsize_results[7], 34);
289 rbsize_add_row(&rbsize_results[7], 34);
290 rbsize_add_band(&rbsize_results[7], 0, 0, 142, 34, 0x00, 200);
291 rbsize_add_band(&rbsize_results[7], 144, 0, 557, 34, 0x00, 200);
292 rbsize_add_band(&rbsize_results[7], 559, 0, 672, 34, 0x04, 200);
293 rbsize_add_band(&rbsize_results[7], 0, 36, 200, 70, 0x00, 200);
294 rbsize_add_band(&rbsize_results[7], 202, 36, 672, 70, 0x04, 66);
296 rbsize_results[8] = rbsize_init(0, 0, 672, 34, 34, 1, 5);
297 rbsize_add_row(&rbsize_results[8], 34);
298 rbsize_add_band(&rbsize_results[8], 0, 0, 167, 34, 0x00, 200);
299 rbsize_add_band(&rbsize_results[8], 169, 0, 582, 34, 0x00, 200);
300 rbsize_add_band(&rbsize_results[8], 559, 0, 759, 34, 0x08, 200);
301 rbsize_add_band(&rbsize_results[8], 584, 0, 627, 34, 0x00, 200);
302 rbsize_add_band(&rbsize_results[8], 629, 0, 672, 34, 0x04, 66);
304 rbsize_results[9] = rbsize_init(0, 0, 672, 34, 34, 1, 4);
305 rbsize_add_row(&rbsize_results[9], 34);
306 rbsize_add_band(&rbsize_results[9], 0, 0, 167, 34, 0x00, 200);
307 rbsize_add_band(&rbsize_results[9], 169, 0, 582, 34, 0x00, 200);
308 rbsize_add_band(&rbsize_results[9], 584, 0, 627, 34, 0x00, 200);
309 rbsize_add_band(&rbsize_results[9], 629, 0, 672, 34, 0x04, 66);
311 rbsize_results[10] = rbsize_init(0, 0, 672, 34, 34, 1, 3);
312 rbsize_add_row(&rbsize_results[10], 34);
313 rbsize_add_band(&rbsize_results[10], 0, 0, 413, 34, 0x00, 200);
314 rbsize_add_band(&rbsize_results[10], 415, 0, 615, 34, 0x00, 200);
315 rbsize_add_band(&rbsize_results[10], 617, 0, 672, 34, 0x04, 66);
317 rbsize_results[11] = rbsize_init(0, 0, 672, 34, 34, 1, 2);
318 rbsize_add_row(&rbsize_results[11], 34);
319 rbsize_add_band(&rbsize_results[11], 0, 0, 604, 34, 0x00, 200);
320 rbsize_add_band(&rbsize_results[11], 606, 0, 672, 34, 0x04, 66);
322 rbsize_results[12] = rbsize_init(0, 0, 672, 8 + 2*system_font_height, 40, 2, 5);
323 rbsize_add_row(&rbsize_results[12], 4 + system_font_height);
324 rbsize_add_row(&rbsize_results[12], 4 + system_font_height);
325 rbsize_add_band(&rbsize_results[12], 0, 0, 87 + string_width("ABC"), 4 + system_font_height, 0x00, 40);
326 rbsize_add_band(&rbsize_results[12], 87 + string_width("ABC"), 0, 157 + string_width("ABC"), 4 + system_font_height, 0x00, 70);
327 rbsize_add_band(&rbsize_results[12], 157 + string_width("ABC"), 0, 397 + string_width("ABC"), 4 + system_font_height, 0x00, 240);
328 rbsize_add_band(&rbsize_results[12], 397 + string_width("ABC"), 0, 672, 4 + system_font_height, 0x00, 60);
329 rbsize_add_band(&rbsize_results[12], 0, 4 + system_font_height, 672, 8 + 2*system_font_height, 0x00, 200);
331 rbsize_results[13] = rbsize_init(0, 0, 672, 8 + 2*system_font_height, 40, 2, 5);
332 rbsize_add_row(&rbsize_results[13], 4 + system_font_height);
333 rbsize_add_row(&rbsize_results[13], 4 + system_font_height);
334 rbsize_add_band(&rbsize_results[13], 0, 0, 87 + string_width("ABC"), 4 + system_font_height, 0x00, 40);
335 rbsize_add_band(&rbsize_results[13], 87 + string_width("ABC"), 0, 200 + string_width("ABC"), 4 + system_font_height, 0x00, 113);
336 rbsize_add_band(&rbsize_results[13], 200 + string_width("ABC"), 0, 397 + string_width("ABC"), 4 + system_font_height, 0x00, 197);
337 rbsize_add_band(&rbsize_results[13], 397 + string_width("ABC"), 0, 672, 4 + system_font_height, 0x00, 60);
338 rbsize_add_band(&rbsize_results[13], 0, 4 + system_font_height, 672, 8 + 2*system_font_height, 0x00, 200);
340 rbsize_results[14] = rbsize_init(0, 0, 672, 8 + 2*system_font_height, 40, 2, 5);
341 rbsize_add_row(&rbsize_results[14], 4 + system_font_height);
342 rbsize_add_row(&rbsize_results[14], 4 + system_font_height);
343 rbsize_add_band(&rbsize_results[14], 0, 0, 87 + string_width("ABC"), 4 + system_font_height, 0x00, 40);
344 rbsize_add_band(&rbsize_results[14], 87 + string_width("ABC"), 0, 412 - string_width("MMMMMMM"), 4 + system_font_height, 0x00, 325 - string_width("ABC") - string_width("MMMMMMM"));
345 rbsize_add_band(&rbsize_results[14], 412 - string_width("MMMMMMM"), 0, 595 - string_width("MMMMMMM"), 4 + system_font_height, 0x00, 183);
346 rbsize_add_band(&rbsize_results[14], 595 - string_width("MMMMMMM"), 0, 672, 4 + system_font_height, 0x00, 77 + string_width("MMMMMMM"));
347 rbsize_add_band(&rbsize_results[14], 0, 4 + system_font_height, 672, 8 + 2*system_font_height, 0x00, 200);
349 rbsize_results[15] = rbsize_init(0, 0, 672, 8 + 2*system_font_height, 40, 2, 5);
350 rbsize_add_row(&rbsize_results[15], 4 + system_font_height);
351 rbsize_add_row(&rbsize_results[15], 4 + system_font_height);
352 rbsize_add_band(&rbsize_results[15], 0, 0, 87 + string_width("ABC"), 4 + system_font_height, 0x00, 40);
353 rbsize_add_band(&rbsize_results[15], 87 + string_width("ABC"), 0, 140 + string_width("ABC"), 4 + system_font_height, 0x00, 53);
354 rbsize_add_band(&rbsize_results[15], 140 + string_width("ABC"), 0, 595 - string_width("MMMMMMM"), 4 + system_font_height, 0x00, 455 - string_width("MMMMMMM") - string_width("ABC"));
355 rbsize_add_band(&rbsize_results[15], 595 - string_width("MMMMMMM"), 0, 672, 4 + system_font_height, 0x00, 77 + string_width("MMMMMMM"));
356 rbsize_add_band(&rbsize_results[15], 0, 4 + system_font_height, 672, 8 + 2*system_font_height, 0x00, 200);
358 rbsize_results[16] = rbsize_init(0, 0, 672, 8 + 2*system_font_height, 40, 2, 5);
359 rbsize_add_row(&rbsize_results[16], 4 + system_font_height);
360 rbsize_add_row(&rbsize_results[16], 4 + system_font_height);
361 rbsize_add_band(&rbsize_results[16], 0, 0, 87 + string_width("ABC"), 4 + system_font_height, 0x00, 40);
362 rbsize_add_band(&rbsize_results[16], 87 + string_width("ABC"), 0, 412 - string_width("MMMMMMM"), 4 + system_font_height, 0x00, 325 - string_width("ABC") - string_width("MMMMMMM"));
363 rbsize_add_band(&rbsize_results[16], 412 - string_width("MMMMMMM"), 0, 595 - string_width("MMMMMMM"), 4 + system_font_height, 0x00, 183);
364 rbsize_add_band(&rbsize_results[16], 595 - string_width("MMMMMMM"), 0, 672, 4 + system_font_height, 0x00, 77 + string_width("MMMMMMM"));
365 rbsize_add_band(&rbsize_results[16], 0, 4 + system_font_height, 672, 8 + 2*system_font_height, 0x00, 200);
367 rbsize_results[17] = rbsize_init(0, 0, 672, 8 + 2*system_font_height, 40, 2, 5);
368 rbsize_add_row(&rbsize_results[17], 4 + system_font_height);
369 rbsize_add_row(&rbsize_results[17], 4 + system_font_height);
370 rbsize_add_band(&rbsize_results[17], 0, 0, 87 + string_width("ABC"), 4 + system_font_height, 0x00, 40);
371 rbsize_add_band(&rbsize_results[17], 87 + string_width("ABC"), 0, 412 - string_width("MMMMMMM"), 4 + system_font_height, 0x00, 325 - string_width("ABC") - string_width("MMMMMMM"));
372 rbsize_add_band(&rbsize_results[17], 412 - string_width("MMMMMMM"), 0, 595 - string_width("MMMMMMM"), 4 + system_font_height, 0x00, 183);
373 rbsize_add_band(&rbsize_results[17], 595 - string_width("MMMMMMM"), 0, 672, 4 + system_font_height, 0x00, 77 + string_width("MMMMMMM"));
374 rbsize_add_band(&rbsize_results[17], 0, 4 + system_font_height, 672, 8 + 2*system_font_height, 0x00, 200);
376 rbsize_results[18] = rbsize_init(0, 0, 672, 56, 56, 2, 5);
377 rbsize_add_row(&rbsize_results[18], 28);
378 rbsize_add_row(&rbsize_results[18], 28);
379 rbsize_add_band(&rbsize_results[18], 0, 0, 87 + string_width("ABC"), 28, 0x00, 40);
380 rbsize_add_band(&rbsize_results[18], 87 + string_width("ABC"), 0, 412 - string_width("MMMMMMM"), 28, 0x00, 325 - string_width("ABC") - string_width("MMMMMMM"));
381 rbsize_add_band(&rbsize_results[18], 412 - string_width("MMMMMMM"), 0, 595 - string_width("MMMMMMM"), 28, 0x00, 183);
382 rbsize_add_band(&rbsize_results[18], 595 - string_width("MMMMMMM"), 0, 672, 28, 0x00, 77 + string_width("MMMMMMM"));
383 rbsize_add_band(&rbsize_results[18], 0, 28, 672, 56, 0x00, 200);
385 rbsize_results[19] = rbsize_init(0, 0, 672, 8 + 2*system_font_height, 40, 2, 5);
386 rbsize_add_row(&rbsize_results[19], 4 + system_font_height);
387 rbsize_add_row(&rbsize_results[19], 4 + system_font_height);
388 rbsize_add_band(&rbsize_results[19], 0, 0, 87 + string_width("ABC"), 4 + system_font_height, 0x00, 40);
389 rbsize_add_band(&rbsize_results[19], 87 + string_width("ABC"), 0, 412 - string_width("MMMMMMM"), 4 + system_font_height, 0x00, 325 - string_width("ABC") - string_width("MMMMMMM"));
390 rbsize_add_band(&rbsize_results[19], 412 - string_width("MMMMMMM"), 0, 595 - string_width("MMMMMMM"), 4 + system_font_height, 0x00, 183);
391 rbsize_add_band(&rbsize_results[19], 595 - string_width("MMMMMMM"), 0, 672, 4 + system_font_height, 0x00, 77 + string_width("MMMMMMM"));
392 rbsize_add_band(&rbsize_results[19], 0, 4 + system_font_height, 672, 8 + 2*system_font_height, 0x00, 200);
394 rbsize_results[20] = rbsize_init(0, 0, 672, 56, 56, 2, 5);
395 rbsize_add_row(&rbsize_results[20], 28);
396 rbsize_add_row(&rbsize_results[20], 28);
397 rbsize_add_band(&rbsize_results[20], 0, 0, 87 + string_width("ABC"), 28, 0x00, 40);
398 rbsize_add_band(&rbsize_results[20], 87 + string_width("ABC"), 0, 412 - string_width("MMMMMMM"), 28, 0x00, 325 - string_width("ABC") - string_width("MMMMMMM"));
399 rbsize_add_band(&rbsize_results[20], 412 - string_width("MMMMMMM"), 0, 595 - string_width("MMMMMMM"), 28, 0x00, 183);
400 rbsize_add_band(&rbsize_results[20], 595 - string_width("MMMMMMM"), 0, 672, 28, 0x00, 77 + string_width("MMMMMMM"));
401 rbsize_add_band(&rbsize_results[20], 0, 28, 672, 56, 0x00, 200);
403 rbsize_results[21] = rbsize_init(0, 0, 672, 0, 0, 0, 0);
405 rbsize_results[22] = rbsize_init(0, 0, 672, 65, 56, 1, 3);
406 rbsize_add_row(&rbsize_results[22], 65);
407 rbsize_add_band(&rbsize_results[22], 0, 0, 90, 65, 0x40, 90);
408 rbsize_add_band(&rbsize_results[22], 90, 0, 180, 65, 0x40, 90);
409 rbsize_add_band(&rbsize_results[22], 180, 0, 672, 65, 0x40, 90);
411 rbsize_results[23] = rbsize_init(0, 0, 0, 226, 0, 0, 0);
413 rbsize_results[24] = rbsize_init(0, 0, 65, 226, 65, 1, 1);
414 rbsize_add_row(&rbsize_results[24], 65);
415 rbsize_add_band(&rbsize_results[24], 0, 0, 226, 65, 0x40, 90);
417 rbsize_results[25] = rbsize_init(0, 0, 65, 226, 65, 1, 2);
418 rbsize_add_row(&rbsize_results[25], 65);
419 rbsize_add_band(&rbsize_results[25], 0, 0, 90, 65, 0x40, 90);
420 rbsize_add_band(&rbsize_results[25], 90, 0, 226, 65, 0x40, 90);
422 rbsize_results[26] = rbsize_init(0, 0, 65, 226, 65, 1, 3);
423 rbsize_add_row(&rbsize_results[26], 65);
424 rbsize_add_band(&rbsize_results[26], 0, 0, 90, 65, 0x40, 90);
425 rbsize_add_band(&rbsize_results[26], 90, 0, 163, 65, 0x40, 90);
426 rbsize_add_band(&rbsize_results[26], 163, 0, 226, 65, 0x40, 90);
429 static void rbsize_results_free(void)
431 int i;
433 for (i = 0; i < rbsize_results_num; i++) {
434 HeapFree(GetProcessHeap(), 0, rbsize_results[i].cyRowHeights);
435 HeapFree(GetProcessHeap(), 0, rbsize_results[i].bands);
437 HeapFree(GetProcessHeap(), 0, rbsize_results);
438 rbsize_results = NULL;
441 static int rbsize_numtests = 0;
443 #define check_sizes_todo(todomask) { \
444 RECT rc; \
445 REBARBANDINFOA rbi; \
446 int count, i/*, mask=(todomask)*/; \
447 const rbsize_result_t *res = &rbsize_results[rbsize_numtests]; \
448 GetClientRect(hRebar, &rc); \
449 check_rect("client", rc, res->rcClient); \
450 count = SendMessageA(hRebar, RB_GETROWCOUNT, 0, 0); \
451 compare(count, res->nRows, "%d"); \
452 for (i=0; i<min(count, res->nRows); i++) { \
453 int height = SendMessageA(hRebar, RB_GETROWHEIGHT, 0, 0);\
454 ok(height == res->cyRowHeights[i], "Height mismatch for row %d - %d vs %d\n", i, res->cyRowHeights[i], height); \
456 count = SendMessageA(hRebar, RB_GETBANDCOUNT, 0, 0); \
457 compare(count, res->nBands, "%d"); \
458 for (i=0; i<min(count, res->nBands); i++) { \
459 ok(SendMessageA(hRebar, RB_GETRECT, i, (LPARAM)&rc) == 1, "RB_GETRECT\n"); \
460 if (!(res->bands[i].fStyle & RBBS_HIDDEN)) \
461 check_rect("band", rc, res->bands[i].rc); \
462 rbi.cbSize = REBARBANDINFOA_V6_SIZE; \
463 rbi.fMask = RBBIM_STYLE | RBBIM_SIZE; \
464 ok(SendMessageA(hRebar, RB_GETBANDINFOA, i, (LPARAM)&rbi) == 1, "RB_GETBANDINFOA\n"); \
465 compare(rbi.fStyle, res->bands[i].fStyle, "%x"); \
466 compare(rbi.cx, res->bands[i].cx, "%d"); \
468 rbsize_numtests++; \
471 #define check_sizes() check_sizes_todo(0)
473 #endif
475 static void add_band_w(HWND hRebar, LPCSTR lpszText, int cxMinChild, int cx, int cxIdeal)
477 CHAR buffer[MAX_PATH];
478 REBARBANDINFOA rbi;
480 if (lpszText != NULL)
481 strcpy(buffer, lpszText);
482 rbi.cbSize = REBARBANDINFOA_V6_SIZE;
483 rbi.fMask = RBBIM_SIZE | RBBIM_CHILDSIZE | RBBIM_CHILD | RBBIM_IDEALSIZE | RBBIM_TEXT;
484 rbi.cx = cx;
485 rbi.cxMinChild = cxMinChild;
486 rbi.cxIdeal = cxIdeal;
487 rbi.cyMinChild = 20;
488 rbi.hwndChild = build_toolbar(1, hRebar);
489 rbi.lpText = (lpszText ? buffer : NULL);
490 SendMessageA(hRebar, RB_INSERTBANDA, -1, (LPARAM)&rbi);
493 static void test_layout(void)
495 HWND hRebar;
496 REBARBANDINFOA rbi;
497 HIMAGELIST himl;
498 REBARINFO ri;
500 rbsize_results_init();
502 hRebar = create_rebar_control();
503 check_sizes();
504 rbi.cbSize = REBARBANDINFOA_V6_SIZE;
505 rbi.fMask = RBBIM_SIZE | RBBIM_CHILDSIZE | RBBIM_CHILD;
506 rbi.cx = 200;
507 rbi.cxMinChild = 100;
508 rbi.cyMinChild = 30;
509 rbi.hwndChild = NULL;
510 SendMessageA(hRebar, RB_INSERTBANDA, -1, (LPARAM)&rbi);
511 check_sizes();
513 rbi.fMask |= RBBIM_STYLE;
514 rbi.fStyle = RBBS_CHILDEDGE;
515 SendMessageA(hRebar, RB_INSERTBANDA, -1, (LPARAM)&rbi);
516 check_sizes();
518 rbi.fStyle = 0;
519 rbi.cx = 200;
520 rbi.cxMinChild = 30;
521 rbi.cyMinChild = 30;
522 rbi.hwndChild = build_toolbar(0, hRebar);
523 SendMessageA(hRebar, RB_INSERTBANDA, -1, (LPARAM)&rbi);
524 check_sizes();
526 rbi.fStyle = RBBS_CHILDEDGE;
527 rbi.cx = 68;
528 rbi.hwndChild = build_toolbar(0, hRebar);
529 SendMessageA(hRebar, RB_INSERTBANDA, -1, (LPARAM)&rbi);
530 check_sizes();
532 SetWindowLongA(hRebar, GWL_STYLE, GetWindowLongA(hRebar, GWL_STYLE) | RBS_BANDBORDERS);
533 check_sizes(); /* a style change won't start a relayout */
534 rbi.fMask = RBBIM_SIZE;
535 rbi.cx = 66;
536 SendMessageA(hRebar, RB_SETBANDINFOA, 3, (LPARAM)&rbi);
537 check_sizes(); /* here it will be relayouted */
539 /* this will force a new row */
540 rbi.fMask = RBBIM_SIZE | RBBIM_CHILDSIZE | RBBIM_CHILD;
541 rbi.cx = 200;
542 rbi.cxMinChild = 400;
543 rbi.cyMinChild = 30;
544 rbi.hwndChild = build_toolbar(0, hRebar);
545 SendMessageA(hRebar, RB_INSERTBANDA, 1, (LPARAM)&rbi);
546 check_sizes();
548 rbi.fMask = RBBIM_STYLE;
549 rbi.fStyle = RBBS_HIDDEN;
550 SendMessageA(hRebar, RB_SETBANDINFOA, 2, (LPARAM)&rbi);
551 check_sizes();
553 SendMessageA(hRebar, RB_DELETEBAND, 2, 0);
554 check_sizes();
555 SendMessageA(hRebar, RB_DELETEBAND, 0, 0);
556 check_sizes();
557 SendMessageA(hRebar, RB_DELETEBAND, 1, 0);
558 check_sizes();
560 DestroyWindow(hRebar);
562 hRebar = create_rebar_control();
563 add_band_w(hRebar, "ABC", 70, 40, 100);
564 add_band_w(hRebar, NULL, 40, 70, 100);
565 add_band_w(hRebar, NULL, 170, 240, 100);
566 add_band_w(hRebar, "MMMMMMM", 60, 60, 100);
567 add_band_w(hRebar, NULL, 200, 200, 100);
568 check_sizes();
569 SendMessageA(hRebar, RB_MAXIMIZEBAND, 1, TRUE);
570 check_sizes();
571 SendMessageA(hRebar, RB_MAXIMIZEBAND, 1, TRUE);
572 check_sizes();
573 SendMessageA(hRebar, RB_MAXIMIZEBAND, 2, FALSE);
574 check_sizes();
575 SendMessageA(hRebar, RB_MINIMIZEBAND, 2, 0);
576 check_sizes();
577 SendMessageA(hRebar, RB_MINIMIZEBAND, 0, 0);
578 check_sizes();
580 /* an image will increase the band height */
581 himl = ImageList_LoadImageA(GetModuleHandleA("comctl32"), MAKEINTRESOURCEA(121), 24, 2,
582 CLR_NONE, IMAGE_BITMAP, LR_DEFAULTCOLOR);
583 ri.cbSize = sizeof(ri);
584 ri.fMask = RBIM_IMAGELIST;
585 ri.himl = himl;
586 ok(SendMessageA(hRebar, RB_SETBARINFO, 0, (LPARAM)&ri), "RB_SETBARINFO failed\n");
587 rbi.fMask = RBBIM_IMAGE;
588 rbi.iImage = 1;
589 SendMessageA(hRebar, RB_SETBANDINFOA, 1, (LPARAM)&rbi);
590 check_sizes();
592 /* after removing it everything is back to normal*/
593 rbi.iImage = -1;
594 SendMessageA(hRebar, RB_SETBANDINFOA, 1, (LPARAM)&rbi);
595 check_sizes();
597 /* Only -1 means that the image is not present. Other invalid values increase the height */
598 rbi.iImage = -2;
599 SendMessageA(hRebar, RB_SETBANDINFOA, 1, (LPARAM)&rbi);
600 check_sizes();
602 DestroyWindow(hRebar);
604 /* VARHEIGHT resizing test on a horizontal rebar */
605 hRebar = create_rebar_control();
606 SetWindowLongA(hRebar, GWL_STYLE, GetWindowLongA(hRebar, GWL_STYLE) | RBS_AUTOSIZE);
607 check_sizes();
608 rbi.fMask = RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_SIZE | RBBIM_STYLE;
609 rbi.fStyle = RBBS_VARIABLEHEIGHT;
610 rbi.cxMinChild = 50;
611 rbi.cyMinChild = 10;
612 rbi.cyIntegral = 11;
613 rbi.cyChild = 70;
614 rbi.cyMaxChild = 200;
615 rbi.cx = 90;
616 rbi.hwndChild = build_toolbar(0, hRebar);
617 SendMessageA(hRebar, RB_INSERTBANDA, -1, (LPARAM)&rbi);
619 rbi.cyChild = 50;
620 rbi.hwndChild = build_toolbar(0, hRebar);
621 SendMessageA(hRebar, RB_INSERTBANDA, -1, (LPARAM)&rbi);
623 rbi.cyMinChild = 40;
624 rbi.cyChild = 50;
625 rbi.cyIntegral = 5;
626 rbi.hwndChild = build_toolbar(0, hRebar);
627 SendMessageA(hRebar, RB_INSERTBANDA, -1, (LPARAM)&rbi);
628 check_sizes();
630 DestroyWindow(hRebar);
632 /* VARHEIGHT resizing on a vertical rebar */
633 hRebar = create_rebar_control();
634 SetWindowLongA(hRebar, GWL_STYLE, GetWindowLongA(hRebar, GWL_STYLE) | CCS_VERT | RBS_AUTOSIZE);
635 check_sizes();
636 rbi.fMask = RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_SIZE | RBBIM_STYLE;
637 rbi.fStyle = RBBS_VARIABLEHEIGHT;
638 rbi.cxMinChild = 50;
639 rbi.cyMinChild = 10;
640 rbi.cyIntegral = 11;
641 rbi.cyChild = 70;
642 rbi.cyMaxChild = 90;
643 rbi.cx = 90;
644 rbi.hwndChild = build_toolbar(0, hRebar);
645 SendMessageA(hRebar, RB_INSERTBANDA, -1, (LPARAM)&rbi);
646 check_sizes();
648 rbi.cyChild = 50;
649 rbi.hwndChild = build_toolbar(0, hRebar);
650 SendMessageA(hRebar, RB_INSERTBANDA, -1, (LPARAM)&rbi);
651 check_sizes();
653 rbi.cyMinChild = 40;
654 rbi.cyChild = 50;
655 rbi.cyIntegral = 5;
656 rbi.hwndChild = build_toolbar(0, hRebar);
657 SendMessageA(hRebar, RB_INSERTBANDA, -1, (LPARAM)&rbi);
658 check_sizes();
660 rbsize_results_free();
661 DestroyWindow(hRebar);
662 ImageList_Destroy(himl);
665 #if 0 /* use this to generate more tests */
667 static void dump_client(HWND hRebar)
669 RECT r;
670 BOOL notify;
671 GetWindowRect(hRebar, &r);
672 MapWindowPoints(HWND_DESKTOP, hMainWnd, &r, 2);
673 if (height_change_notify_rect.top != -1)
675 RECT rcClient;
676 GetClientRect(hRebar, &rcClient);
677 assert(EqualRect(&rcClient, &height_change_notify_rect));
678 notify = TRUE;
680 else
681 notify = FALSE;
682 printf(" {{%d, %d, %d, %d}, %d, %s},\n", r.left, r.top, r.right, r.bottom, SendMessageA(hRebar, RB_GETROWCOUNT, 0, 0),
683 notify ? "TRUE" : "FALSE");
684 SetRect(&height_change_notify_rect, -1, -1, -1, -1);
687 #define comment(fmt, arg1) printf("/* " fmt " */\n", arg1);
688 #define check_client() dump_client(hRebar)
690 #else
692 typedef struct {
693 RECT rc;
694 INT iNumRows;
695 BOOL heightNotify;
696 } rbresize_test_result_t;
698 static const rbresize_test_result_t resize_results[] = {
699 /* style 00000001 */
700 {{0, 2, 672, 2}, 0, FALSE},
701 {{0, 2, 672, 22}, 1, TRUE},
702 {{0, 2, 672, 22}, 1, FALSE},
703 {{0, 2, 672, 22}, 1, FALSE},
704 {{0, 2, 672, 22}, 1, FALSE},
705 {{0, 2, 672, 22}, 0, FALSE},
706 /* style 00000041 */
707 {{0, 0, 672, 0}, 0, FALSE},
708 {{0, 0, 672, 20}, 1, TRUE},
709 {{0, 0, 672, 20}, 1, FALSE},
710 {{0, 0, 672, 20}, 1, FALSE},
711 {{0, 0, 672, 20}, 1, FALSE},
712 {{0, 0, 672, 20}, 0, FALSE},
713 /* style 00000003 */
714 {{0, 226, 672, 226}, 0, FALSE},
715 {{0, 206, 672, 226}, 1, TRUE},
716 {{0, 206, 672, 226}, 1, FALSE},
717 {{0, 206, 672, 226}, 1, FALSE},
718 {{0, 206, 672, 226}, 1, FALSE},
719 {{0, 206, 672, 226}, 0, FALSE},
720 /* style 00000043 */
721 {{0, 226, 672, 226}, 0, FALSE},
722 {{0, 206, 672, 226}, 1, TRUE},
723 {{0, 206, 672, 226}, 1, FALSE},
724 {{0, 206, 672, 226}, 1, FALSE},
725 {{0, 206, 672, 226}, 1, FALSE},
726 {{0, 206, 672, 226}, 0, FALSE},
727 /* style 00000080 */
728 {{2, 0, 2, 226}, 0, FALSE},
729 {{2, 0, 22, 226}, 1, TRUE},
730 {{2, 0, 22, 226}, 1, FALSE},
731 {{2, 0, 22, 226}, 1, FALSE},
732 {{2, 0, 22, 226}, 1, FALSE},
733 {{2, 0, 22, 226}, 0, FALSE},
734 /* style 00000083 */
735 {{672, 0, 672, 226}, 0, FALSE},
736 {{652, 0, 672, 226}, 1, TRUE},
737 {{652, 0, 672, 226}, 1, FALSE},
738 {{652, 0, 672, 226}, 1, FALSE},
739 {{652, 0, 672, 226}, 1, FALSE},
740 {{652, 0, 672, 226}, 0, FALSE},
741 /* style 00000008 */
742 {{10, 11, 510, 11}, 0, FALSE},
743 {{10, 15, 510, 35}, 1, TRUE},
744 {{10, 17, 510, 37}, 1, FALSE},
745 {{10, 14, 110, 54}, 2, TRUE},
746 {{0, 4, 0, 44}, 2, FALSE},
747 {{0, 6, 0, 46}, 2, FALSE},
748 {{0, 8, 0, 48}, 2, FALSE},
749 {{0, 12, 0, 32}, 1, TRUE},
750 {{0, 4, 100, 24}, 0, FALSE},
751 /* style 00000048 */
752 {{10, 5, 510, 5}, 0, FALSE},
753 {{10, 5, 510, 25}, 1, TRUE},
754 {{10, 5, 510, 25}, 1, FALSE},
755 {{10, 10, 110, 50}, 2, TRUE},
756 {{0, 0, 0, 40}, 2, FALSE},
757 {{0, 0, 0, 40}, 2, FALSE},
758 {{0, 0, 0, 40}, 2, FALSE},
759 {{0, 0, 0, 20}, 1, TRUE},
760 {{0, 0, 100, 20}, 0, FALSE},
761 /* style 00000004 */
762 {{10, 5, 510, 20}, 0, FALSE},
763 {{10, 5, 510, 20}, 1, TRUE},
764 {{10, 10, 110, 110}, 2, TRUE},
765 {{0, 0, 0, 0}, 2, FALSE},
766 {{0, 0, 0, 0}, 2, FALSE},
767 {{0, 0, 0, 0}, 2, FALSE},
768 {{0, 0, 0, 0}, 1, TRUE},
769 {{0, 0, 100, 100}, 0, FALSE},
770 /* style 00000002 */
771 {{0, 5, 672, 5}, 0, FALSE},
772 {{0, 5, 672, 25}, 1, TRUE},
773 {{0, 10, 672, 30}, 1, FALSE},
774 {{0, 0, 672, 20}, 1, FALSE},
775 {{0, 0, 672, 20}, 1, FALSE},
776 {{0, 0, 672, 20}, 0, FALSE},
777 /* style 00000082 */
778 {{10, 0, 10, 226}, 0, FALSE},
779 {{10, 0, 30, 226}, 1, TRUE},
780 {{10, 0, 30, 226}, 1, FALSE},
781 {{0, 0, 20, 226}, 1, FALSE},
782 {{0, 0, 20, 226}, 1, FALSE},
783 {{0, 0, 20, 226}, 0, FALSE},
784 /* style 00800001 */
785 {{-2, 0, 674, 4}, 0, FALSE},
786 {{-2, 0, 674, 24}, 1, TRUE},
787 {{-2, 0, 674, 24}, 1, FALSE},
788 {{-2, 0, 674, 24}, 1, FALSE},
789 {{-2, 0, 674, 24}, 1, FALSE},
790 {{-2, 0, 674, 24}, 0, FALSE},
791 /* style 00800048 */
792 {{10, 5, 510, 9}, 0, FALSE},
793 {{10, 5, 510, 29}, 1, TRUE},
794 {{10, 5, 510, 29}, 1, FALSE},
795 {{10, 10, 110, 54}, 2, TRUE},
796 {{0, 0, 0, 44}, 2, FALSE},
797 {{0, 0, 0, 44}, 2, FALSE},
798 {{0, 0, 0, 44}, 2, FALSE},
799 {{0, 0, 0, 24}, 1, TRUE},
800 {{0, 0, 100, 24}, 0, FALSE},
801 /* style 00800004 */
802 {{10, 5, 510, 20}, 0, FALSE},
803 {{10, 5, 510, 20}, 1, TRUE},
804 {{10, 10, 110, 110}, 2, TRUE},
805 {{0, 0, 0, 0}, 2, FALSE},
806 {{0, 0, 0, 0}, 2, FALSE},
807 {{0, 0, 0, 0}, 2, FALSE},
808 {{0, 0, 0, 0}, 1, TRUE},
809 {{0, 0, 100, 100}, 0, FALSE},
810 /* style 00800002 */
811 {{-2, 5, 674, 9}, 0, FALSE},
812 {{-2, 5, 674, 29}, 1, TRUE},
813 {{-2, 10, 674, 34}, 1, FALSE},
814 {{-2, 0, 674, 24}, 1, FALSE},
815 {{-2, 0, 674, 24}, 1, FALSE},
816 {{-2, 0, 674, 24}, 0, FALSE},
819 static DWORD resize_numtests = 0;
821 #define comment(fmt, arg1)
822 #define check_client() { \
823 RECT r; \
824 int value; \
825 const rbresize_test_result_t *res = &resize_results[resize_numtests++]; \
826 assert(resize_numtests <= sizeof(resize_results)/sizeof(resize_results[0])); \
827 GetWindowRect(hRebar, &r); \
828 MapWindowPoints(HWND_DESKTOP, hMainWnd, (LPPOINT)&r, 2); \
829 if ((dwStyles[i] & (CCS_NOPARENTALIGN|CCS_NODIVIDER)) == CCS_NOPARENTALIGN) {\
830 check_rect_no_top("client", r, res->rc); /* the top coordinate changes after every layout and is very implementation-dependent */ \
831 } else { \
832 check_rect("client", r, res->rc); \
834 value = (int)SendMessageA(hRebar, RB_GETROWCOUNT, 0, 0); \
835 ok(res->iNumRows == value, "RB_GETROWCOUNT expected %d got %d\n", res->iNumRows, value); \
836 if (res->heightNotify) { \
837 RECT rcClient; \
838 GetClientRect(hRebar, &rcClient); \
839 check_rect("notify", height_change_notify_rect, rcClient); \
840 } else ok(height_change_notify_rect.top == -1, "Unexpected RBN_HEIGHTCHANGE received\n"); \
841 SetRect(&height_change_notify_rect, -1, -1, -1, -1); \
844 #endif
846 static void test_resize(void)
848 DWORD dwStyles[] = {CCS_TOP, CCS_TOP | CCS_NODIVIDER, CCS_BOTTOM, CCS_BOTTOM | CCS_NODIVIDER, CCS_VERT, CCS_RIGHT,
849 CCS_NOPARENTALIGN, CCS_NOPARENTALIGN | CCS_NODIVIDER, CCS_NORESIZE, CCS_NOMOVEY, CCS_NOMOVEY | CCS_VERT,
850 CCS_TOP | WS_BORDER, CCS_NOPARENTALIGN | CCS_NODIVIDER | WS_BORDER, CCS_NORESIZE | WS_BORDER,
851 CCS_NOMOVEY | WS_BORDER};
853 const int styles_count = sizeof(dwStyles) / sizeof(dwStyles[0]);
854 int i;
856 for (i = 0; i < styles_count; i++)
858 HWND hRebar;
860 comment("style %08x", dwStyles[i]);
861 SetRect(&height_change_notify_rect, -1, -1, -1, -1);
862 hRebar = CreateWindowA(REBARCLASSNAMEA, "A", dwStyles[i] | WS_CHILD | WS_VISIBLE, 10, 5, 500, 15, hMainWnd, NULL, GetModuleHandleA(NULL), 0);
863 check_client();
864 add_band_w(hRebar, NULL, 70, 100, 0);
865 if (dwStyles[i] & CCS_NOPARENTALIGN) /* the window drifts downward for CCS_NOPARENTALIGN without CCS_NODIVIDER */
866 check_client();
867 add_band_w(hRebar, NULL, 70, 100, 0);
868 check_client();
869 MoveWindow(hRebar, 10, 10, 100, 100, TRUE);
870 check_client();
871 MoveWindow(hRebar, 0, 0, 0, 0, TRUE);
872 check_client();
873 /* try to fool the rebar by sending invalid width/height - won't work */
874 if (dwStyles[i] & (CCS_NORESIZE | CCS_NOPARENTALIGN))
876 WINDOWPOS pos;
877 pos.hwnd = hRebar;
878 pos.hwndInsertAfter = NULL;
879 pos.cx = 500;
880 pos.cy = 500;
881 pos.x = 10;
882 pos.y = 10;
883 pos.flags = 0;
884 SendMessageA(hRebar, WM_WINDOWPOSCHANGING, 0, (LPARAM)&pos);
885 SendMessageA(hRebar, WM_WINDOWPOSCHANGED, 0, (LPARAM)&pos);
886 check_client();
887 SendMessageA(hRebar, WM_SIZE, SIZE_RESTORED, MAKELONG(500, 500));
888 check_client();
890 SendMessageA(hRebar, RB_DELETEBAND, 0, 0);
891 check_client();
892 SendMessageA(hRebar, RB_DELETEBAND, 0, 0);
893 MoveWindow(hRebar, 0, 0, 100, 100, TRUE);
894 check_client();
895 DestroyWindow(hRebar);
899 static void expect_band_content_(int line, HWND hRebar, UINT uBand, INT fStyle, COLORREF clrFore,
900 COLORREF clrBack, LPCSTR lpText, int iImage, HWND hwndChild,
901 INT cxMinChild, INT cyMinChild, INT cx, HBITMAP hbmBack, INT wID,
902 INT cyChild, INT cyMaxChild, INT cyIntegral, INT cxIdeal, LPARAM lParam,
903 UINT cxHeader, UINT cxHeader_broken)
905 CHAR buf[MAX_PATH] = "abc";
906 REBARBANDINFOA rb;
908 memset(&rb, 0xdd, sizeof(rb));
909 rb.cbSize = REBARBANDINFOA_V6_SIZE;
910 rb.fMask = RBBIM_BACKGROUND | RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_COLORS
911 | RBBIM_HEADERSIZE | RBBIM_ID | RBBIM_IDEALSIZE | RBBIM_IMAGE | RBBIM_LPARAM
912 | RBBIM_SIZE | RBBIM_STYLE | RBBIM_TEXT;
913 rb.lpText = buf;
914 rb.cch = MAX_PATH;
915 ok(SendMessageA(hRebar, RB_GETBANDINFOA, uBand, (LPARAM)&rb), "RB_GETBANDINFOA failed from line %d\n", line);
916 expect_eq(line, rb.fStyle, fStyle, int, "%x");
917 expect_eq(line, rb.clrFore, clrFore, COLORREF, "%x");
918 expect_eq(line, rb.clrBack, clrBack, COLORREF, "%x");
919 expect_eq(line, strcmp(rb.lpText, lpText), 0, int, "%d");
920 expect_eq(line, rb.iImage, iImage, int, "%x");
921 expect_eq(line, rb.hwndChild, hwndChild, HWND, "%p");
922 expect_eq(line, rb.cxMinChild, cxMinChild, int, "%d");
923 expect_eq(line, rb.cyMinChild, cyMinChild, int, "%d");
924 expect_eq(line, rb.cx, cx, int, "%d");
925 expect_eq(line, rb.hbmBack, hbmBack, HBITMAP, "%p");
926 expect_eq(line, rb.wID, wID, int, "%d");
927 /* the values of cyChild, cyMaxChild and cyIntegral can't be read unless the band is RBBS_VARIABLEHEIGHT */
928 expect_eq(line, rb.cyChild, cyChild, int, "%x");
929 expect_eq(line, rb.cyMaxChild, cyMaxChild, int, "%x");
930 expect_eq(line, rb.cyIntegral, cyIntegral, int, "%x");
931 expect_eq(line, rb.cxIdeal, cxIdeal, int, "%d");
932 expect_eq(line, rb.lParam, lParam, LPARAM, "%ld");
933 ok(rb.cxHeader == cxHeader || rb.cxHeader == cxHeader + 1 || broken(rb.cxHeader == cxHeader_broken),
934 "expected %d for %d from line %d\n", cxHeader, rb.cxHeader, line);
937 #define expect_band_content(hRebar, uBand, fStyle, clrFore, clrBack,\
938 lpText, iImage, hwndChild, cxMinChild, cyMinChild, cx, hbmBack, wID,\
939 cyChild, cyMaxChild, cyIntegral, cxIdeal, lParam, cxHeader, cxHeader_broken) \
940 expect_band_content_(__LINE__, hRebar, uBand, fStyle, clrFore, clrBack,\
941 lpText, iImage, hwndChild, cxMinChild, cyMinChild, cx, hbmBack, wID,\
942 cyChild, cyMaxChild, cyIntegral, cxIdeal, lParam, cxHeader, cxHeader_broken)
944 static void test_bandinfo(void)
946 REBARBANDINFOA rb;
947 CHAR szABC[] = "ABC";
948 CHAR szABCD[] = "ABCD";
949 HWND hRebar;
951 hRebar = create_rebar_control();
952 rb.cbSize = REBARBANDINFOA_V6_SIZE;
953 rb.fMask = 0;
954 if (!SendMessageA(hRebar, RB_INSERTBANDA, 0, (LPARAM)&rb))
956 win_skip( "V6 info not supported\n" );
957 DestroyWindow(hRebar);
958 return;
960 expect_band_content(hRebar, 0, 0, 0, GetSysColor(COLOR_3DFACE), "", -1, NULL, 0, 0, 0, NULL, 0, 0xdddddddd, 0xdddddddd, 0xdddddddd, 0, 0, 0, -1);
962 rb.fMask = RBBIM_CHILDSIZE;
963 rb.cxMinChild = 15;
964 rb.cyMinChild = 20;
965 rb.cyChild = 30;
966 rb.cyMaxChild = 20;
967 rb.cyIntegral = 10;
968 ok(SendMessageA(hRebar, RB_SETBANDINFOA, 0, (LPARAM)&rb), "RB_SETBANDINFOA failed\n");
969 expect_band_content(hRebar, 0, 0, 0, GetSysColor(COLOR_3DFACE), "", -1, NULL, 15, 20, 0, NULL, 0, 0xdddddddd, 0xdddddddd, 0xdddddddd, 0, 0, 0, -1);
971 rb.fMask = RBBIM_TEXT;
972 rb.lpText = szABC;
973 ok(SendMessageA(hRebar, RB_SETBANDINFOA, 0, (LPARAM)&rb), "RB_SETBANDINFOA failed\n");
974 expect_band_content(hRebar, 0, 0, 0, GetSysColor(COLOR_3DFACE), "ABC", -1, NULL, 15, 20, 0, NULL, 0, 0xdddddddd, 0xdddddddd, 0xdddddddd, 0, 0, 3 + 2*system_font_height, -1);
976 rb.cbSize = REBARBANDINFOA_V6_SIZE;
977 rb.fMask = 0;
978 ok(SendMessageA(hRebar, RB_INSERTBANDA, 1, (LPARAM)&rb), "RB_INSERTBANDA failed\n");
979 expect_band_content(hRebar, 1, 0, 0, GetSysColor(COLOR_3DFACE), "", -1, NULL, 0, 0, 0, NULL, 0, 0xdddddddd, 0xdddddddd, 0xdddddddd, 0, 0, 9, -1);
980 expect_band_content(hRebar, 0, 0, 0, GetSysColor(COLOR_3DFACE), "ABC", -1, NULL, 15, 20, 0, NULL, 0, 0xdddddddd, 0xdddddddd, 0xdddddddd, 0, 0, 8 + 2*system_font_height, -1);
982 rb.fMask = RBBIM_HEADERSIZE;
983 rb.cxHeader = 50;
984 ok(SendMessageA(hRebar, RB_SETBANDINFOA, 0, (LPARAM)&rb), "RB_SETBANDINFOA failed\n");
985 expect_band_content(hRebar, 0, 0x40000000, 0, GetSysColor(COLOR_3DFACE), "ABC", -1, NULL, 15, 20, 0, NULL, 0, 0xdddddddd, 0xdddddddd, 0xdddddddd, 0, 0, 50, -1);
987 rb.cxHeader = 5;
988 ok(SendMessageA(hRebar, RB_SETBANDINFOA, 0, (LPARAM)&rb), "RB_SETBANDINFOA failed\n");
989 expect_band_content(hRebar, 0, 0x40000000, 0, GetSysColor(COLOR_3DFACE), "ABC", -1, NULL, 15, 20, 0, NULL, 0, 0xdddddddd, 0xdddddddd, 0xdddddddd, 0, 0, 5, -1);
991 rb.fMask = RBBIM_TEXT;
992 rb.lpText = szABCD;
993 ok(SendMessageA(hRebar, RB_SETBANDINFOA, 0, (LPARAM)&rb), "RB_SETBANDINFOA failed\n");
994 expect_band_content(hRebar, 0, 0x40000000, 0, GetSysColor(COLOR_3DFACE), "ABCD", -1, NULL, 15, 20, 0, NULL, 0, 0xdddddddd, 0xdddddddd, 0xdddddddd, 0, 0, 5, -1);
995 rb.fMask = RBBIM_STYLE | RBBIM_TEXT;
996 rb.fStyle = RBBS_VARIABLEHEIGHT;
997 rb.lpText = szABC;
998 ok(SendMessageA(hRebar, RB_SETBANDINFOA, 0, (LPARAM)&rb), "RB_SETBANDINFOA failed\n");
999 expect_band_content(hRebar, 0, RBBS_VARIABLEHEIGHT, 0, GetSysColor(COLOR_3DFACE), "ABC", -1, NULL, 15, 20, 0, NULL, 0, 20, 0x7fffffff, 0, 0, 0, 8 + 2*system_font_height, 5);
1001 DestroyWindow(hRebar);
1004 static void test_colors(void)
1006 COLORSCHEME scheme;
1007 COLORREF clr;
1008 BOOL ret;
1009 HWND hRebar;
1010 REBARBANDINFOA bi;
1012 hRebar = create_rebar_control();
1014 /* test default colors */
1015 clr = SendMessageA(hRebar, RB_GETTEXTCOLOR, 0, 0);
1016 compare(clr, CLR_NONE, "%x");
1017 clr = SendMessageA(hRebar, RB_GETBKCOLOR, 0, 0);
1018 compare(clr, CLR_NONE, "%x");
1020 scheme.dwSize = sizeof(scheme);
1021 scheme.clrBtnHighlight = 0;
1022 scheme.clrBtnShadow = 0;
1023 ret = SendMessageA(hRebar, RB_GETCOLORSCHEME, 0, (LPARAM)&scheme);
1024 if (ret)
1026 compare(scheme.clrBtnHighlight, CLR_DEFAULT, "%x");
1027 compare(scheme.clrBtnShadow, CLR_DEFAULT, "%x");
1029 else
1030 skip("RB_GETCOLORSCHEME not supported\n");
1032 /* check default band colors */
1033 add_band_w(hRebar, "", 0, 10, 10);
1034 bi.cbSize = REBARBANDINFOA_V6_SIZE;
1035 bi.fMask = RBBIM_COLORS;
1036 bi.clrFore = bi.clrBack = 0xc0ffe;
1037 ret = SendMessageA(hRebar, RB_GETBANDINFOA, 0, (LPARAM)&bi);
1038 ok(ret, "RB_GETBANDINFOA failed\n");
1039 compare(bi.clrFore, RGB(0, 0, 0), "%x");
1040 compare(bi.clrBack, GetSysColor(COLOR_3DFACE), "%x");
1042 SendMessageA(hRebar, RB_SETTEXTCOLOR, 0, RGB(255, 0, 0));
1043 bi.clrFore = bi.clrBack = 0xc0ffe;
1044 ret = SendMessageA(hRebar, RB_GETBANDINFOA, 0, (LPARAM)&bi);
1045 ok(ret, "RB_GETBANDINFOA failed\n");
1046 compare(bi.clrFore, RGB(0, 0, 0), "%x");
1048 DestroyWindow(hRebar);
1052 static BOOL register_parent_wnd_class(void)
1054 WNDCLASSA wc;
1056 wc.style = CS_HREDRAW | CS_VREDRAW;
1057 wc.cbClsExtra = 0;
1058 wc.cbWndExtra = 0;
1059 wc.hInstance = GetModuleHandleA(NULL);
1060 wc.hIcon = NULL;
1061 wc.hCursor = LoadCursorA(NULL, (LPCSTR)IDC_IBEAM);
1062 wc.hbrBackground = GetSysColorBrush(COLOR_WINDOW);
1063 wc.lpszMenuName = NULL;
1064 wc.lpszClassName = "MyTestWnd";
1065 wc.lpfnWndProc = parent_wndproc;
1067 return RegisterClassA(&wc);
1070 static HWND create_parent_window(void)
1072 HWND hwnd;
1074 if (!register_parent_wnd_class()) return NULL;
1076 hwnd = CreateWindowExA(0, "MyTestWnd", "Blah", WS_OVERLAPPEDWINDOW,
1077 CW_USEDEFAULT, CW_USEDEFAULT, 672+2*GetSystemMetrics(SM_CXSIZEFRAME),
1078 226+GetSystemMetrics(SM_CYCAPTION)+2*GetSystemMetrics(SM_CYSIZEFRAME),
1079 NULL, NULL, GetModuleHandleA(NULL), 0);
1081 ShowWindow(hwnd, SW_SHOW);
1082 return hwnd;
1085 static void test_showband(void)
1087 HWND hRebar;
1088 REBARBANDINFOA rbi;
1089 BOOL ret;
1091 hRebar = create_rebar_control();
1093 /* no bands */
1094 ret = SendMessageA(hRebar, RB_SHOWBAND, 0, TRUE);
1095 ok(ret == FALSE, "got %d\n", ret);
1097 rbi.cbSize = REBARBANDINFOA_V6_SIZE;
1098 rbi.fMask = RBBIM_SIZE | RBBIM_CHILDSIZE | RBBIM_CHILD;
1099 rbi.cx = 200;
1100 rbi.cxMinChild = 100;
1101 rbi.cyMinChild = 30;
1102 rbi.hwndChild = NULL;
1103 SendMessageA(hRebar, RB_INSERTBANDA, -1, (LPARAM)&rbi);
1105 /* index out of range */
1106 ret = SendMessageA(hRebar, RB_SHOWBAND, 1, TRUE);
1107 ok(ret == FALSE, "got %d\n", ret);
1109 ret = SendMessageA(hRebar, RB_SHOWBAND, 0, TRUE);
1110 ok(ret == TRUE, "got %d\n", ret);
1112 DestroyWindow(hRebar);
1115 static void test_notification(void)
1117 MEASUREITEMSTRUCT mis;
1118 HWND rebar;
1120 rebar = create_rebar_control();
1122 g_parent_measureitem = 0;
1123 SendMessageA(rebar, WM_MEASUREITEM, 0, (LPARAM)&mis);
1124 ok(g_parent_measureitem == 1, "got %d\n", g_parent_measureitem);
1126 DestroyWindow(rebar);
1129 START_TEST(rebar)
1131 HMODULE hComctl32;
1132 BOOL (WINAPI *pInitCommonControlsEx)(const INITCOMMONCONTROLSEX*);
1133 INITCOMMONCONTROLSEX iccex;
1134 MSG msg;
1136 init_system_font_height();
1138 /* LoadLibrary is needed. This file has no reference to functions in comctl32 */
1139 hComctl32 = LoadLibraryA("comctl32.dll");
1140 pInitCommonControlsEx = (void*)GetProcAddress(hComctl32, "InitCommonControlsEx");
1141 if (!pInitCommonControlsEx)
1143 win_skip("InitCommonControlsEx() is missing. Skipping the tests\n");
1144 return;
1146 iccex.dwSize = sizeof(iccex);
1147 iccex.dwICC = ICC_COOL_CLASSES;
1148 pInitCommonControlsEx(&iccex);
1150 hMainWnd = create_parent_window();
1152 test_bandinfo();
1153 test_colors();
1154 test_showband();
1155 test_notification();
1157 if(!is_font_installed("System") || !is_font_installed("Tahoma"))
1159 skip("Missing System or Tahoma font\n");
1160 goto out;
1163 test_layout();
1164 test_resize();
1166 out:
1167 PostQuitMessage(0);
1168 while(GetMessageA(&msg,0,0,0)) {
1169 TranslateMessage(&msg);
1170 DispatchMessageA(&msg);
1172 DestroyWindow(hMainWnd);
1174 FreeLibrary(hComctl32);