Dmitry Timoshkov : user: Add more TrackMouseEvent tests, particularly a test with

Alexandre Julliard julliard at wine.codeweavers.com
Mon Jul 24 13:15:10 CDT 2006


Module: wine
Branch: refs/heads/master
Commit: a8af062baac2913fd0838813bd2783ddbcb96836
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=a8af062baac2913fd0838813bd2783ddbcb96836

Author: Dmitry Timoshkov <dmitry at codeweavers.com>
Date:   Tue Jul 25 00:45:30 2006 +0900

user: Add more TrackMouseEvent tests, particularly a test with
injected mouse move events. Fix a problem detected by the test.

---

 dlls/user/input.c     |    2 +
 dlls/user/tests/msg.c |   94 +++++++++++++++++++++++++++++++++++++------------
 2 files changed, 73 insertions(+), 23 deletions(-)

diff --git a/dlls/user/input.c b/dlls/user/input.c
index 131bcd8..26c3b96 100644
--- a/dlls/user/input.c
+++ b/dlls/user/input.c
@@ -894,6 +894,8 @@ TrackMouseEvent (TRACKMOUSEEVENT *ptme)
     if (ptme->dwFlags & TME_QUERY )
     {
         *ptme = tracking_info.tme;
+        /* set cbSize in the case it's not initialized yet */
+        ptme->cbSize = sizeof(TRACKMOUSEEVENT);
 
         return TRUE; /* return here, TME_QUERY is retrieving information */
     }
diff --git a/dlls/user/tests/msg.c b/dlls/user/tests/msg.c
index f462b43..5b7cd37 100644
--- a/dlls/user/tests/msg.c
+++ b/dlls/user/tests/msg.c
@@ -7624,6 +7624,48 @@ static const struct message WmMouseHover
     { 0 }
 };
 
+static void pump_msg_loop_timeout(DWORD timeout, BOOL inject_mouse_move)
+{
+    MSG msg;
+    DWORD start_ticks, end_ticks;
+
+    start_ticks = GetTickCount();
+    /* add some deviation (5%) to cover not expected delays */
+    start_ticks += timeout / 20;
+
+    do
+    {
+        while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
+        {
+            /* Timer proc messages are not dispatched to the window proc,
+             * and therefore not logged.
+             */
+            if (msg.message == WM_TIMER || msg.message == WM_SYSTIMER)
+            {
+                struct message s_msg;
+
+                s_msg.message = msg.message;
+                s_msg.flags = sent|wparam|lparam;
+                s_msg.wParam = msg.wParam;
+                s_msg.lParam = msg.lParam;
+                add_message(&s_msg);
+            }
+            DispatchMessage(&msg);
+        }
+
+        end_ticks = GetTickCount();
+
+        /* inject WM_MOUSEMOVE to see how it changes tracking */
+        if (inject_mouse_move && start_ticks + timeout / 2 >= end_ticks)
+        {
+            mouse_event(MOUSEEVENTF_MOVE, -1, 0, 0, 0);
+            mouse_event(MOUSEEVENTF_MOVE, 1, 0, 0, 0);
+
+            inject_mouse_move = FALSE;
+        }
+    } while (start_ticks + timeout >= end_ticks);
+}
+
 static void test_TrackMouseEvent(void)
 {
     MSG msg;
@@ -7631,8 +7673,7 @@ static void test_TrackMouseEvent(void)
     BOOL ret;
     HWND hwnd, hchild;
     RECT rc_parent, rc_child;
-    UINT default_hover_time;
-    DWORD start_ticks, end_ticks;
+    UINT default_hover_time, hover_width = 0, hover_height = 0;
 
 #define track_hover(track_hwnd, track_hover_time) \
     tme.cbSize = sizeof(tme); \
@@ -7651,6 +7692,7 @@ #define track_query(expected_track_flags
     SetLastError(0xdeadbeef); \
     ret = TrackMouseEvent(&tme); \
     ok(ret, "TrackMouseEvent(TME_QUERY) error %ld\n", GetLastError());\
+    ok(tme.cbSize == sizeof(tme), "wrong tme.cbSize %lu\n", tme.cbSize); \
     ok(tme.dwFlags == (expected_track_flags), \
        "wrong tme.dwFlags %08lx, expected %08x\n", tme.dwFlags, (expected_track_flags)); \
     ok(tme.hwndTrack == (expected_track_hwnd), \
@@ -7672,6 +7714,10 @@ #define track_hover_cancel(track_hwnd) \
     ok(ret, "SystemParametersInfo(SPI_GETMOUSEHOVERTIME) failed\n");
     trace("SPI_GETMOUSEHOVERTIME returned %u ms\n", default_hover_time);
 
+    SystemParametersInfo(SPI_GETMOUSEHOVERWIDTH, 0, &hover_width, 0);
+    SystemParametersInfo(SPI_GETMOUSEHOVERHEIGHT, 0, &hover_height, 0);
+    trace("hover rect is %u x %d\n", hover_width, hover_height);
+
     hwnd = CreateWindowEx(0, "TestWindowClass", NULL,
 			  WS_OVERLAPPEDWINDOW | WS_VISIBLE,
 			  CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
@@ -7734,32 +7780,34 @@ #define track_hover_cancel(track_hwnd) \
 
     track_hover(hwnd, 0);
     track_query(TME_HOVER, hwnd, default_hover_time);
-    start_ticks = GetTickCount();
-    do
-    {
-        while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
-        {
-            /* Timer proc messages are not dispatched to the window proc,
-             * and therefore not logged.
-             */
-            if (msg.message == WM_TIMER || msg.message == WM_SYSTIMER)
-            {
-                struct message s_msg;
 
-                s_msg.message = msg.message;
-                s_msg.flags = sent|wparam|lparam;
-                s_msg.wParam = msg.wParam;
-                s_msg.lParam = msg.lParam;
-                add_message(&s_msg);
-            }
-            DispatchMessage(&msg);
-        }
+    pump_msg_loop_timeout(default_hover_time, FALSE);
+    ok_sequence(WmMouseHoverSeq, "WmMouseHoverSeq", FALSE);
 
-        end_ticks = GetTickCount();
-    } while (start_ticks + default_hover_time >= end_ticks);
+    track_query(0, NULL, 0);
+
+    track_hover(hwnd, HOVER_DEFAULT);
+    track_query(TME_HOVER, hwnd, default_hover_time);
+
+    Sleep(default_hover_time / 2);
+    mouse_event(MOUSEEVENTF_MOVE, -1, 0, 0, 0);
+    mouse_event(MOUSEEVENTF_MOVE, 1, 0, 0, 0);
+
+    track_query(TME_HOVER, hwnd, default_hover_time);
+
+    pump_msg_loop_timeout(default_hover_time / 2, FALSE);
     ok_sequence(WmMouseHoverSeq, "WmMouseHoverSeq", FALSE);
 
     track_query(0, NULL, 0);
+
+    track_hover(hwnd, HOVER_DEFAULT);
+    track_query(TME_HOVER, hwnd, default_hover_time);
+
+    pump_msg_loop_timeout(default_hover_time, TRUE);
+    ok_sequence(WmMouseHoverSeq, "WmMouseHoverSeq", FALSE);
+
+    track_query(0, NULL, 0);
+
     track_hover(hwnd, HOVER_DEFAULT);
     track_query(TME_HOVER, hwnd, default_hover_time);
     track_hover_cancel(hwnd);




More information about the wine-cvs mailing list