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
27 #include "wine/test.h"
32 #define expect_eq(expr, value, type, format) { type ret = expr; ok((value) == ret, #expr " expected " format " got " format "\n", (value), (ret)); }
34 static void rebuild_rebar(HWND *hRebar)
37 DestroyWindow(*hRebar);
39 *hRebar = CreateWindow(REBARCLASSNAME, NULL, WS_CHILD | WS_VISIBLE, 0, 0, 0, 0,
40 hMainWnd, (HMENU)17, GetModuleHandle(NULL), NULL);
41 SendMessageA(*hRebar, WM_SETFONT, (WPARAM)GetStockObject(SYSTEM_FONT), 0);
44 static LRESULT CALLBACK MyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
46 return DefWindowProcA(hWnd, msg, wParam, lParam);
49 static void expect_band_content(UINT uBand, UINT fStyle, COLORREF clrFore,
50 COLORREF clrBack, LPCSTR lpText, int iImage, HWND hwndChild,
51 UINT cxMinChild, UINT cyMinChild, UINT cx, HBITMAP hbmBack, UINT wID,
52 /*UINT cyChild, UINT cyMaxChild, UINT cyIntegral,*/ UINT cxIdeal, LPARAM lParam,
55 CHAR buf[MAX_PATH] = "abc";
58 memset(&rb, 0xdd, sizeof(rb));
59 rb.cbSize = sizeof(rb);
60 rb.fMask = RBBIM_BACKGROUND | RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_COLORS
61 | RBBIM_HEADERSIZE | RBBIM_ID | RBBIM_IDEALSIZE | RBBIM_IMAGE | RBBIM_LPARAM
62 | RBBIM_SIZE | RBBIM_STYLE | RBBIM_TEXT;
65 ok(SendMessageA(hRebar, RB_GETBANDINFOA, uBand, (LPARAM)&rb), "RB_GETBANDINFO failed\n");
66 expect_eq(rb.fStyle, fStyle, int, "%x");
67 todo_wine expect_eq(rb.clrFore, clrFore, COLORREF, "%x");
68 todo_wine expect_eq(rb.clrBack, clrBack, int, "%x");
69 expect_eq(strcmp(rb.lpText, lpText), 0, int, "%d");
70 expect_eq(rb.iImage, iImage, int, "%x");
71 expect_eq(rb.hwndChild, hwndChild, HWND, "%p");
72 expect_eq(rb.cxMinChild, cxMinChild, int, "%d");
73 expect_eq(rb.cyMinChild, cyMinChild, int, "%d");
74 expect_eq(rb.cx, cx, int, "%d");
75 expect_eq(rb.hbmBack, hbmBack, HBITMAP, "%p");
76 expect_eq(rb.wID, wID, int, "%d");
77 /* in Windows the values of cyChild, cyMaxChild and cyIntegral can't be read */
78 todo_wine expect_eq(rb.cyChild, 0xdddddddd, int, "%x");
79 todo_wine expect_eq(rb.cyMaxChild, 0xdddddddd, int, "%x");
80 todo_wine expect_eq(rb.cyIntegral, 0xdddddddd, int, "%x");
81 expect_eq(rb.cxIdeal, cxIdeal, int, "%d");
82 expect_eq(rb.lParam, lParam, LPARAM, "%lx");
83 expect_eq(rb.cxHeader, cxHeader, int, "%d");
86 static void bandinfo_test()
90 CHAR szABCD[] = "ABCD";
92 rebuild_rebar(&hRebar);
93 rb.cbSize = sizeof(REBARBANDINFO);
95 ok(SendMessageA(hRebar, RB_INSERTBANDA, 0, (LPARAM)&rb), "RB_INSERTBAND failed\n");
96 expect_band_content(0, 0, 0, GetSysColor(COLOR_3DFACE), "", -1, NULL, 0, 0, 0, NULL, 0, 0, 0, 0);
98 rb.fMask = RBBIM_CHILDSIZE;
104 ok(SendMessageA(hRebar, RB_SETBANDINFOA, 0, (LPARAM)&rb), "RB_INSERTBAND failed\n");
105 expect_band_content(0, 0, 0, GetSysColor(COLOR_3DFACE), "", -1, NULL, 15, 20, 0, NULL, 0, 0, 0, 0);
107 rb.fMask = RBBIM_TEXT;
109 ok(SendMessageA(hRebar, RB_SETBANDINFOA, 0, (LPARAM)&rb), "RB_INSERTBAND failed\n");
110 expect_band_content(0, 0, 0, GetSysColor(COLOR_3DFACE), "ABC", -1, NULL, 15, 20, 0, NULL, 0, 0, 0, 35);
112 rb.cbSize = sizeof(REBARBANDINFO);
114 ok(SendMessageA(hRebar, RB_INSERTBANDA, 1, (LPARAM)&rb), "RB_INSERTBAND failed\n");
115 expect_band_content(1, 0, 0, GetSysColor(COLOR_3DFACE), "", -1, NULL, 0, 0, 0, NULL, 0, 0, 0, 9);
116 expect_band_content(0, 0, 0, GetSysColor(COLOR_3DFACE), "ABC", -1, NULL, 15, 20, 0, NULL, 0, 0, 0, 40);
118 rb.fMask = RBBIM_HEADERSIZE;
120 ok(SendMessageA(hRebar, RB_SETBANDINFOA, 0, (LPARAM)&rb), "RB_INSERTBAND failed\n");
121 expect_band_content(0, 0x40000000, 0, GetSysColor(COLOR_3DFACE), "ABC", -1, NULL, 15, 20, 0, NULL, 0, 0, 0, 50);
124 ok(SendMessageA(hRebar, RB_SETBANDINFOA, 0, (LPARAM)&rb), "RB_INSERTBAND failed\n");
125 expect_band_content(0, 0x40000000, 0, GetSysColor(COLOR_3DFACE), "ABC", -1, NULL, 15, 20, 0, NULL, 0, 0, 0, 5);
127 rb.fMask = RBBIM_TEXT;
129 ok(SendMessageA(hRebar, RB_SETBANDINFOA, 0, (LPARAM)&rb), "RB_INSERTBAND failed\n");
130 expect_band_content(0, 0x40000000, 0, GetSysColor(COLOR_3DFACE), "ABCD", -1, NULL, 15, 20, 0, NULL, 0, 0, 0, 5);
131 rb.fMask = RBBIM_STYLE | RBBIM_TEXT;
134 ok(SendMessageA(hRebar, RB_SETBANDINFOA, 0, (LPARAM)&rb), "RB_INSERTBAND failed\n");
135 expect_band_content(0, 0, 0, GetSysColor(COLOR_3DFACE), "ABC", -1, NULL, 15, 20, 0, NULL, 0, 0, 0, 40);
137 DestroyWindow(hRebar);
142 INITCOMMONCONTROLSEX icc;
147 icc.dwSize = sizeof(icc);
148 icc.dwICC = ICC_COOL_CLASSES;
149 InitCommonControlsEx(&icc);
151 wc.style = CS_HREDRAW | CS_VREDRAW;
154 wc.hInstance = GetModuleHandleA(NULL);
156 wc.hCursor = LoadCursorA(NULL, MAKEINTRESOURCEA(IDC_IBEAM));
157 wc.hbrBackground = GetSysColorBrush(COLOR_WINDOW);
158 wc.lpszMenuName = NULL;
159 wc.lpszClassName = "MyTestWnd";
160 wc.lpfnWndProc = MyWndProc;
163 hMainWnd = CreateWindowExA(0, "MyTestWnd", "Blah", WS_OVERLAPPEDWINDOW,
164 CW_USEDEFAULT, CW_USEDEFAULT, 680, 260, NULL, NULL, GetModuleHandleA(NULL), 0);
165 GetClientRect(hMainWnd, &rc);
166 ShowWindow(hMainWnd, SW_SHOW);
170 while(GetMessageA(&msg,0,0,0)) {
171 TranslateMessage(&msg);
172 DispatchMessageA(&msg);
174 DestroyWindow(hMainWnd);