[PATCH v2 2/2] comctl32/tests: Add tests for preserving tooltip size and position after TTN_SHOW.

Roman Pišl rpisl at seznam.cz
Sat Feb 24 05:01:09 CST 2018


Signed-off-by: Roman Pišl <rpisl at seznam.cz>
---
 dlls/comctl32/tests/tooltips.c | 94 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 94 insertions(+)

diff --git a/dlls/comctl32/tests/tooltips.c b/dlls/comctl32/tests/tooltips.c
index c260e3d220..6f2ff22f09 100644
--- a/dlls/comctl32/tests/tooltips.c
+++ b/dlls/comctl32/tests/tooltips.c
@@ -262,8 +262,16 @@ static void test_customdraw(void) {
    SetCursorPos(orig_pos.x, orig_pos.y);
 }
 
+#define TTIP_LEFT   300
+#define TTIP_TOP    300
+#define TTIP_WIDTH  200
+#define TTIP_HEIGHT 50
+
 static const CHAR testcallbackA[]  = "callback";
 
+static HWND g_hwnd_ttn_show;
+static enum { none = 0, size, both } g_resize = none;
+
 static LRESULT WINAPI parent_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
 {
     if (message == WM_NOTIFY && lParam)
@@ -272,6 +280,12 @@ static LRESULT WINAPI parent_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LP
 
         if (ttnmdi->hdr.code == TTN_GETDISPINFOA)
             lstrcpyA(ttnmdi->lpszText, testcallbackA);
+
+        if (g_resize != none && ttnmdi->hdr.code == TTN_SHOW) {
+            g_hwnd_ttn_show = ttnmdi->hdr.hwndFrom;
+            SetWindowPos(ttnmdi->hdr.hwndFrom, 0, TTIP_LEFT, TTIP_TOP, TTIP_WIDTH, TTIP_HEIGHT, SWP_NOZORDER | SWP_NOACTIVATE);
+            return g_resize == both;
+        }
     }
 
     return DefWindowProcA(hwnd, message, wParam, lParam);
@@ -1134,6 +1148,84 @@ static void test_TTM_ADDTOOL(BOOL is_v6)
     DestroyWindow(hwnd);
 }
 
+static void test_TTN_SHOW(void)
+{
+    HWND hwndTip, notify;
+    TTTOOLINFOA toolinfoA;
+    RECT rect;
+    LRESULT r;
+    DWORD major, minor, version;
+
+    version = GetVersion();
+    major = LOBYTE(version);
+    minor = HIBYTE(LOWORD(version));
+    if (major < 6 || minor < 1)
+    {
+        skip("Test available on Windows 7 and later\n");
+        return;
+    }
+
+    /* Create main window */
+    notify = create_parent_window();
+    ok(notify != NULL, "Expected notification window to be created\n");
+
+    /* Put cursor outside the window */
+    GetWindowRect(notify, &rect);
+    SetCursorPos(rect.right + 200, 0);
+
+    /* Create tooltip */
+    hwndTip = CreateWindowExA(0, TOOLTIPS_CLASSA, NULL, 0,
+                           10, 10, 400, 400,
+                           NULL, NULL, NULL, 0);
+    ok(hwndTip != NULL, "failed to create tooltip wnd\n");
+
+    toolinfoA.cbSize = sizeof(TTTOOLINFOA);
+    toolinfoA.hwnd = notify;
+    toolinfoA.hinst = GetModuleHandleA(NULL);
+    toolinfoA.uFlags = TTF_SUBCLASS;
+    toolinfoA.uId = 0x1234ABCD;
+    toolinfoA.lpszText = (LPSTR)"This is a test tooltip";
+    toolinfoA.lParam = 0xdeadbeef;
+    GetClientRect(notify, &toolinfoA.rect);
+    r = SendMessageA(hwndTip, TTM_ADDTOOLA, 0, (LPARAM)&toolinfoA);
+    ok(r, "got %ld\n", r);
+
+    /* Make tooltip appear quickly */
+    SendMessageA(hwndTip, TTM_SETDELAYTIME, TTDT_INITIAL, MAKELPARAM(1,0));
+
+    /* Put cursor inside window, tooltip will appear immediately */
+    g_resize = size;
+    GetWindowRect(notify, &rect);
+    SetCursorPos((rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2);
+    flush_events(200);
+
+    /* Test actual tooltip window size */
+    GetWindowRect(g_hwnd_ttn_show, &rect);
+    ok(rect.right - rect.left == TTIP_WIDTH && rect.bottom - rect.top == TTIP_HEIGHT,
+       "Invalid tooltip size %i %i \n", rect.right - rect.left, rect.bottom - rect.top);
+    ok(rect.left != TTIP_LEFT && rect.top != TTIP_TOP, "Tooltip position should not be modified");
+
+    /* Put cursor outside the window */
+    GetWindowRect(notify, &rect);
+    SetCursorPos(rect.right + 200, 0);
+    flush_events(200);
+
+    /* Put cursor inside window, tooltip will appear immediately */
+    g_resize = both;
+    GetWindowRect(notify, &rect);
+    SetCursorPos((rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2);
+    flush_events(200);
+
+    /* Test actual tooltip window size and position */
+    GetWindowRect(g_hwnd_ttn_show, &rect);
+    ok(rect.left == TTIP_LEFT && rect.top == TTIP_TOP && 
+       rect.right == TTIP_LEFT + TTIP_WIDTH && rect.bottom == TTIP_TOP + TTIP_HEIGHT,
+       "Invalid tooltip rect %i %i %i %i\n", rect.left, rect.top, rect.right, rect.bottom);
+
+    DestroyWindow(hwndTip);
+    DestroyWindow(notify);
+}
+
 START_TEST(tooltips)
 {
     ULONG_PTR ctx_cookie;
@@ -1153,6 +1245,7 @@ START_TEST(tooltips)
     test_setinfo(FALSE);
     test_margin();
     test_TTM_ADDTOOL(FALSE);
+    test_TTN_SHOW();
 
     if (!load_v6_module(&ctx_cookie, &hCtx))
         return;
@@ -1164,6 +1257,7 @@ START_TEST(tooltips)
     test_setinfo(TRUE);
     test_margin();
     test_TTM_ADDTOOL(TRUE);
+    test_TTN_SHOW();
 
     unload_v6_module(ctx_cookie, hCtx);
 }
-- 
2.16.1




More information about the wine-devel mailing list