[PATCH 08/10] Add a test for TCM_SETITEMEXTRA
Nikolay Sivov
nsivov at codeweavers.com
Sun Sep 26 15:11:41 CDT 2010
---
dlls/comctl32/tab.c | 9 +---
dlls/comctl32/tests/tab.c | 126 +++++++++++++++++++++++++++++---------------
2 files changed, 84 insertions(+), 51 deletions(-)
diff --git a/dlls/comctl32/tab.c b/dlls/comctl32/tab.c
index 8807a11..0ecbb63 100644
--- a/dlls/comctl32/tab.c
+++ b/dlls/comctl32/tab.c
@@ -3190,15 +3190,8 @@ TAB_SetItemExtra (TAB_INFO *infoPtr, INT cbInfo)
{
TRACE("(%p %d)\n", infoPtr, cbInfo);
- if (cbInfo <= 0)
- return FALSE;
+ if (cbInfo < 0 || infoPtr->uNumItem) return FALSE;
- if (infoPtr->uNumItem)
- {
- /* FIXME: MSDN says this is not allowed, but this hasn't been verified */
- return FALSE;
- }
-
infoPtr->cbInfo = cbInfo;
return TRUE;
}
diff --git a/dlls/comctl32/tests/tab.c b/dlls/comctl32/tests/tab.c
index 6774d51..5f466a7 100644
--- a/dlls/comctl32/tests/tab.c
+++ b/dlls/comctl32/tests/tab.c
@@ -61,7 +61,8 @@
"%s: Expected [%d,%d] got [%d,%d]\n", msg, (int)width, (int)height,\
rTab.right - rTab.left, rTab.bottom - rTab.top);
-static HFONT hFont = 0;
+static HFONT hFont;
+static HWND parent_wnd;
static struct msg_sequence *sequences[NUM_MSG_SEQUENCES];
@@ -638,20 +639,20 @@ static void test_tab(INT nMinTabWidth)
DeleteObject(hFont);
}
-static void test_curfocus(HWND parent_wnd, INT nTabs)
+static void test_curfocus(void)
{
INT focusIndex;
HWND hTab;
- hTab = createFilledTabControl(parent_wnd, TCS_FIXEDWIDTH, TCIF_TEXT|TCIF_IMAGE, nTabs);
+ hTab = createFilledTabControl(parent_wnd, TCS_FIXEDWIDTH, TCIF_TEXT|TCIF_IMAGE, 5);
ok(hTab != NULL, "Failed to create tab control\n");
flush_sequences(sequences, NUM_MSG_SEQUENCES);
/* Testing CurFocus with largest appropriate value */
- SendMessage(hTab, TCM_SETCURFOCUS, nTabs-1, 0);
+ SendMessage(hTab, TCM_SETCURFOCUS, 4, 0);
focusIndex = SendMessage(hTab, TCM_GETCURFOCUS, 0, 0);
- expect(nTabs-1, focusIndex);
+ expect(4, focusIndex);
/* Testing CurFocus with negative value */
SendMessage(hTab, TCM_SETCURFOCUS, -10, 0);
@@ -662,7 +663,7 @@ static void test_curfocus(HWND parent_wnd, INT nTabs)
focusIndex = SendMessage(hTab, TCM_SETCURSEL, 1, 0);
expect(-1, focusIndex);
- SendMessage(hTab, TCM_SETCURFOCUS, nTabs+1, 0);
+ SendMessage(hTab, TCM_SETCURFOCUS, 6, 0);
focusIndex = SendMessage(hTab, TCM_GETCURFOCUS, 0, 0);
expect(1, focusIndex);
@@ -671,27 +672,27 @@ static void test_curfocus(HWND parent_wnd, INT nTabs)
DestroyWindow(hTab);
}
-static void test_cursel(HWND parent_wnd, INT nTabs)
+static void test_cursel(void)
{
INT selectionIndex;
INT focusIndex;
TCITEM tcItem;
HWND hTab;
- hTab = createFilledTabControl(parent_wnd, TCS_FIXEDWIDTH, TCIF_TEXT|TCIF_IMAGE, nTabs);
+ hTab = createFilledTabControl(parent_wnd, TCS_FIXEDWIDTH, TCIF_TEXT|TCIF_IMAGE, 5);
ok(hTab != NULL, "Failed to create tab control\n");
flush_sequences(sequences, NUM_MSG_SEQUENCES);
/* Testing CurSel with largest appropriate value */
- selectionIndex = SendMessage(hTab, TCM_SETCURSEL, nTabs-1, 0);
+ selectionIndex = SendMessage(hTab, TCM_SETCURSEL, 4, 0);
expect(0, selectionIndex);
selectionIndex = SendMessage(hTab, TCM_GETCURSEL, 0, 0);
- expect(nTabs-1, selectionIndex);
+ expect(4, selectionIndex);
/* Focus should switch with selection */
focusIndex = SendMessage(hTab, TCM_GETCURFOCUS, 0, 0);
- expect(nTabs-1, focusIndex);
+ expect(4, focusIndex);
/* Testing CurSel with negative value */
SendMessage(hTab, TCM_SETCURSEL, -10, 0);
@@ -702,7 +703,7 @@ static void test_cursel(HWND parent_wnd, INT nTabs)
selectionIndex = SendMessage(hTab, TCM_SETCURSEL, 1, 0);
expect(-1, selectionIndex);
- selectionIndex = SendMessage(hTab, TCM_SETCURSEL, nTabs+1, 0);
+ selectionIndex = SendMessage(hTab, TCM_SETCURSEL, 6, 0);
expect(-1, selectionIndex);
selectionIndex = SendMessage(hTab, TCM_GETCURFOCUS, 0, 0);
expect(1, selectionIndex);
@@ -723,13 +724,13 @@ static void test_cursel(HWND parent_wnd, INT nTabs)
DestroyWindow(hTab);
}
-static void test_extendedstyle(HWND parent_wnd, INT nTabs)
+static void test_extendedstyle(void)
{
DWORD prevExtendedStyle;
DWORD extendedStyle;
HWND hTab;
- hTab = createFilledTabControl(parent_wnd, TCS_FIXEDWIDTH, TCIF_TEXT|TCIF_IMAGE, nTabs);
+ hTab = createFilledTabControl(parent_wnd, TCS_FIXEDWIDTH, TCIF_TEXT|TCIF_IMAGE, 5);
ok(hTab != NULL, "Failed to create tab control\n");
flush_sequences(sequences, NUM_MSG_SEQUENCES);
@@ -757,12 +758,12 @@ static void test_extendedstyle(HWND parent_wnd, INT nTabs)
DestroyWindow(hTab);
}
-static void test_unicodeformat(HWND parent_wnd, INT nTabs)
+static void test_unicodeformat(void)
{
INT unicodeFormat;
HWND hTab;
- hTab = createFilledTabControl(parent_wnd, TCS_FIXEDWIDTH, TCIF_TEXT|TCIF_IMAGE, nTabs);
+ hTab = createFilledTabControl(parent_wnd, TCS_FIXEDWIDTH, TCIF_TEXT|TCIF_IMAGE, 5);
ok(hTab != NULL, "Failed to create tab control\n");
flush_sequences(sequences, NUM_MSG_SEQUENCES);
@@ -788,14 +789,14 @@ static void test_unicodeformat(HWND parent_wnd, INT nTabs)
DestroyWindow(hTab);
}
-static void test_getset_item(HWND parent_wnd, INT nTabs)
+static void test_getset_item(void)
{
TCITEM tcItem;
DWORD ret;
char szText[32] = "New Label";
HWND hTab;
- hTab = createFilledTabControl(parent_wnd, TCS_FIXEDWIDTH, TCIF_TEXT|TCIF_IMAGE, nTabs);
+ hTab = createFilledTabControl(parent_wnd, TCS_FIXEDWIDTH, TCIF_TEXT|TCIF_IMAGE, 5);
ok(hTab != NULL, "Failed to create tab control\n");
/* passing invalid index should result in initialization to zero
@@ -898,12 +899,12 @@ static void test_getset_item(HWND parent_wnd, INT nTabs)
DestroyWindow(hTab);
}
-static void test_getset_tooltips(HWND parent_wnd, INT nTabs)
+static void test_getset_tooltips(void)
{
HWND hTab, toolTip;
char toolTipText[32] = "ToolTip Text Test";
- hTab = createFilledTabControl(parent_wnd, TCS_FIXEDWIDTH, TCIF_TEXT|TCIF_IMAGE, nTabs);
+ hTab = createFilledTabControl(parent_wnd, TCS_FIXEDWIDTH, TCIF_TEXT|TCIF_IMAGE, 5);
ok(hTab != NULL, "Failed to create tab control\n");
flush_sequences(sequences, NUM_MSG_SEQUENCES);
@@ -921,7 +922,7 @@ static void test_getset_tooltips(HWND parent_wnd, INT nTabs)
DestroyWindow(hTab);
}
-static void test_misc(HWND parent_wnd, INT nTabs)
+static void test_misc(void)
{
HWND hTab;
RECT rTab;
@@ -933,7 +934,7 @@ static void test_misc(HWND parent_wnd, INT nTabs)
ok(parent_wnd != NULL, "no parent window!\n");
flush_sequences(sequences, NUM_MSG_SEQUENCES);
- hTab = createFilledTabControl(parent_wnd, TCS_FIXEDWIDTH, TCIF_TEXT|TCIF_IMAGE, nTabs);
+ hTab = createFilledTabControl(parent_wnd, TCS_FIXEDWIDTH, TCIF_TEXT|TCIF_IMAGE, 5);
ok(hTab != NULL, "Failed to create tab control\n");
if(!winetest_interactive)
@@ -957,7 +958,7 @@ static void test_misc(HWND parent_wnd, INT nTabs)
/* Testing GetItemCount */
flush_sequences(sequences, NUM_MSG_SEQUENCES);
nTabsRetrieved = SendMessage(hTab, TCM_GETITEMCOUNT, 0, 0);
- expect(nTabs, nTabsRetrieved);
+ expect(5, nTabsRetrieved);
ok_sequence(sequences, TAB_SEQ_INDEX, get_item_count_seq, "Get itemCount test sequence", FALSE);
ok_sequence(sequences, PARENT_SEQ_INDEX, empty_sequence, "Getset itemCount test parent sequence", FALSE);
@@ -982,7 +983,7 @@ static void test_misc(HWND parent_wnd, INT nTabs)
DestroyWindow(hTab);
}
-static void test_adjustrect(HWND parent_wnd)
+static void test_adjustrect(void)
{
HWND hTab;
INT r;
@@ -997,9 +998,11 @@ static void test_adjustrect(HWND parent_wnd)
r = SendMessage(hTab, TCM_ADJUSTRECT, TRUE, 0);
expect(-1, r);
+
+ DestroyWindow(hTab);
}
-static void test_insert_focus(HWND parent_wnd)
+static void test_insert_focus(void)
{
HWND hTab;
INT nTabsRetrieved;
@@ -1062,7 +1065,7 @@ static void test_insert_focus(HWND parent_wnd)
DestroyWindow(hTab);
}
-static void test_delete_focus(HWND parent_wnd)
+static void test_delete_focus(void)
{
HWND hTab;
INT nTabsRetrieved;
@@ -1111,7 +1114,7 @@ static void test_delete_focus(HWND parent_wnd)
DestroyWindow(hTab);
}
-static void test_removeimage(HWND parent_wnd)
+static void test_removeimage(void)
{
static const BYTE bits[32];
HWND hwTab;
@@ -1174,7 +1177,7 @@ static void test_removeimage(HWND parent_wnd)
DestroyIcon(hicon);
}
-static void test_delete_selection(HWND parent_wnd)
+static void test_delete_selection(void)
{
HWND hTab;
DWORD ret;
@@ -1196,9 +1199,45 @@ static void test_delete_selection(HWND parent_wnd)
DestroyWindow(hTab);
}
+static void test_TCM_SETITEMEXTRA(void)
+{
+ HWND hTab;
+ DWORD ret;
+
+ hTab = CreateWindowA(
+ WC_TABCONTROLA,
+ "TestTab",
+ WS_CLIPSIBLINGS | WS_CLIPCHILDREN | TCS_FOCUSNEVER | TCS_FIXEDWIDTH,
+ 10, 10, 300, 100,
+ parent_wnd, NULL, NULL, 0);
+
+ /* zero is valid size too */
+ ret = SendMessageA(hTab, TCM_SETITEMEXTRA, 0, 0);
+ if (ret == FALSE)
+ {
+ win_skip("TCM_SETITEMEXTRA not supported\n");
+ DestroyWindow(hTab);
+ return;
+ }
+
+ ret = SendMessageA(hTab, TCM_SETITEMEXTRA, -1, 0);
+ ok(ret == FALSE, "got %d\n", ret);
+
+ ret = SendMessageA(hTab, TCM_SETITEMEXTRA, 2, 0);
+ ok(ret == TRUE, "got %d\n", ret);
+ DestroyWindow(hTab);
+
+ /* it's not possible to change extra data size for control with tabs */
+ hTab = createFilledTabControl(parent_wnd, TCS_FIXEDWIDTH, TCIF_TEXT|TCIF_IMAGE, 4);
+ ok(hTab != NULL, "Failed to create tab control\n");
+
+ ret = SendMessageA(hTab, TCM_SETITEMEXTRA, 2, 0);
+ ok(ret == FALSE, "got %d\n", ret);
+ DestroyWindow(hTab);
+}
+
START_TEST(tab)
{
- HWND parent_wnd;
LOGFONTA logfont;
lstrcpyA(logfont.lfFaceName, "Arial");
@@ -1226,20 +1265,21 @@ START_TEST(tab)
parent_wnd = createParentWindow();
ok(parent_wnd != NULL, "Failed to create parent window!\n");
- test_curfocus(parent_wnd, 5);
- test_cursel(parent_wnd, 5);
- test_extendedstyle(parent_wnd, 5);
- test_unicodeformat(parent_wnd, 5);
- test_getset_item(parent_wnd, 5);
- test_getset_tooltips(parent_wnd, 5);
- test_misc(parent_wnd, 5);
-
- test_adjustrect(parent_wnd);
-
- test_insert_focus(parent_wnd);
- test_delete_focus(parent_wnd);
- test_delete_selection(parent_wnd);
- test_removeimage(parent_wnd);
+ test_curfocus();
+ test_cursel();
+ test_extendedstyle();
+ test_unicodeformat();
+ test_getset_item();
+ test_getset_tooltips();
+ test_misc();
+
+ test_adjustrect();
+
+ test_insert_focus();
+ test_delete_focus();
+ test_delete_selection();
+ test_removeimage();
+ test_TCM_SETITEMEXTRA();
DestroyWindow(parent_wnd);
}
--
1.5.6.5
--------------080203010709010807030304--
More information about the wine-patches
mailing list