[PATCH 1/2] comctl32/tests: Add tests for LVM_APPROXIMATEVIEWRECT in LVS_REPORT mode.
Vadim Druzhin
cdslow at mail.ru
Thu Oct 12 10:00:50 CDT 2017
Signed-off-by: Vadim Druzhin <cdslow at mail.ru>
---
dlls/comctl32/tests/listview.c | 125 ++++++++++++++++++++++++++++++++++++++++-
1 file changed, 123 insertions(+), 2 deletions(-)
diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c
index dce253c..d69cd0a 100644
--- a/dlls/comctl32/tests/listview.c
+++ b/dlls/comctl32/tests/listview.c
@@ -4960,7 +4960,7 @@ static void test_LVS_EX_TRANSPARENTBKGND(void)
DestroyWindow(hwnd);
}
-static void test_approximate_viewrect(void)
+static void test_approximate_viewrect_icon(void)
{
HWND hwnd;
DWORD ret;
@@ -5027,6 +5027,126 @@ static void test_approximate_viewrect(void)
DestroyWindow(hwnd);
}
+/***
+ * DESCRIPTION:
+ * Test LVM_APPROXIMATEVIEWRECT in LVS_REPORT mode.
+ *
+ * lParam seems to be completely ignored in this mode.
+ *
+ * wParam:
+ * The number of items to be displayed in the control.
+ * If this parameter is set to -1, the message uses the total number of items in the control.
+ * Other negative values are interpreted as big positive numbers (-2 is 65534 and so on).
+ */
+static void test_approximate_viewrect_report(void)
+{
+ HWND hwnd;
+ DWORD ret;
+ WORD w, h;
+ unsigned header_h, item_h, item_w;
+ LVCOLUMNA col;
+ static CHAR column_header[] = "Header";
+ unsigned const column_width = 100;
+ int const max_item_count = 2;
+ int item_count;
+ LV_ITEMA litem;
+ static CHAR item_text[] = "Item";
+
+ hwnd = create_listview_control(LVS_REPORT);
+
+ /* Empty control without columns */
+ ret = SendMessageA(hwnd, LVM_APPROXIMATEVIEWRECT, 0, 0);
+ w = LOWORD(ret);
+ h = HIWORD(ret);
+ ok(w == 0, "LVM_APPROXIMATEVIEWRECT: Empty header: width != 0\n");
+ ok(h != 0, "LVM_APPROXIMATEVIEWRECT: Empty header: zero height\n");
+
+ header_h = h;
+
+ ret = SendMessageA(hwnd, LVM_APPROXIMATEVIEWRECT, 1, 0);
+ w = LOWORD(ret);
+ h = HIWORD(ret);
+ ok(w == 0, "LVM_APPROXIMATEVIEWRECT: Empty header: width != 0\n");
+ ok(h > header_h, "LVM_APPROXIMATEVIEWRECT: Empty header: wrong item height\n");
+
+ item_h = h - header_h;
+
+ ret = SendMessageA(hwnd, LVM_APPROXIMATEVIEWRECT, -2, 0);
+ expect(MAKELONG(0, header_h + (WORD)(-2) * item_h), ret);
+ ret = SendMessageA(hwnd, LVM_APPROXIMATEVIEWRECT, -1, 0);
+ expect(MAKELONG(0, header_h), ret);
+ ret = SendMessageA(hwnd, LVM_APPROXIMATEVIEWRECT, 2, 0);
+ expect(MAKELONG(0, header_h + 2 * item_h), ret);
+
+ /* Insert column */
+ col.mask = LVCF_TEXT | LVCF_WIDTH;
+ col.pszText = column_header;
+ col.cx = column_width;
+ SendMessageA(hwnd, LVM_INSERTCOLUMNA, 0, (LPARAM)&col);
+
+ /* Empty control with column */
+ ret = SendMessageA(hwnd, LVM_APPROXIMATEVIEWRECT, 0, 0);
+ w = LOWORD(ret);
+ h = HIWORD(ret);
+ ok(w >= column_width, "LVM_APPROXIMATEVIEWRECT: Empty control: wrong width\n");
+ ok(h != 0, "LVM_APPROXIMATEVIEWRECT: Empty control: zero height\n");
+
+ header_h = h;
+ item_w = w;
+
+ ret = SendMessageA(hwnd, LVM_APPROXIMATEVIEWRECT, 1, 0);
+ w = LOWORD(ret);
+ h = HIWORD(ret);
+ ok(w == item_w, "LVM_APPROXIMATEVIEWRECT: Empty control: wrong width\n");
+ ok(h > header_h, "LVM_APPROXIMATEVIEWRECT: Empty control: wrong item height\n");
+
+ item_h = h - header_h;
+
+ ret = SendMessageA(hwnd, LVM_APPROXIMATEVIEWRECT, -2, 0);
+ expect(MAKELONG(item_w, header_h + (WORD)(-2) * item_h), ret);
+ ret = SendMessageA(hwnd, LVM_APPROXIMATEVIEWRECT, -1, 0);
+ expect(MAKELONG(item_w, header_h), ret);
+ ret = SendMessageA(hwnd, LVM_APPROXIMATEVIEWRECT, 2, 0);
+ expect(MAKELONG(item_w, header_h + 2 * item_h), ret);
+
+ for(item_count = 1; item_count <= max_item_count; ++item_count)
+ {
+ /* Insert item */
+ litem.mask = LVIF_TEXT;
+ litem.iItem = 0;
+ litem.iSubItem = 0;
+ litem.pszText = item_text;
+ SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM)&litem);
+
+ /* Control with items */
+ ret = SendMessageA(hwnd, LVM_APPROXIMATEVIEWRECT, 0, 0);
+ w = LOWORD(ret);
+ h = HIWORD(ret);
+ ok(w >= column_width, "LVM_APPROXIMATEVIEWRECT: Item count = %d: wrong width\n", item_count);
+ ok(h != 0, "LVM_APPROXIMATEVIEWRECT: Item count = %d: zero height\n", item_count);
+
+ header_h = h;
+ item_w = w;
+
+ ret = SendMessageA(hwnd, LVM_APPROXIMATEVIEWRECT, 1, 0);
+ w = LOWORD(ret);
+ h = HIWORD(ret);
+ ok(w == item_w, "LVM_APPROXIMATEVIEWRECT: Item count = %d: wrong width\n", item_count);
+ ok(h > header_h, "LVM_APPROXIMATEVIEWRECT: Item count = %d: wrong item height\n", item_count);
+
+ item_h = h - header_h;
+
+ ret = SendMessageA(hwnd, LVM_APPROXIMATEVIEWRECT, -2, 0);
+ expect(MAKELONG(item_w, header_h + (WORD)(-2) * item_h), ret);
+ ret = SendMessageA(hwnd, LVM_APPROXIMATEVIEWRECT, -1, 0);
+ expect(MAKELONG(item_w, header_h + item_count * item_h), ret);
+ ret = SendMessageA(hwnd, LVM_APPROXIMATEVIEWRECT, 2, 0);
+ expect(MAKELONG(item_w, header_h + 2 * item_h), ret);
+ }
+
+ DestroyWindow(hwnd);
+}
+
static void test_finditem(void)
{
LVFINDINFOA fi;
@@ -5944,7 +6064,8 @@ START_TEST(listview)
test_indentation();
test_getitemspacing();
test_getcolumnwidth();
- test_approximate_viewrect();
+ test_approximate_viewrect_icon();
+ test_approximate_viewrect_report();
test_finditem();
test_hover();
test_destroynotify();
--
2.5.5
More information about the wine-patches
mailing list