[2/2] comctl32/tests: test Itemtext in treeview for Zero and Textcallback
André Hentschel
nerv at dawncrow.de
Fri Jan 16 12:24:02 CST 2009
Related to Bug #16466
---
dlls/comctl32/tests/treeview.c | 74 ++++++++++++++++++++++++++++++++++++++-
1 files changed, 72 insertions(+), 2 deletions(-)
diff --git a/dlls/comctl32/tests/treeview.c b/dlls/comctl32/tests/treeview.c
index 5e2746c..af65582 100644
--- a/dlls/comctl32/tests/treeview.c
+++ b/dlls/comctl32/tests/treeview.c
@@ -35,6 +35,8 @@
#define NUM_MSG_SEQUENCES 1
#define LISTVIEW_SEQ_INDEX 0
+#define compare(val, exp, format) ok((val) == (exp), #val " value " format " expected " format "\n", (val), (exp));
+
static struct msg_sequence *MsgSequences[NUM_MSG_SEQUENCES];
static const struct message FillRootSeq[] = {
@@ -71,6 +73,16 @@ static const struct message DoTest3Seq[] = {
{ 0 }
};
+static const struct message DoTest4Seq[] = {
+ { TVM_INSERTITEM, sent },
+ { TVM_GETITEM, sent },
+ { TVM_DELETEITEM, sent },
+ { TVM_INSERTITEM, sent },
+ { TVM_GETITEM, sent },
+ { TVM_DELETEITEM, sent },
+ { 0 }
+};
+
static const struct message DoFocusTestSeq[] = {
{ TVM_INSERTITEM, sent },
{ TVM_INSERTITEM, sent },
@@ -331,6 +343,52 @@ static void DoTest3(void)
ok(SendMessageA(hTree, TVM_DELETEITEM, 0, (LPARAM)hChild), "DeleteItem failed\n");
}
+static void DoTest4(void)
+{
+ TVINSERTSTRUCTA ins;
+ HTREEITEM hChild;
+ TVITEM tvi;
+
+ int nBufferSize = 80;
+ CHAR szBuffer[80] = "Blah";
+
+ /* add an item with TVIF_TEXT mask and pszText == LPSTR_TEXTCALLBACKA */
+ ins.hParent = hRoot;
+ ins.hInsertAfter = TVI_ROOT;
+ U(ins).item.mask = TVIF_TEXT;
+ U(ins).item.pszText = LPSTR_TEXTCALLBACKA;
+ hChild = TreeView_InsertItem(hTree, &ins);
+ assert(hChild);
+
+ /* retrieve it with TVIF_TEXT mask */
+ tvi.hItem = hChild;
+ tvi.mask = TVIF_TEXT;
+ tvi.cchTextMax = nBufferSize;
+ tvi.pszText = szBuffer;
+
+ SendMessageA( hTree, TVM_GETITEM, 0, (LPARAM)&tvi );
+ ok(!strcmp(szBuffer, ""), "szBuffer=\"%s\", expected \"\"\n", szBuffer);
+ ok(SendMessageA(hTree, TVM_DELETEITEM, 0, (LPARAM)hChild), "DeleteItem failed\n");
+
+ /* add an item with TVIF_TEXT mask and pszText == 0 */
+ ins.hParent = hRoot;
+ ins.hInsertAfter = TVI_ROOT;
+ U(ins).item.mask = TVIF_TEXT;
+ U(ins).item.pszText = 0;
+ hChild = TreeView_InsertItem(hTree, &ins);
+ assert(hChild);
+
+ /* retrieve it with TVIF_TEXT mask */
+ tvi.hItem = hChild;
+ tvi.mask = TVIF_TEXT;
+ tvi.cchTextMax = nBufferSize;
+ tvi.pszText = szBuffer;
+
+ SendMessageA( hTree, TVM_GETITEM, 0, (LPARAM)&tvi );
+ ok(!strcmp(szBuffer, ""), "szBuffer=\"%s\", expected \"\"\n", szBuffer);
+ ok(SendMessageA(hTree, TVM_DELETEITEM, 0, (LPARAM)hChild), "DeleteItem failed\n");
+}
+
static void DoFocusTest(void)
{
TVINSERTSTRUCTA ins;
@@ -649,6 +707,8 @@ static LRESULT CALLBACK MyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa
case WM_NOTIFY:
{
NMHDR *pHdr = (NMHDR *)lParam;
+ NMTVDISPINFO *nmdisp;
+ TVITEMA *nmitem;
ok(pHdr->code != NM_FIRST - 19, "Treeview should not send NM_TOOLTIPSCREATED\n");
if (pHdr->idFrom == 100) {
@@ -658,12 +718,18 @@ static LRESULT CALLBACK MyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa
AddItem('(');
IdentifyItem(pTreeView->itemOld.hItem);
IdentifyItem(pTreeView->itemNew.hItem);
- return 0;
+ break;
case TVN_SELCHANGEDA:
AddItem(')');
IdentifyItem(pTreeView->itemOld.hItem);
IdentifyItem(pTreeView->itemNew.hItem);
- return 0;
+ break;
+ case TVN_GETDISPINFOA:
+ nmdisp = (NMTVDISPINFOA *)lParam;
+ nmitem = (TVITEMA *)&nmdisp->item;
+ compare(nmitem->mask, TVIF_TEXT, "%x");
+ ok(nmitem->pszText != NULL, "pszText is NULL\n");
+ break;
}
}
return 0;
@@ -738,6 +804,10 @@ START_TEST(treeview)
flush_sequences(MsgSequences, NUM_MSG_SEQUENCES);
DoTest3();
ok_sequence(MsgSequences, LISTVIEW_SEQ_INDEX, DoTest3Seq, "DoTest3", FALSE);
+
+ flush_sequences(MsgSequences, NUM_MSG_SEQUENCES);
+ DoTest4();
+ ok_sequence(MsgSequences, LISTVIEW_SEQ_INDEX, DoTest4Seq, "DoTest4", FALSE);
flush_sequences(MsgSequences, NUM_MSG_SEQUENCES);
DoFocusTest();
--
1.6.0.4
--------------030901020502040004060607--
More information about the wine-patches
mailing list