dlls/comctl32/tests/tab.c: Transform CheckSize from a macro to a function.
Gerald Pfeifer
gerald at pfeifer.com
Sat Sep 19 15:40:14 CDT 2009
This not only avoids a 12+ line macro, it also sheds a couple of
compiler warnings with GCC 4.4 (though not the forthcoming 4.5).
Gerald
ChangeLog:
Transform CheckSize from a macro to a function.
diff --git a/dlls/comctl32/tests/tab.c b/dlls/comctl32/tests/tab.c
index f017b13..4d094b9 100644
--- a/dlls/comctl32/tests/tab.c
+++ b/dlls/comctl32/tests/tab.c
@@ -41,25 +41,27 @@
#define TabWidthPadded(padd_x, num) (DEFAULT_MIN_TAB_WIDTH - (TAB_PADDING_X - (padd_x)) * num)
+static void CheckSize(HWND hwnd, RECT rTab, int width, int height, const char *msg)
+{
+ SendMessage (hwnd, TCM_GETITEMRECT, 0, (LPARAM) &rTab);
+ if ((width >= 0) && (height < 0))
+ ok (width == rTab.right - rTab.left, "%s: Expected width [%d] got [%d]\n",
+ msg, (int)width, rTab.right - rTab.left);
+ else if ((height >= 0) && (width < 0))
+ ok (height == rTab.bottom - rTab.top, "%s: Expected height [%d] got [%d]\n",
+ msg, (int)height, rTab.bottom - rTab.top);
+ else
+ ok ((width == rTab.right - rTab.left) &&
+ (height == rTab.bottom - rTab.top ),
+ "%s: Expected [%d,%d] got [%d,%d]\n", msg, (int)width, (int)height,
+ rTab.right - rTab.left, rTab.bottom - rTab.top);
+}
+
#define TabCheckSetSize(hwnd, SetWidth, SetHeight, ExpWidth, ExpHeight, Msg)\
SendMessage (hwnd, TCM_SETITEMSIZE, 0,\
(LPARAM) MAKELPARAM((SetWidth >= 0) ? SetWidth:0, (SetHeight >= 0) ? SetHeight:0));\
if (winetest_interactive) RedrawWindow (hwnd, NULL, 0, RDW_UPDATENOW);\
- CheckSize(hwnd, ExpWidth, ExpHeight, Msg);
-
-#define CheckSize(hwnd,width,height,msg)\
- SendMessage (hwnd, TCM_GETITEMRECT, 0, (LPARAM) &rTab);\
- if ((width >= 0) && (height < 0))\
- ok (width == rTab.right - rTab.left, "%s: Expected width [%d] got [%d]\n",\
- msg, (int)width, rTab.right - rTab.left);\
- else if ((height >= 0) && (width < 0))\
- ok (height == rTab.bottom - rTab.top, "%s: Expected height [%d] got [%d]\n",\
- msg, (int)height, rTab.bottom - rTab.top);\
- else\
- ok ((width == rTab.right - rTab.left) &&\
- (height == rTab.bottom - rTab.top ),\
- "%s: Expected [%d,%d] got [%d,%d]\n", msg, (int)width, (int)height,\
- rTab.right - rTab.left, rTab.bottom - rTab.top);
+ CheckSize(hwnd, rTab, ExpWidth, ExpHeight, Msg);
static HFONT hFont = 0;
@@ -526,7 +528,7 @@ static void test_tab(INT nMinTabWidth)
ReleaseDC(hwTab, hdc);
trace (" TCS_FIXEDWIDTH tabs no icon...\n");
- CheckSize(hwTab, dpi, -1, "default width");
+ CheckSize(hwTab, rTab, dpi, -1, "default width");
TabCheckSetSize(hwTab, 50, 20, 50, 20, "set size");
TabCheckSetSize(hwTab, 0, 1, 0, 1, "min size");
@@ -546,7 +548,7 @@ static void test_tab(INT nMinTabWidth)
dpi = GetDeviceCaps(hdc, LOGPIXELSX);
ReleaseDC(hwTab, hdc);
trace (" TCS_FIXEDWIDTH buttons no icon...\n");
- CheckSize(hwTab, dpi, -1, "default width");
+ CheckSize(hwTab, rTab, dpi, -1, "default width");
TabCheckSetSize(hwTab, 20, 20, 20, 20, "set size 1");
TabCheckSetSize(hwTab, 10, 50, 10, 50, "set size 2");
TabCheckSetSize(hwTab, 0, 1, 0, 1, "min size");
@@ -569,7 +571,7 @@ static void test_tab(INT nMinTabWidth)
dpi = GetDeviceCaps(hdc, LOGPIXELSX);
ReleaseDC(hwTab, hdc);
trace (" TCS_FIXEDWIDTH | TCS_BOTTOM tabs...\n");
- CheckSize(hwTab, dpi, -1, "no icon, default width");
+ CheckSize(hwTab, rTab, dpi, -1, "no icon, default width");
TabCheckSetSize(hwTab, 20, 20, 20, 20, "no icon, set size 1");
TabCheckSetSize(hwTab, 10, 50, 10, 50, "no icon, set size 2");
@@ -701,7 +703,7 @@ static void test_getters_setters(HWND parent_wnd, INT nTabs)
hdc = GetDC(hTab);
dpi = GetDeviceCaps(hdc, LOGPIXELSX);
ReleaseDC(hTab, hdc);
- CheckSize(hTab, dpi, -1 , "Default Width");
+ CheckSize(hTab, rTab, dpi, -1 , "Default Width");
ok_sequence(sequences, TAB_SEQ_INDEX, get_item_rect_seq, "Get itemRect test sequence", FALSE);
ok_sequence(sequences, PARENT_SEQ_INDEX, empty_sequence, "Get itemRect test parent sequence", FALSE);
More information about the wine-patches
mailing list