comctl32: treeview[3/3]: some more tests for TVM_GET/SETTOOLTIPS

Mikołaj Zalewski mikolaj at zalewski.pl
Sat May 5 13:23:06 CDT 2007


-------------- next part --------------
From d56f5cc6c9891a749b68adb4c93d6d49f1e08acd Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Miko=C5=82aj_Zalewski?= <mikolaj at zalewski.pl>
Date: Sat, 5 May 2007 20:10:01 +0200
Subject: [PATCH] comctl32: treeview: some more tests for TVM_GET/SETTOOLTIPS

---
 dlls/comctl32/tests/treeview.c |   63 +++++++++++++++++++++++++++++++++++++--
 1 files changed, 59 insertions(+), 4 deletions(-)

diff --git a/dlls/comctl32/tests/treeview.c b/dlls/comctl32/tests/treeview.c
index 3b99c4f..e9aefcf 100644
--- a/dlls/comctl32/tests/treeview.c
+++ b/dlls/comctl32/tests/treeview.c
@@ -32,6 +32,8 @@
 #include "wine/test.h"
 #include "msg.h"
 
+#define expect_eq(expr, value, type, format) { type ret = (expr); ok((value) == ret, #expr " expected " format " got " format "\n", value, ret); }
+
 #define NUM_MSG_SEQUENCES   1
 #define LISTVIEW_SEQ_INDEX  0
 
@@ -171,8 +173,29 @@ static const struct message TestGetSetTextColorSeq[] = {
 static const struct message TestGetSetToolTipsSeq[] = {
     { WM_COMMAND,       sent|wparam,            0x02000000 },
     { WM_PARENTNOTIFY,  sent|wparam|defwinproc, 0x00020002 },
-    { TVM_SETTOOLTIPS, sent|wparam|lparam, 0x00000000, 0x00000000 },
-    { TVM_GETTOOLTIPS, sent|wparam|lparam, 0x00000000, 0x00000000 },
+    { TVM_GETTOOLTIPS,  sent|wparam|lparam,     0x00000000, 0x00000000 },
+    { WM_STYLECHANGING, sent|wparam,             GWL_STYLE             },
+    { WM_STYLECHANGED,  sent|wparam,             GWL_STYLE             },
+    { TVM_GETTOOLTIPS,  sent|wparam|lparam,     0x00000000, 0x00000000 },
+    { TVM_SETTOOLTIPS,  sent|wparam|lparam,     0x00000000, 0x00000000 },
+    { TVM_GETTOOLTIPS,  sent|lparam|lparam,     0x00000000, 0x00000000 },
+    { TVM_SETTOOLTIPS,  sent|lparam,            0x00000000, 0x00000000 },
+    { TVM_GETTOOLTIPS,  sent|lparam|lparam,     0x00000000, 0x00000000 },
+    { WM_STYLECHANGING, sent|wparam,             GWL_STYLE             },
+    { WM_STYLECHANGED,  sent|wparam,             GWL_STYLE             },
+    { WM_NOTIFYFORMAT,  sent|lparam|defwinproc,          0,          3 },
+    { 0x0129,           sent|lparam|defwinproc,          0,          0 },   /* WM_QUERYUISTATE */
+    { WM_NOTIFYFORMAT,  sent|lparam|defwinproc,          0,          3 },
+    { TVM_GETTOOLTIPS,  sent|wparam|lparam,     0x00000000, 0x00000000 },
+    { TVM_SETTOOLTIPS,  sent|lparam,            0x00000000, 0x00000000 },
+    { WM_STYLECHANGING, sent|wparam,             GWL_STYLE             },
+    { WM_STYLECHANGED,  sent|wparam,             GWL_STYLE             },
+    { TVM_GETTOOLTIPS,  sent|wparam|lparam,     0x00000000, 0x00000000 },
+    { WM_STYLECHANGING, sent|wparam,             GWL_STYLE             },
+    { WM_STYLECHANGED,  sent|wparam,             GWL_STYLE             },
+    { WM_NOTIFYFORMAT,  sent|lparam|defwinproc,          0,          3 },
+    { 0x0129,           sent|lparam|defwinproc,          0,          0 },   /* WM_QUERYUISTATE */
+    { WM_NOTIFYFORMAT,  sent|lparam|defwinproc,          0,          3 },
     { 0 }
 };
 
@@ -472,18 +495,50 @@ static void TestGetSetTextColor(void)
 static void TestGetSetToolTips(void)
 {
     HWND hwndLastToolTip = NULL;
+    HWND hwndToolTip;
     HWND hPopupTreeView;
 
     /* show even WS_POPUP treeview doesn't send NM_TOOLTIPSCREATED */
     hPopupTreeView = CreateWindow(WC_TREEVIEW, NULL, WS_POPUP|WS_VISIBLE, 0, 0, 100, 100, hMainWnd, NULL, NULL, NULL);
     DestroyWindow(hPopupTreeView);
 
+    /* a tooltip is automatically created */
+    hwndLastToolTip = (HWND)SendMessage( hTree, TVM_GETTOOLTIPS, 0, 0 );
+    ok(hwndLastToolTip != 0, "No tooltip\n");
+    /* clearing the style destoys it */
+    SetWindowLong(hTree, GWL_STYLE, GetWindowLong(hTree, GWL_STYLE)|TVS_NOTOOLTIPS);
+    ok(SendMessage( hTree, TVM_GETTOOLTIPS, 0, 0 ) == 0, "Unexpected tooltip after clearing the style\n");
+    ok(!IsWindow(hwndLastToolTip), "Default tooltip not destroyed\n");
+
     /* Testing setting a NULL ToolTip */
-    SendMessage( hTree, TVM_SETTOOLTIPS, 0, 0 );
+    expect_eq((HWND)SendMessage( hTree, TVM_SETTOOLTIPS, 0, 0 ), NULL, HWND, "%p");
     hwndLastToolTip = (HWND)SendMessage( hTree, TVM_GETTOOLTIPS, 0, 0 );
     ok(hwndLastToolTip == NULL, "NULL tool tip, reported as 0x%p, expected 0.\n", hwndLastToolTip);
 
-    /* TODO: Add a test of an actual tooltip */
+    /* add a tooltip */
+    hwndToolTip = CreateWindow(TOOLTIPS_CLASS, NULL, WS_POPUP,
+        CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hMainWnd, NULL, NULL, NULL);
+    expect_eq((HWND)SendMessage( hTree, TVM_SETTOOLTIPS, (WPARAM)hwndToolTip, 0 ), NULL, HWND, "%p");
+    expect_eq((HWND)SendMessage( hTree, TVM_GETTOOLTIPS, 0, 0 ), hwndToolTip, HWND, "%p");
+
+    /* setting the style will create a new tooltip */
+    SetWindowLong(hTree, GWL_STYLE, GetWindowLong(hTree, GWL_STYLE)&~TVS_NOTOOLTIPS);
+    hwndLastToolTip = (HWND)SendMessage( hTree, TVM_GETTOOLTIPS, 0, 0 );
+    ok(hwndLastToolTip != hwndToolTip, "Custom tooltip reused\n");
+    ok(hwndLastToolTip != NULL, "No tooltip\n");
+    ok(IsWindow(hwndToolTip), "Custom tooltip destroyed\n");
+
+    /* TVM_SETTOOLTIPS doesn't destroy the tooltip */
+    hwndLastToolTip = (HWND)SendMessage( hTree, TVM_SETTOOLTIPS, (WPARAM)hwndToolTip, 0 );
+    ok(IsWindow(hwndLastToolTip), "Default tooltip destoyed\n");
+
+    /* setting TVS_NOTOOLTIPS does */
+    SetWindowLong(hTree, GWL_STYLE, GetWindowLong(hTree, GWL_STYLE)|TVS_NOTOOLTIPS);
+    expect_eq((HWND)SendMessage( hTree, TVM_GETTOOLTIPS, 0, 0 ), NULL, HWND, "%p");
+    ok(!IsWindow(hwndToolTip), "Custom tooltip not destroyed after setting TVS_NOTOOLTIPS\n");
+
+    /* cleanup after the tests*/
+    SetWindowLong(hTree, GWL_STYLE, GetWindowLong(hTree, GWL_STYLE)&~TVS_NOTOOLTIPS);
 }
 
 static void TestGetSetUnicodeFormat(void)
-- 
1.4.4.2


More information about the wine-patches mailing list