[PATCH v2] comctl32/tests: Add test for v6 combobox dropdown size

Nikolay Sivov bunglehead at gmail.com
Sat Feb 3 08:49:03 CST 2018


On 2/2/2018 12:56 AM, Fabian Maurer wrote:
> v2: Shorten test and fix style issues
> 
> Signed-off-by: Fabian Maurer <dark.shadow4 at 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);

First argument is a window class.

> +        ok(min_visible_expected == 30, "Expected maximum of visible items to be 30, got %d\n", min_visible_expected);

Shouldn't it say minimum? But I think shorter is better, you can call it
unexpected number of items, without specifying expected number at all.

> +        cbInfo.cbSize = sizeof(COMBOBOXINFO);
> +        SetLastError(0xdeadbeef);
> +        ret = GetComboBoxInfo(hCombo, &cbInfo);
> +        ok(ret, "Failed to get COMBOBOXINFO structure; LastError: %u\n", GetLastError());

I think CB_GETCOMBOBOXINFO is preferable.

> +        for (i = 0; i < info_test->num_items; i++)
> +            SendMessageA(hCombo, CB_ADDSTRING, 0, (LPARAM) wine_test);

...

> +
> +            SendMessageA(hCombo, CB_SETMINVISIBLE, min_visible_expected, 0);

Please check return values for sent messages.

> +
> +        /* 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());

I haven't tested what cbInfo returns exactly, but does this work in RTL
case? CB_SHOWDROPDOWN should work better here.

> +        ok(SendMessageA(hCombo, CB_GETDROPPEDSTATE, 0, 0),
> +           "The dropdown list should have appeared after clicking the button.\n");

If only for consistency please place call on a separate line.

> +
> +            /* 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;

It's hard to tell what those constant are about. I.e. should bordersize
be 3 actually, or if it's affected by resolution.


> +    test_combo_dropdown_size(CBS_DROPDOWN);
> +    test_combo_dropdown_size(CBS_DROPDOWN | CBS_NOINTEGRALHEIGHT);

My understanding is this only applies to CBS_DROPDOWN controls, right?
You can use this style unconditionally in CreateWindow().



More information about the wine-devel mailing list