[PATCH v2] comctl32/tests: Add tests for mouse right-click in a treeview control

Nikolay Sivov bunglehead at gmail.com
Wed May 17 12:35:41 CDT 2017


On 16.05.2017 12:05, Hugh McMaster wrote:
> Signed-off-by: Hugh McMaster <hugh.mcmaster at outlook.com>
> ---
>  dlls/comctl32/tests/treeview.c | 79 ++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 79 insertions(+)
> 
> diff --git a/dlls/comctl32/tests/treeview.c b/dlls/comctl32/tests/treeview.c
> index 43de61c..ca3366d 100644
> --- a/dlls/comctl32/tests/treeview.c
> +++ b/dlls/comctl32/tests/treeview.c
> @@ -54,6 +54,21 @@ static BOOL g_v6;
>  static struct msg_sequence *sequences[NUM_MSG_SEQUENCES];
>  static struct msg_sequence *item_sequence[1];
>  
> +static void flush_events(void)
> +{
> +    MSG msg;
> +    int diff = 200;
> +    int min_timeout = 100;
> +    DWORD time = GetTickCount() + diff;
> +
> +    while (diff > 0)
> +    {
> +        if (MsgWaitForMultipleObjects(0, NULL, FALSE, min_timeout, QS_ALLINPUT) == WAIT_TIMEOUT) break;
> +        while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
> +        diff = time - GetTickCount();
> +    }
> +}
> +
>  static const struct message FillRootSeq[] = {
>      { TVM_INSERTITEMA, sent },
>      { TVM_INSERTITEMA, sent },
> @@ -201,6 +216,13 @@ static const struct message test_get_set_unicodeformat_seq[] = {
>      { 0 }
>  };
>  
> +static const struct message test_right_click_seq[] = {
> +    { WM_RBUTTONDOWN, sent|wparam, MK_RBUTTON },
> +    { WM_CAPTURECHANGED, sent|defwinproc },
> +    { TVM_GETNEXTITEM, sent|wparam|lparam|defwinproc, TVGN_CARET, 0 },
> +    { 0 }
> +};
> +
>  static const struct message parent_expand_seq[] = {
>      { WM_NOTIFY, sent|id, 0, 0, TVN_ITEMEXPANDINGA },
>      { WM_NOTIFY, sent|id, 0, 0, TVN_ITEMEXPANDEDA },
> @@ -342,6 +364,12 @@ static const struct message parent_vk_return_seq[] = {
>      { 0 }
>  };
>  
> +static const struct message parent_right_click_seq[] = {
> +    { WM_NOTIFY, sent|id, 0, 0, NM_RCLICK },
> +    { WM_CONTEXTMENU, sent },
> +    { 0 }
> +};
> +
>  static HWND hMainWnd;
>  
>  static HTREEITEM hRoot, hChild;
> @@ -1296,6 +1324,13 @@ static LRESULT CALLBACK parent_wnd_proc(HWND hWnd, UINT message, WPARAM wParam,
>                  }
>                  break;
>              }
> +            case NM_RCLICK:
> +            {
> +                HTREEITEM selected = (HTREEITEM)SendMessageA(((NMHDR *)lParam)->hwndFrom,
> +                                                             TVM_GETNEXTITEM, TVGN_CARET, 0);
> +                ok(selected == hChild, "child item should still be selected\n");
> +                break;
> +            }
>              }
>          }
>          break;
> @@ -2583,6 +2618,49 @@ todo_wine
>      DestroyWindow(hwnd);
>  }
>  
> +static void test_right_click(void)
> +{
> +    HWND hTree;
> +    HTREEITEM selected;
> +    RECT rc;
> +    LRESULT result;
> +    POINT pt;
> +
> +    hTree = create_treeview_control(0);
> +    fill_tree(hTree);
> +
> +    SendMessageA(hTree, TVM_ENSUREVISIBLE, 0, (LPARAM)hChild);
> +    SendMessageA(hTree, TVM_SELECTITEM, TVGN_CARET, (LPARAM)hChild);
> +    selected = (HTREEITEM)SendMessageA(hTree, TVM_GETNEXTITEM, TVGN_CARET, 0);
> +    ok(selected == hChild, "child item not selected\n");
> +
> +    *(HTREEITEM *)&rc = hRoot;
> +    result = SendMessageA(hTree, TVM_GETITEMRECT, TRUE, (LPARAM)&rc);
> +    ok(result, "TVM_GETITEMRECT failed\n");
> +
> +    flush_events();
> +
> +    pt.x = rc.left + (rc.right - rc.left) / 2;
> +    pt.y = rc.top + (rc.bottom - rc.top) / 2;

Could you please simplify this to "(a + b) / 2"? Other than that, it
looks good.



More information about the wine-devel mailing list