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)
41 create_tabcontrol (DWORD style)
46 handle = CreateWindow (
49 WS_CLIPSIBLINGS | WS_CLIPCHILDREN | TCS_FOCUSNEVER | style,
55 tcNewTab.mask = TCIF_TEXT | TCIF_IMAGE;
56 tcNewTab.pszText = "Tab 1";
58 SendMessage (handle, TCM_INSERTITEM, 0, (LPARAM) &tcNewTab);
59 tcNewTab.pszText = "Wide Tab 2";
61 SendMessage (handle, TCM_INSERTITEM, 1, (LPARAM) &tcNewTab);
62 tcNewTab.pszText = "T 3";
64 SendMessage (handle, TCM_INSERTITEM, 2, (LPARAM) &tcNewTab);
67 ShowWindow (handle, SW_SHOW);
75 void CheckSize(HWND hwnd, INT width, INT height)
79 SendMessage (hwnd, TCM_GETITEMRECT, 1, (LPARAM) &rTab);
80 /*trace ("Got (%ld,%ld)-(%ld,%ld)\n", rTab.left, rTab.top, rTab.right, rTab.bottom);*/
81 if ((width >= 0) && (height < 0))
82 ok (width == rTab.right - rTab.left, "Expected [%d] got [%ld]", width, rTab.right - rTab.left);
83 else if ((height >= 0) && (width < 0))
84 ok (height == rTab.bottom - rTab.top, "Expected [%d] got [%ld]", height, rTab.bottom - rTab.top);
86 ok ((width == rTab.right - rTab.left) &&
87 (height == rTab.bottom - rTab.top ),
88 "Expected [%d,%d] got [%ld,%ld]", width, height, rTab.right - rTab.left, rTab.bottom - rTab.top);
91 void TabCheckSetSize(HWND hwnd, INT SetWidth, INT SetHeight, INT ExpWidth, INT ExpHeight)
93 SendMessage (hwnd, TCM_SETITEMSIZE, 0,
94 (LPARAM) MAKELPARAM((SetWidth >= 0) ? SetWidth:0, (SetHeight >= 0) ? SetHeight:0));
96 CheckSize(hwnd, ExpWidth, ExpHeight);
103 HIMAGELIST himl = ImageList_Create(21, 21, ILC_COLOR, 3, 4);
105 InitCommonControls();
108 hwTab = create_tabcontrol(TCS_FIXEDWIDTH);
110 trace ("Testing TCS_FIXEDWIDTH tabs no icon...\n");
111 trace (" default width...\n");
112 CheckSize(hwTab, TAB_DEFAULT_WIDTH, -1);
113 trace (" set size...\n");
114 TabCheckSetSize(hwTab, 50, 20, 50, 20);
116 trace (" min size...\n");
117 TabCheckSetSize(hwTab, 0, 1, 0, 1);
120 SendMessage(hwTab, TCM_SETIMAGELIST, 0, (LPARAM)himl);
122 trace ("Testing TCS_FIXEDWIDTH tabs with icon...\n");
123 trace (" set size > icon...\n");
124 TabCheckSetSize(hwTab, 50, 30, 50, 30);
126 trace (" set size < icon...\n");
127 TabCheckSetSize(hwTab, 20, 20, 25, 20);
129 trace (" min size...\n");
130 TabCheckSetSize(hwTab, 0, 1, 25, 1);
133 DestroyWindow (hwTab);
135 trace ("Testing TCS_FIXEDWIDTH buttons no icon...\n");
136 hwTab = create_tabcontrol(TCS_FIXEDWIDTH | TCS_BUTTONS);
138 trace (" default width...\n");
139 CheckSize(hwTab, TAB_DEFAULT_WIDTH, -1);
140 trace (" set size 1...\n");
141 TabCheckSetSize(hwTab, 20, 20, 20, 20);
142 trace (" set size 2...\n");
143 TabCheckSetSize(hwTab, 10, 50, 10, 50);
144 trace (" min size...\n");
145 TabCheckSetSize(hwTab, 0, 1, 0, 1);
147 SendMessage(hwTab, TCM_SETIMAGELIST, 0, (LPARAM)himl);
149 trace ("Testing TCS_FIXEDWIDTH buttons with icon...\n");
150 trace (" set size > icon...\n");
151 TabCheckSetSize(hwTab, 50, 30, 50, 30);
152 trace (" set size < icon...\n");
153 TabCheckSetSize(hwTab, 20, 20, 25, 20);
154 trace (" min size...\n");
155 TabCheckSetSize(hwTab, 0, 1, 25, 1);
157 trace (" Add padding...\n");
158 SendMessage(hwTab, TCM_SETPADDING, 0, MAKELPARAM(4,4));
159 trace (" min size...\n");
160 TabCheckSetSize(hwTab, 0, 1, 25, 1);
163 DestroyWindow (hwTab);
164 ImageList_Destroy(himl);