Nikolay Sivov : comctl32/tests: Fix wrong use of HDM_GETITEM when getting item text.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Apr 18 10:37:02 CDT 2016


Module: wine
Branch: master
Commit: 025508f75534eb9b6f60d5e2f3567a6d47d9a062
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=025508f75534eb9b6f60d5e2f3567a6d47d9a062

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Sat Apr 16 11:36:08 2016 +0300

comctl32/tests: Fix wrong use of HDM_GETITEM when getting item text.

Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/comctl32/tests/header.c | 30 ++++++++++++++++--------------
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/dlls/comctl32/tests/header.c b/dlls/comctl32/tests/header.c
index f37b72b..8245711 100644
--- a/dlls/comctl32/tests/header.c
+++ b/dlls/comctl32/tests/header.c
@@ -1078,10 +1078,7 @@ static void test_hdm_bitmapmarginMessages(HWND hParent)
 static void test_hdm_index_messages(HWND hParent)
 {
     HWND hChild;
-    int retVal;
-    int loopcnt;
-    int strcmpResult;
-    int iSize;
+    int retVal, i, iSize;
     static const int lpiarray[2] = {1, 0};
     static int lpiarrayReceived[2];
     static char firstHeaderItem[] = "Name";
@@ -1091,10 +1088,7 @@ static void test_hdm_index_messages(HWND hParent)
     static char *items[] = {firstHeaderItem, secondHeaderItem, thirdHeaderItem, fourthHeaderItem};
     RECT rect;
     HDITEMA hdItem;
-    hdItem.mask = HDI_TEXT | HDI_WIDTH | HDI_FORMAT;
-    hdItem.fmt = HDF_LEFT;
-    hdItem.cxy = 80;
-    hdItem.cchTextMax = 260;
+    char buffA[32];
 
     flush_sequences(sequences, NUM_MSG_SEQUENCES);
     hChild = create_custom_header_control(hParent, FALSE);
@@ -1105,11 +1099,15 @@ static void test_hdm_index_messages(HWND hParent)
          ok_sequence(sequences, PARENT_SEQ_INDEX, add_header_to_parent_seq,
                                      "adder header control to parent", FALSE);
     flush_sequences(sequences, NUM_MSG_SEQUENCES);
-    for ( loopcnt = 0 ; loopcnt < 4 ; loopcnt++ )
+    for (i = 0; i < sizeof(items)/sizeof(items[0]); i++)
     {
-      hdItem.pszText = items[loopcnt];
-      retVal = SendMessageA(hChild, HDM_INSERTITEMA, loopcnt, (LPARAM) &hdItem);
-      ok(retVal == loopcnt, "Adding item %d failed with return value %d\n", ( loopcnt + 1 ), retVal);
+        hdItem.mask = HDI_TEXT | HDI_WIDTH | HDI_FORMAT;
+        hdItem.pszText = items[i];
+        hdItem.fmt = HDF_LEFT;
+        hdItem.cxy = 80;
+
+        retVal = SendMessageA(hChild, HDM_INSERTITEMA, i, (LPARAM) &hdItem);
+        ok(retVal == i, "Adding item %d failed with return value %d\n", i, retVal);
     }
     ok_sequence(sequences, HEADER_SEQ_INDEX, insertItem_seq, "insertItem sequence testing", FALSE);
 
@@ -1135,17 +1133,21 @@ static void test_hdm_index_messages(HWND hParent)
 
     flush_sequences(sequences, NUM_MSG_SEQUENCES);
 
+    hdItem.mask = HDI_WIDTH;
     retVal = SendMessageA(hChild, HDM_GETITEMA, 3, (LPARAM) &hdItem);
     ok(retVal == FALSE, "Getting already-deleted item should return FALSE, got %d\n", retVal);
 
+    hdItem.mask = HDI_TEXT | HDI_WIDTH;
+    hdItem.pszText = buffA;
+    hdItem.cchTextMax = sizeof(buffA)/sizeof(buffA[0]);
     retVal = SendMessageA(hChild, HDM_GETITEMA, 0, (LPARAM) &hdItem);
     ok(retVal == TRUE, "Getting the 1st header item should return TRUE, got %d\n", retVal);
 
     ok_sequence(sequences, HEADER_SEQ_INDEX, getItem_seq, "getItem sequence testing", FALSE);
 
     /* check if the item is the right one */
-    strcmpResult =  strcmp(hdItem.pszText, firstHeaderItem);
-    expect(0, strcmpResult);
+    ok(!strcmp(hdItem.pszText, firstHeaderItem), "got wrong item %s, expected %s\n",
+        hdItem.pszText, firstHeaderItem);
     expect(80, hdItem.cxy);
 
     iSize = SendMessageA(hChild, HDM_GETITEMCOUNT, 0, 0);




More information about the wine-cvs mailing list