v2: Shorten test and fix style issues
Signed-off-by: Fabian Maurer <dark.shadow4(a)web.de>
---
dlls/comctl32/tests/combo.c | 111 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 111 insertions(+)
diff --git a/dlls/comctl32/tests/combo.c b/dlls/comctl32/tests/combo.c
index 895d9429b4..47cbdd1059 100644
--- a/dlls/comctl32/tests/combo.c
+++ b/dlls/comctl32/tests/combo.c
@@ -1151,6 +1151,115 @@ static void test_combo_WS_VSCROLL(void)
DestroyWindow(hCombo);
}
+
+static void test_combo_dropdown_size(DWORD style)
+{
+ HWND hCombo, hList;
+ COMBOBOXINFO cbInfo;
+ UINT x, y;
+ BOOL ret;
+ int i, test;
+ const char wine_test[] = "Wine Test";
+ const int combo_bordersize = 2;
+
+ static const struct list_size_info
+ {
+ int num_items;
+ int height_combo;
+ int limit;
+ } info_height[] = {
+ {33, 50, -1},
+ {35, 50, 40},
+ {15, 50, 3},
+ };
+
+ for (test = 0; test < sizeof(info_height) / sizeof(info_height[0]); test++)
+ {
+ const struct list_size_info *info_test = &info_height[test];
+ int height_item; /* Height of a list item */
+ int height_list; /* Height of the list we got */
+ int expected_height_list;
+ RECT rect_list_client;
+ int min_visible_expected;
+
+ hCombo = CreateWindowA("ComboBox", WC_COMBOBOXA, WS_VISIBLE | WS_CHILD | style, 5, 5, 100,
+ info_test->height_combo, hMainWnd, (HMENU)COMBO_ID, NULL, 0);
+
+ min_visible_expected = SendMessageA(hCombo, CB_GETMINVISIBLE, 0, 0);
+ todo_wine
+ ok(min_visible_expected == 30, "Expected maximum of visible items to be 30, got %d\n", min_visible_expected);
+
+ cbInfo.cbSize = sizeof(COMBOBOXINFO);
+ SetLastError(0xdeadbeef);
+ ret = GetComboBoxInfo(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++)
+ SendMessageA(hCombo, CB_ADDSTRING, 0, (LPARAM) wine_test);
+
+ if (info_test->limit != -1)
+ {
+ int min_visible_actual;
+ min_visible_expected = info_test->limit;
+
+ SendMessageA(hCombo, CB_SETMINVISIBLE, min_visible_expected, 0);
+ min_visible_actual = SendMessageA(hCombo, CB_GETMINVISIBLE, 0, 0);
+ todo_wine
+ ok(min_visible_expected == min_visible_actual, "Expected maximum of visible items to be %d, got %d\n",
+ min_visible_expected, min_visible_actual);
+ }
+
+ /* 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_client);
+ height_list = rect_list_client.bottom - rect_list_client.top;
+ height_item = (int)SendMessageA(hList, LB_GETITEMHEIGHT, 0, 0);
+
+ if (style & CBS_NOINTEGRALHEIGHT)
+ {
+ RECT rect_list_complete;
+ int list_height_nonclient;
+ int list_height_calculated;
+
+ GetWindowRect(hList, &rect_list_complete);
+
+ list_height_nonclient = (rect_list_complete.bottom - rect_list_complete.top)
+ - (rect_list_client.bottom - rect_list_client.top);
+
+ /* Calculate the expected client size of the listbox popup from the size of the combobox. */
+ list_height_calculated = info_test->height_combo
+ - (cbInfo.rcItem.bottom + combo_bordersize)
+ - list_height_nonclient
+ - 1;
+
+ expected_height_list = min(list_height_calculated, height_item * info_test->num_items);
+ if (expected_height_list < 0)
+ expected_height_list = 0;
+
+ todo_wine
+ ok(expected_height_list == height_list,
+ "Test %d, expected list height to be %d, got %d\n", test, expected_height_list, height_list);
+ }
+ else
+ {
+ expected_height_list = min(info_test->num_items, min_visible_expected) * height_item;
+
+ todo_wine
+ ok(expected_height_list == height_list,
+ "Test %d, expected list height to be %d, got %d\n", test, expected_height_list, height_list);
+ }
+
+ DestroyWindow(hCombo);
+ }
+}
+
START_TEST(combo)
{
ULONG_PTR ctx_cookie;
@@ -1192,6 +1301,8 @@ START_TEST(combo)
test_combo_listbox_styles(CBS_SIMPLE);
test_combo_listbox_styles(CBS_DROPDOWN);
test_combo_listbox_styles(CBS_DROPDOWNLIST);
+ test_combo_dropdown_size(CBS_DROPDOWN);
+ test_combo_dropdown_size(CBS_DROPDOWN | CBS_NOINTEGRALHEIGHT);
cleanup();
unload_v6_module(ctx_cookie, hCtx);
--
2.16.1