[PATCH] comctl32/tests: Test LVM_SORTITEMS sorting.
Haoyang Chen
chenhaoyang at uniontech.com
Mon Apr 5 21:30:43 CDT 2021
Signed-off-by: Haoyang Chen <chenhaoyang at uniontech.com>
---
dlls/comctl32/tests/listview.c | 67 ++++++++++++++++++++++++++++++++++
1 file changed, 67 insertions(+)
diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c
index e95b81f5bb1..88a9d518406 100644
--- a/dlls/comctl32/tests/listview.c
+++ b/dlls/comctl32/tests/listview.c
@@ -2921,6 +2921,28 @@ static INT WINAPI test_CallBackCompare(LPARAM first, LPARAM second, LPARAM lPara
return (first > second ? 1 : -1);
}
+static INT WINAPI test_CallBackCompare1(LPARAM first, LPARAM second, LPARAM lParam)
+{
+ CHAR str1[5];
+ CHAR str2[5];
+ INT r;
+ HWND hwnd = (HWND)lParam;
+ LV_ITEMA item = {0};
+
+ if (first == second) return 0;
+ item.cchTextMax = 5;
+ item.iSubItem = 0;
+ item.pszText = str1;
+ r = SendMessageA(hwnd, LVM_GETITEMTEXTA, first, (LPARAM)&item);
+ expect(TRUE, r);
+
+ item.pszText = str2;
+ r = SendMessageA(hwnd, LVM_GETITEMTEXTA, second, (LPARAM)&item);
+ expect(TRUE, r);
+
+ return atoi(str1) > atoi(str2) ? 1 : -1;
+}
+
static void test_sorting(void)
{
HWND hwnd;
@@ -2929,6 +2951,10 @@ static void test_sorting(void)
LONG_PTR style;
static CHAR names[][5] = {"A", "B", "C", "D", "0"};
CHAR buff[10];
+ static CHAR before_sort_array[][5] = {"6","3","1","4","2"};
+ static CHAR after_sort_arary[][5] = {"1","2","3","4","6"};
+ INT i;
+ LVCOLUMNA lvc;
hwnd = create_listview_control(LVS_REPORT);
ok(hwnd != NULL, "failed to create a listview window\n");
@@ -3096,6 +3122,47 @@ static void test_sorting(void)
expect(TRUE, r);
ok(lstrcmpA(buff, names[3]) == 0, "Expected '%s', got '%s'\n", names[3], buff);
+ DestroyWindow(hwnd);
+
+ hwnd = create_listview_control(LVS_REPORT);
+ ok(hwnd != NULL, "failed to create a listview window\n");
+
+ lvc.mask = LVCF_TEXT | LVCF_WIDTH;
+ lvc.pszText = names[0];
+ lvc.cx = 50;
+
+ SendMessageA(hwnd, LVM_INSERTCOLUMNA, 0, (LPARAM)&lvc);
+ SendMessageA(hwnd, LVM_INSERTCOLUMNA, 1, (LPARAM)&lvc);
+
+ item.mask = LVIF_PARAM | LVIF_TEXT;
+ item.iSubItem = 0;
+ item.cchTextMax = 5;
+
+ for (i = 0; i < sizeof(before_sort_array)/5; i++)
+ {
+ item.iItem = i;
+ item.lParam = i;
+ item.pszText = &before_sort_array[i][0];
+ r = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM)&item);
+ expect(i, r);
+ }
+
+ r = SendMessageA(hwnd, LVM_SORTITEMS, (WPARAM)(LPARAM)hwnd, (LPARAM)test_CallBackCompare1);
+ expect(TRUE, r);
+
+ for (i = 0; i < sizeof(after_sort_arary)/5; i++)
+ {
+ CHAR str[5];
+ item.iItem = i;
+ item.cchTextMax = 5;
+ item.iSubItem = 0;
+ item.pszText = str;
+ r = SendMessageA(hwnd, LVM_GETITEMTEXTA, i, (LPARAM)&item);
+ expect(TRUE, r);
+
+ expect(atoi(after_sort_arary[i]), atoi(str));
+ }
+
DestroyWindow(hwnd);
}
--
2.20.1
More information about the wine-devel
mailing list