Akihiro Sagawa : comctl32/tests: Add tests for long info tip texts.

Alexandre Julliard julliard at winehq.org
Mon Apr 16 13:35:44 CDT 2012


Module: wine
Branch: master
Commit: 28f26c978387e161b42b9dd5960a91e1af6b49a5
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=28f26c978387e161b42b9dd5960a91e1af6b49a5

Author: Akihiro Sagawa <sagawa.aki at gmail.com>
Date:   Fri Apr 13 22:45:20 2012 +0900

comctl32/tests: Add tests for long info tip texts.

---

 dlls/comctl32/tests/tooltips.c |  124 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 124 insertions(+), 0 deletions(-)

diff --git a/dlls/comctl32/tests/tooltips.c b/dlls/comctl32/tests/tooltips.c
index 31504d1..cf571de 100644
--- a/dlls/comctl32/tests/tooltips.c
+++ b/dlls/comctl32/tests/tooltips.c
@@ -636,6 +636,128 @@ static void test_ttm_gettoolinfo(void)
     DestroyWindow(hwnd);
 }
 
+static void test_longtextA(void)
+{
+    static const char longtextA[] =
+        "According to MSDN, TTM_ENUMTOOLS claims that TOOLINFO's lpszText is maximum "
+        "80 chars including null. In fact, the buffer is not null-terminated.";
+    HWND hwnd;
+    TTTOOLINFOA toolinfoA = { 0 };
+    CHAR bufA[256];
+    LRESULT r;
+
+    hwnd = CreateWindowExA(0, TOOLTIPS_CLASSA, NULL, 0,
+                           10, 10, 300, 100,
+                           NULL, NULL, NULL, 0);
+    toolinfoA.cbSize = sizeof(TTTOOLINFOA);
+    toolinfoA.hwnd = NULL;
+    toolinfoA.hinst = GetModuleHandleA(NULL);
+    toolinfoA.uFlags = 0;
+    toolinfoA.uId = 0x1234ABCD;
+    strcpy(bufA, longtextA);
+    toolinfoA.lpszText = bufA;
+    toolinfoA.lParam = 0xdeadbeef;
+    GetClientRect(hwnd, &toolinfoA.rect);
+    r = SendMessageA(hwnd, TTM_ADDTOOLA, 0, (LPARAM)&toolinfoA);
+    if (r)
+    {
+        int textlen;
+        memset(bufA, 0, sizeof(bufA));
+        toolinfoA.hwnd = NULL;
+        toolinfoA.uId = 0xABCD1234;
+        toolinfoA.lpszText = bufA;
+        SendMessageA(hwnd, TTM_ENUMTOOLSA, 0, (LPARAM)&toolinfoA);
+        textlen = lstrlenA(toolinfoA.lpszText);
+        todo_wine ok(textlen == 80, "lpszText has %d chars\n", textlen);
+        ok(toolinfoA.uId == 0x1234ABCD,
+           "uId should be retrieved, got %p\n", (void*)toolinfoA.uId);
+
+        memset(bufA, 0, sizeof(bufA));
+        toolinfoA.hwnd = NULL;
+        toolinfoA.uId = 0x1234ABCD;
+        toolinfoA.lpszText = bufA;
+        SendMessageA(hwnd, TTM_GETTOOLINFOA, 0, (LPARAM)&toolinfoA);
+        textlen = lstrlenA(toolinfoA.lpszText);
+        todo_wine ok(textlen == 80, "lpszText has %d chars\n", textlen);
+
+        memset(bufA, 0, sizeof(bufA));
+        toolinfoA.hwnd = NULL;
+        toolinfoA.uId = 0x1234ABCD;
+        toolinfoA.lpszText = bufA;
+        SendMessageA(hwnd, TTM_GETTEXTA, 0, (LPARAM)&toolinfoA);
+        textlen = lstrlenA(toolinfoA.lpszText);
+        todo_wine ok(textlen == 80, "lpszText has %d chars\n", textlen);
+    }
+
+    DestroyWindow(hwnd);
+}
+
+static void test_longtextW(void)
+{
+    static const char longtextA[] =
+        "According to MSDN, TTM_ENUMTOOLS claims that TOOLINFO's lpszText is maximum "
+        "80 chars including null. Actually, this is not applied for wide version.";
+    HWND hwnd;
+    TTTOOLINFOW toolinfoW = { 0 };
+    WCHAR bufW[256];
+    LRESULT r;
+    int lenW;
+
+    hwnd = CreateWindowExW(0, TOOLTIPS_CLASSW, NULL, 0,
+                           10, 10, 300, 100,
+                           NULL, NULL, NULL, 0);
+    if(!hwnd)
+    {
+        win_skip("CreateWindowExW() not supported. Skipping.\n");
+        return;
+    }
+
+    toolinfoW.cbSize = TTTOOLINFOW_V2_SIZE;
+    toolinfoW.hwnd = NULL;
+    toolinfoW.hinst = GetModuleHandleW(NULL);
+    toolinfoW.uFlags = 0;
+    toolinfoW.uId = 0x1234ABCD;
+    MultiByteToWideChar(CP_ACP, 0, longtextA, -1, bufW, sizeof(bufW)/sizeof(bufW[0]));
+    lenW = lstrlenW(bufW);
+    toolinfoW.lpszText = bufW;
+    toolinfoW.lParam = 0xdeadbeef;
+    GetClientRect(hwnd, &toolinfoW.rect);
+    r = SendMessageW(hwnd, TTM_ADDTOOLW, 0, (LPARAM)&toolinfoW);
+    if (r)
+    {
+        int textlen;
+        memset(bufW, 0, sizeof(bufW));
+        toolinfoW.hwnd = NULL;
+        toolinfoW.uId = 0xABCD1234;
+        toolinfoW.lpszText = bufW;
+        SendMessageW(hwnd, TTM_ENUMTOOLSW, 0, (LPARAM)&toolinfoW);
+        textlen = lstrlenW(toolinfoW.lpszText);
+        ok(textlen == lenW, "lpszText has %d chars\n", textlen);
+        ok(toolinfoW.uId == 0x1234ABCD,
+           "uId should be retrieved, got %p\n", (void*)toolinfoW.uId);
+
+        memset(bufW, 0, sizeof(bufW));
+        toolinfoW.hwnd = NULL;
+        toolinfoW.uId = 0x1234ABCD;
+        toolinfoW.lpszText = bufW;
+        SendMessageW(hwnd, TTM_GETTOOLINFOW, 0, (LPARAM)&toolinfoW);
+        textlen = lstrlenW(toolinfoW.lpszText);
+        ok(textlen == lenW, "lpszText has %d chars\n", textlen);
+
+        memset(bufW, 0, sizeof(bufW));
+        toolinfoW.hwnd = NULL;
+        toolinfoW.uId = 0x1234ABCD;
+        toolinfoW.lpszText = bufW;
+        SendMessageW(hwnd, TTM_GETTEXTW, 0, (LPARAM)&toolinfoW);
+        textlen = lstrlenW(toolinfoW.lpszText);
+        ok(textlen == lenW ||
+           broken(textlen == 0 && toolinfoW.lpszText == NULL), /* nt4, kb186177 */
+           "lpszText has %d chars\n", textlen);
+    }
+
+    DestroyWindow(hwnd);
+}
+
 START_TEST(tooltips)
 {
     InitCommonControls();
@@ -644,4 +766,6 @@ START_TEST(tooltips)
     test_customdraw();
     test_gettext();
     test_ttm_gettoolinfo();
+    test_longtextA();
+    test_longtextW();
 }




More information about the wine-cvs mailing list