From c3399383e4183f685c9237e7e6ac06db312475db Mon Sep 17 00:00:00 2001 From: Damjan Jovanovic Date: Wed, 13 Nov 2019 05:54:11 +0200 Subject: [PATCH] comctl32: Test overwriting of pszText contents in TVN_ENDLABELEDIT. Signed-off-by: Damjan Jovanovic Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard (cherry picked from commit 1fa32f9a5396934c6788ac02402cccc020237bf4) Signed-off-by: Michael Stefaniuc --- dlls/comctl32/tests/treeview.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/dlls/comctl32/tests/treeview.c b/dlls/comctl32/tests/treeview.c index 6b97853377c..bfde77df797 100644 --- a/dlls/comctl32/tests/treeview.c +++ b/dlls/comctl32/tests/treeview.c @@ -42,6 +42,7 @@ static BOOL g_get_rect_in_expand; static BOOL g_disp_A_to_W; static BOOL g_disp_set_stateimage; static BOOL g_beginedit_alter_text; +static const char *g_endedit_overwrite_contents; static HFONT g_customdraw_font; static BOOL g_v6; @@ -1324,7 +1325,11 @@ static LRESULT CALLBACK parent_wnd_proc(HWND hWnd, UINT message, WPARAM wParam, { NMTVDISPINFOA *disp = (NMTVDISPINFOA *)lParam; if (disp->item.mask & TVIF_TEXT) + { todo_wine ok(disp->item.cchTextMax == MAX_PATH, "cchTextMax is %d\n", disp->item.cchTextMax); + if (g_endedit_overwrite_contents) + strcpy(disp->item.pszText, g_endedit_overwrite_contents); + } return TRUE; } case TVN_ITEMEXPANDINGA: @@ -1717,6 +1722,23 @@ static void test_itemedit(void) expect(TRUE, r); todo_wine expect(MAX_PATH - 1, strlen(item.pszText)); + /* Overwriting of pszText contents in TVN_ENDLABELEDIT */ + edit = (HWND)SendMessageA(hTree, TVM_EDITLABELA, 0, (LPARAM)hRoot); + ok(IsWindow(edit), "Expected valid handle\n"); + r = SetWindowTextA(edit, "old"); + expect(TRUE, r); + g_endedit_overwrite_contents = ""; + r = SendMessageA(hTree, WM_COMMAND, MAKEWPARAM(0, EN_KILLFOCUS), (LPARAM)edit); + expect(0, r); + g_endedit_overwrite_contents = NULL; + item.mask = TVIF_TEXT; + item.hItem = hRoot; + item.pszText = buffA; + item.cchTextMax = ARRAY_SIZE(buffA); + r = SendMessageA(hTree, TVM_GETITEMA, 0, (LPARAM)&item); + expect(TRUE, r); + expect(0, strcmp(item.pszText, "")); + DestroyWindow(hTree); }