[PATCH] user32/combo: Set listview popup height correctly and add tests
Fabian Maurer
dark.shadow4 at web.de
Mon Aug 14 16:54:29 CDT 2017
Signed-off-by: Fabian Maurer <dark.shadow4 at web.de>
---
dlls/user32/combo.c | 8 -----
dlls/user32/tests/combo.c | 92 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 92 insertions(+), 8 deletions(-)
diff --git a/dlls/user32/combo.c b/dlls/user32/combo.c
index a2e8b3ce6c..f35e0d9296 100644
--- a/dlls/user32/combo.c
+++ b/dlls/user32/combo.c
@@ -1033,14 +1033,6 @@ static void CBDropDown( LPHEADCOMBO lphc )
if (nHeight < nDroppedHeight - COMBO_YBORDERSIZE())
nDroppedHeight = nHeight + COMBO_YBORDERSIZE();
-
- if (nDroppedHeight < nHeight)
- {
- if (nItems < 5)
- nDroppedHeight = (nItems+1)*nIHeight;
- else if (nDroppedHeight < 6*nIHeight)
- nDroppedHeight = 6*nIHeight;
- }
}
r.left = rect.left;
diff --git a/dlls/user32/tests/combo.c b/dlls/user32/tests/combo.c
index f52efae587..e304e3c3fe 100644
--- a/dlls/user32/tests/combo.c
+++ b/dlls/user32/tests/combo.c
@@ -700,11 +700,103 @@ static void test_listbox_styles(DWORD cb_style)
DestroyWindow(combo);
}
+struct list_size_info
+{
+ int num_items;
+ int height_combo;
+ int height_list_expected;
+ BOOL todo;
+};
+
+static void test_listview_size(DWORD style)
+{
+ BOOL (WINAPI *pGetComboBoxInfo)(HWND, PCOMBOBOXINFO);
+ HWND hCombo, hList;
+ COMBOBOXINFO cbInfo;
+ UINT x, y;
+ BOOL ret;
+ int i, test;
+ const char wine_test[] = "Wine Test";
+ RECT rect_list;
+
+ static const struct list_size_info info_height[] = {
+ {2, 24, 0},
+ {2, 41, 0, TRUE},
+ {2, 42, 16},
+ {2, 50, 16},
+ {2, 60, 32},
+ {2, 80, 32},
+ {2, 89, 32},
+ {2, 90, 32},
+ {2, 100, 32},
+
+ {10, 24, 0},
+ {10, 41, 0, TRUE},
+ {10, 42, 16},
+ {10, 50, 16},
+ {10, 60, 32},
+ {10, 80, 48},
+ {10, 89, 48, TRUE},
+ {10, 90, 64},
+ {10, 100, 64},
+ };
+
+ pGetComboBoxInfo = (void *)GetProcAddress(GetModuleHandleA("user32.dll"), "GetComboBoxInfo");
+ if (!pGetComboBoxInfo)
+ {
+ win_skip("GetComboBoxInfo is not available\n");
+ return;
+ }
+
+ for(test = 0; test < sizeof(info_height) / sizeof(struct list_size_info); test++)
+ {
+ const struct list_size_info *info_test = &info_height[test];
+ int height_list;
+
+ hCombo = CreateWindowA("ComboBox", "Combo", WS_VISIBLE|WS_CHILD|style, 5, 5, 100, info_test->height_combo, hMainWnd, (HMENU)COMBO_ID, NULL, 0);
+
+ cbInfo.cbSize = sizeof(COMBOBOXINFO);
+ SetLastError(0xdeadbeef);
+ ret = pGetComboBoxInfo(hCombo, &cbInfo);
+ ok(ret, "Failed to get COMBOBOXINFO structure; LastError: %u\n", GetLastError());
+
+ hList = cbInfo.hwndList;
+ for (i = 0; i < info_test->num_items; i++)
+ SendMessageW(hCombo, CB_ADDSTRING, 0, (LPARAM) wine_test );
+
+ /* Click on the button to drop down the list */
+ x = cbInfo.rcButton.left + (cbInfo.rcButton.right-cbInfo.rcButton.left)/2;
+ y = cbInfo.rcButton.top + (cbInfo.rcButton.bottom-cbInfo.rcButton.top)/2;
+ ret = SendMessageA(hCombo, WM_LBUTTONDOWN, 0, MAKELPARAM(x, y));
+ ok(ret, "WM_LBUTTONDOWN was not processed. LastError=%d\n",
+ GetLastError());
+ ok(SendMessageA(hCombo, CB_GETDROPPEDSTATE, 0, 0),
+ "The dropdown list should have appeared after clicking the button.\n");
+
+ GetClientRect(hList, &rect_list);
+ height_list = rect_list.bottom - rect_list.top;
+
+ if(info_test->todo)
+ {
+ todo_wine ok(info_test->height_list_expected == height_list,
+ "Test %d, expected list height to be %d, got %d\n", test, info_test->height_list_expected, height_list);
+ }
+ else
+ {
+ ok(info_test->height_list_expected == height_list,
+ "Test %d, expected list height to be %d, got %d\n", test, info_test->height_list_expected, height_list);
+ }
+
+ DestroyWindow(hCombo);
+ }
+}
+
START_TEST(combo)
{
hMainWnd = CreateWindowA("static", "Test", WS_OVERLAPPEDWINDOW, 10, 10, 300, 300, NULL, NULL, NULL, 0);
ShowWindow(hMainWnd, SW_SHOW);
+ test_listview_size(CBS_DROPDOWN);
test_setfont(CBS_DROPDOWN);
test_setfont(CBS_DROPDOWNLIST);
test_setitemheight(CBS_DROPDOWN);
--
2.14.1
More information about the wine-patches
mailing list