Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/comctl32/tests/tooltips.c | 48 ++++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 13 deletions(-)
diff --git a/dlls/comctl32/tests/tooltips.c b/dlls/comctl32/tests/tooltips.c index 7e82604376..207536cadf 100644 --- a/dlls/comctl32/tests/tooltips.c +++ b/dlls/comctl32/tests/tooltips.c @@ -24,9 +24,11 @@
#include "wine/test.h"
+#include "v6util.h" + #define expect(expected, got) ok(got == expected, "Expected %d, got %d\n", expected, got)
-static void test_create_tooltip(void) +static void test_create_tooltip(BOOL is_v6) { HWND parent, hwnd; DWORD style, exp_style; @@ -56,9 +58,12 @@ static void test_create_tooltip(void) ok(hwnd != NULL, "failed to create tooltip wnd\n");
style = GetWindowLongA(hwnd, GWL_STYLE); - trace("style = %08x\n", style); - ok(style == (WS_POPUP | WS_CLIPSIBLINGS | WS_BORDER), - "wrong style %08x\n", style); + exp_style = WS_POPUP | WS_CLIPSIBLINGS; + if (!is_v6) + exp_style |= WS_BORDER; +todo_wine_if(is_v6) + ok(style == exp_style || broken(style == (exp_style | WS_BORDER)) /* XP */, + "Unexpected window style %#x.\n", style);
DestroyWindow(hwnd);
@@ -273,9 +278,10 @@ static LRESULT WINAPI parent_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LP return DefWindowProcA(hwnd, message, wParam, lParam); }
-static BOOL register_parent_wnd_class(void) +static void register_parent_wnd_class(void) { WNDCLASSA cls; + BOOL ret;
cls.style = 0; cls.lpfnWndProc = parent_wnd_proc; @@ -287,14 +293,12 @@ static BOOL register_parent_wnd_class(void) cls.hbrBackground = GetStockObject(WHITE_BRUSH); cls.lpszMenuName = NULL; cls.lpszClassName = "Tooltips test parent class"; - return RegisterClassA(&cls); + ret = RegisterClassA(&cls); + ok(ret, "Failed to register test parent class.\n"); }
static HWND create_parent_window(void) { - if (!register_parent_wnd_class()) - return NULL; - return CreateWindowExA(0, "Tooltips test parent class", "Tooltips test parent window", WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | @@ -884,7 +888,7 @@ static LRESULT CALLBACK info_wnd_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM return 0; }
-static void test_setinfo(void) +static void test_setinfo(BOOL is_v6) { WNDCLASSA wc; LRESULT lResult; @@ -976,7 +980,8 @@ static void test_setinfo(void) toolInfo2.uId = 0x1234ABCD; lResult = SendMessageA(hwndTip, TTM_GETTOOLINFOA, 0, (LPARAM)&toolInfo2); ok(lResult, "GetToolInfo failed\n"); - ok(toolInfo2.uFlags & TTF_SUBCLASS, "uFlags does not have subclass\n"); + ok(toolInfo2.uFlags & TTF_SUBCLASS || broken(is_v6 && !(toolInfo2.uFlags & TTF_SUBCLASS)) /* XP */, + "uFlags does not have subclass\n"); wndProc = (WNDPROC)GetWindowLongPtrA(parent, GWLP_WNDPROC); ok (wndProc != info_wnd_proc, "Window Proc is wrong\n");
@@ -1057,15 +1062,32 @@ static void test_margin(void)
START_TEST(tooltips) { + ULONG_PTR ctx_cookie; + HANDLE hCtx; + LoadLibraryA("comctl32.dll");
- test_create_tooltip(); + register_parent_wnd_class(); + + test_create_tooltip(FALSE); test_customdraw(); test_gettext(); test_ttm_gettoolinfo(); test_longtextA(); test_longtextW(); test_track(); - test_setinfo(); + test_setinfo(FALSE); test_margin(); + + if (!load_v6_module(&ctx_cookie, &hCtx)) + return; + + test_create_tooltip(TRUE); + test_customdraw(); + test_longtextW(); + test_track(); + test_setinfo(TRUE); + test_margin(); + + unload_v6_module(ctx_cookie, hCtx); }
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com ---
For https://bugs.winehq.org/show_bug.cgi?id=10347
dlls/comctl32/tests/tooltips.c | 80 ++++++++++++++++++++++++++++++++++++++++-- dlls/comctl32/tooltips.c | 2 +- 2 files changed, 79 insertions(+), 3 deletions(-)
diff --git a/dlls/comctl32/tests/tooltips.c b/dlls/comctl32/tests/tooltips.c index 207536cadf..c260e3d220 100644 --- a/dlls/comctl32/tests/tooltips.c +++ b/dlls/comctl32/tests/tooltips.c @@ -44,7 +44,6 @@ static void test_create_tooltip(BOOL is_v6) ok(hwnd != NULL, "failed to create tooltip wnd\n");
style = GetWindowLongA(hwnd, GWL_STYLE); - trace("style = %08x\n", style); exp_style = 0x7fffffff | WS_POPUP; exp_style &= ~(WS_CHILD | WS_MAXIMIZE | WS_BORDER | WS_DLGFRAME); ok(style == exp_style || broken(style == (exp_style | WS_BORDER)), /* nt4 */ @@ -448,7 +447,7 @@ todo_wine NULL, NULL, NULL, 0); ok(hwnd != NULL, "failed to create tooltip wnd\n");
- toolinfoW.cbSize = sizeof(TTTOOLINFOW); + toolinfoW.cbSize = TTTOOLINFOW_V2_SIZE + 1; toolinfoW.hwnd = NULL; toolinfoW.hinst = GetModuleHandleA(NULL); toolinfoW.uFlags = 0; @@ -457,6 +456,9 @@ todo_wine toolinfoW.lParam = 0xdeadbeef; GetClientRect(hwnd, &toolinfoW.rect); r = SendMessageW(hwnd, TTM_ADDTOOLW, 0, (LPARAM)&toolinfoW); + /* Wine currently checks for V3 structure size, which matches what V6 control does. + Older implementation was never updated to support lpReserved field. */ +todo_wine ok(!r, "Adding the tool to the tooltip succeeded!\n");
if (0) /* crashes on NT4 */ @@ -1060,6 +1062,78 @@ static void test_margin(void) DestroyWindow(hwnd); }
+static void test_TTM_ADDTOOL(BOOL is_v6) +{ + static const WCHAR testW[] = {'T','e','s','t',0}; + TTTOOLINFOW tiW; + TTTOOLINFOA ti; + int ret, size; + HWND hwnd, parent; + UINT max_size; + + parent = CreateWindowExA(0, "Static", NULL, WS_POPUP, 0, 0, 0, 0, NULL, NULL, NULL, 0); + ok(parent != NULL, "failed to create parent wnd\n"); + + hwnd = CreateWindowExA(WS_EX_TOPMOST, TOOLTIPS_CLASSA, NULL, TTS_NOPREFIX | TTS_ALWAYSTIP, + 0, 0, 100, 100, NULL, NULL, GetModuleHandleA(NULL), 0); + ok(hwnd != NULL, "Failed to create tooltip window.\n"); + + for (size = 0; size <= TTTOOLINFOW_V3_SIZE + 1; size++) + { + ti.cbSize = size; + ti.hwnd = NULL; + ti.hinst = GetModuleHandleA(NULL); + ti.uFlags = 0; + ti.uId = 0x1234abce; + ti.lpszText = (LPSTR)"Test"; + ti.lParam = 0xdeadbeef; + GetClientRect(hwnd, &ti.rect); + + ret = SendMessageA(hwnd, TTM_ADDTOOLA, 0, (LPARAM)&ti); + ok(ret, "Failed to add a tool, size %d.\n", size); + + ret = SendMessageA(hwnd, TTM_GETTOOLCOUNT, 0, 0); + ok(ret == 1, "Unexpected tool count %d, size %d.\n", ret, size); + + ret = SendMessageA(hwnd, TTM_DELTOOLA, 0, (LPARAM)&ti); + ok(!ret, "Unexpected ret value %d.\n", ret); + + ret = SendMessageA(hwnd, TTM_GETTOOLCOUNT, 0, 0); + ok(ret == 0, "Unexpected tool count %d, size %d.\n", ret, size); + } + + /* W variant checks cbSize. */ + max_size = is_v6 ? TTTOOLINFOW_V3_SIZE : TTTOOLINFOW_V2_SIZE; + for (size = 0; size <= max_size + 1; size++) + { + tiW.cbSize = size; + tiW.hwnd = NULL; + tiW.hinst = GetModuleHandleA(NULL); + tiW.uFlags = 0; + tiW.uId = 0x1234abce; + tiW.lpszText = (LPWSTR)testW; + tiW.lParam = 0xdeadbeef; + GetClientRect(hwnd, &tiW.rect); + + ret = SendMessageA(hwnd, TTM_ADDTOOLW, 0, (LPARAM)&tiW); + todo_wine_if(!is_v6 && size > max_size) + ok(size <= max_size ? ret : !ret, "%d: Unexpected ret value %d, size %d, max size %d.\n", is_v6, ret, size, max_size); + if (ret) + { + ret = SendMessageA(hwnd, TTM_GETTOOLCOUNT, 0, 0); + ok(ret == 1, "Unexpected tool count %d.\n", ret); + + ret = SendMessageA(hwnd, TTM_DELTOOLA, 0, (LPARAM)&tiW); + ok(!ret, "Unexpected ret value %d.\n", ret); + + ret = SendMessageA(hwnd, TTM_GETTOOLCOUNT, 0, 0); + ok(ret == 0, "Unexpected tool count %d.\n", ret); + } + } + + DestroyWindow(hwnd); +} + START_TEST(tooltips) { ULONG_PTR ctx_cookie; @@ -1078,6 +1152,7 @@ START_TEST(tooltips) test_track(); test_setinfo(FALSE); test_margin(); + test_TTM_ADDTOOL(FALSE);
if (!load_v6_module(&ctx_cookie, &hCtx)) return; @@ -1088,6 +1163,7 @@ START_TEST(tooltips) test_track(); test_setinfo(TRUE); test_margin(); + test_TTM_ADDTOOL(TRUE);
unload_v6_module(ctx_cookie, hCtx); } diff --git a/dlls/comctl32/tooltips.c b/dlls/comctl32/tooltips.c index 1c8cb66422..12f2d4b81c 100644 --- a/dlls/comctl32/tooltips.c +++ b/dlls/comctl32/tooltips.c @@ -1059,7 +1059,7 @@ TOOLTIPS_AddToolT (TOOLTIPS_INFO *infoPtr, const TTTOOLINFOW *ti, BOOL isW) TRACE("add tool (%p) %p %ld%s\n", infoPtr->hwndSelf, ti->hwnd, ti->uId, (ti->uFlags & TTF_IDISHWND) ? " TTF_IDISHWND" : "");
- if (ti->cbSize >= TTTOOLINFOW_V2_SIZE && !ti->lpszText && isW) + if (ti->cbSize > TTTOOLINFOW_V3_SIZE && isW) return FALSE;
if (infoPtr->uNumTools == 0) {