2011-09-21 12:30:22 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS api tests
|
|
|
|
* LICENSE: GPL - See COPYING in the top level directory
|
|
|
|
* PURPOSE: Test for TrackMouseEvent
|
|
|
|
* PROGRAMMERS: Giannis Adamopoulos
|
|
|
|
*/
|
|
|
|
|
2013-09-22 18:17:54 +00:00
|
|
|
#include <apitest.h>
|
|
|
|
|
2013-02-05 17:54:22 +00:00
|
|
|
#include <wingdi.h>
|
|
|
|
#include <winuser.h>
|
2011-09-23 12:05:40 +00:00
|
|
|
#include "helper.h"
|
2011-09-24 11:55:19 +00:00
|
|
|
#include <undocuser.h>
|
2011-09-21 12:30:22 +00:00
|
|
|
|
|
|
|
HWND hWnd1, hWnd2, hWnd3;
|
2011-09-23 12:05:40 +00:00
|
|
|
HHOOK hMouseHookLL, hMouseHook;
|
2011-09-25 16:05:09 +00:00
|
|
|
int ignore_timer = 0, ignore_mouse = 0, ignore_mousell = 0;
|
2011-09-21 12:30:22 +00:00
|
|
|
|
2011-09-23 12:05:40 +00:00
|
|
|
static int get_iwnd(HWND hWnd)
|
2011-09-21 12:30:22 +00:00
|
|
|
{
|
2011-09-23 12:05:40 +00:00
|
|
|
if(hWnd == hWnd1) return 1;
|
|
|
|
else if(hWnd == hWnd2) return 2;
|
|
|
|
else if(hWnd == hWnd3) return 3;
|
|
|
|
else return 0;
|
2011-09-21 12:30:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT CALLBACK TmeTestProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
2011-09-24 11:55:19 +00:00
|
|
|
int iwnd = get_iwnd(hWnd);
|
2011-09-21 12:30:22 +00:00
|
|
|
|
2011-09-23 11:45:44 +00:00
|
|
|
if(message == WM_PAINT)
|
|
|
|
{
|
|
|
|
PAINTSTRUCT ps;
|
|
|
|
BeginPaint(hWnd, &ps);
|
2011-09-21 12:30:22 +00:00
|
|
|
Rectangle(ps.hdc, ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom);
|
2011-09-23 11:45:44 +00:00
|
|
|
EndPaint(hWnd, &ps);
|
|
|
|
}
|
2011-09-24 11:55:19 +00:00
|
|
|
|
|
|
|
if(message > WM_USER || !iwnd || IsDWmMsg(message) || IseKeyMsg(message))
|
|
|
|
return DefWindowProc(hWnd, message, wParam, lParam);
|
|
|
|
|
|
|
|
switch(message)
|
|
|
|
{
|
|
|
|
case WM_IME_SETCONTEXT:
|
|
|
|
case WM_IME_NOTIFY :
|
|
|
|
case WM_GETICON :
|
|
|
|
case WM_GETTEXT:
|
|
|
|
break;
|
2011-09-24 12:22:21 +00:00
|
|
|
case WM_SYSTIMER:
|
|
|
|
ok(0, "Got unexpected WM_SYSTIMER in the winproc. wParam=%d\n", wParam);
|
|
|
|
break;
|
2011-09-24 11:55:19 +00:00
|
|
|
default:
|
2012-08-13 18:04:04 +00:00
|
|
|
RECOND_MESSAGE(iwnd, message, SENT, 0,0);
|
2011-09-24 11:55:19 +00:00
|
|
|
}
|
2011-09-21 12:30:22 +00:00
|
|
|
return DefWindowProc(hWnd, message, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
2011-09-23 12:05:40 +00:00
|
|
|
static LRESULT CALLBACK MouseLLHookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
2011-09-25 16:05:09 +00:00
|
|
|
LRESULT ret;
|
2012-08-13 18:04:04 +00:00
|
|
|
RECOND_MESSAGE(0, WH_MOUSE_LL, HOOK, wParam, 0);
|
2011-09-25 16:05:09 +00:00
|
|
|
ret = CallNextHookEx(hMouseHookLL, nCode, wParam, lParam);
|
|
|
|
if(ignore_mousell)
|
|
|
|
return TRUE;
|
|
|
|
return ret;
|
2011-09-23 12:05:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static LRESULT CALLBACK MouseHookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
MOUSEHOOKSTRUCT *hs = (MOUSEHOOKSTRUCT*) lParam;
|
2011-09-25 16:05:09 +00:00
|
|
|
LRESULT ret;
|
2012-08-13 18:04:04 +00:00
|
|
|
RECOND_MESSAGE(get_iwnd(hs->hwnd), WH_MOUSE, HOOK, wParam, hs->wHitTestCode);
|
2011-09-25 16:05:09 +00:00
|
|
|
ret = CallNextHookEx(hMouseHook, nCode, wParam, lParam);
|
|
|
|
if(ignore_mouse)
|
|
|
|
return TRUE;
|
|
|
|
return ret;
|
2011-09-23 12:05:40 +00:00
|
|
|
}
|
|
|
|
|
2011-09-24 11:55:19 +00:00
|
|
|
static void FlushMessages()
|
|
|
|
{
|
|
|
|
MSG msg;
|
|
|
|
|
|
|
|
while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
|
|
|
|
{
|
|
|
|
int iwnd = get_iwnd(msg.hwnd);
|
|
|
|
if(iwnd)
|
|
|
|
{
|
|
|
|
if(msg.message == WM_SYSTIMER)
|
2011-09-25 16:05:09 +00:00
|
|
|
{
|
2012-08-13 18:04:04 +00:00
|
|
|
RECOND_MESSAGE(iwnd, msg.message, POST,msg.wParam,0);
|
2011-09-25 16:05:09 +00:00
|
|
|
if(ignore_timer)
|
|
|
|
continue;
|
|
|
|
}
|
2011-09-24 11:55:19 +00:00
|
|
|
else if(!(msg.message > WM_USER || !iwnd || IsDWmMsg(msg.message) || IseKeyMsg(msg.message)))
|
2012-08-13 18:04:04 +00:00
|
|
|
RECOND_MESSAGE(iwnd, msg.message, POST,0,0);
|
2011-09-24 11:55:19 +00:00
|
|
|
}
|
|
|
|
DispatchMessageA( &msg );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-25 16:05:09 +00:00
|
|
|
#define FLUSH_MESSAGES(expected, notexpected) \
|
|
|
|
{ EXPECT_QUEUE_STATUS(expected, notexpected);\
|
|
|
|
FlushMessages();\
|
|
|
|
}
|
|
|
|
|
2011-09-21 12:30:22 +00:00
|
|
|
static void create_test_windows()
|
|
|
|
{
|
2011-09-23 12:05:40 +00:00
|
|
|
hMouseHookLL = SetWindowsHookExW(WH_MOUSE_LL, MouseLLHookProc, GetModuleHandleW( NULL ), 0);
|
|
|
|
hMouseHook = SetWindowsHookExW(WH_MOUSE, MouseHookProc, GetModuleHandleW( NULL ), GetCurrentThreadId());
|
|
|
|
ok(hMouseHook!=NULL,"failed to set hook\n");
|
|
|
|
ok(hMouseHookLL!=NULL,"failed to set hook\n");
|
|
|
|
|
|
|
|
RegisterSimpleClass(TmeTestProc, L"testClass");
|
2011-09-21 12:30:22 +00:00
|
|
|
|
|
|
|
hWnd1 = CreateWindowW(L"testClass", L"test", WS_OVERLAPPEDWINDOW,
|
|
|
|
100, 100, 500, 500, NULL, NULL, 0, NULL);
|
|
|
|
hWnd2 = CreateWindowW(L"testClass", L"test", WS_CHILD,
|
|
|
|
50, 50, 200, 200, hWnd1, NULL, 0, NULL);
|
|
|
|
hWnd3 = CreateWindowW(L"testClass", L"test", WS_CHILD,
|
|
|
|
150, 150, 200, 200, hWnd1, NULL, 0, NULL);
|
|
|
|
|
|
|
|
ShowWindow(hWnd1, SW_SHOW);
|
|
|
|
UpdateWindow(hWnd1);
|
|
|
|
ShowWindow(hWnd2, SW_SHOW);
|
|
|
|
UpdateWindow(hWnd2);
|
|
|
|
ShowWindow(hWnd3, SW_SHOWNORMAL);
|
|
|
|
UpdateWindow(hWnd3);
|
2011-09-23 11:45:44 +00:00
|
|
|
//SetWindowPos (hWnd3, HWND_TOP, 0,0,0,0, SWP_NOMOVE|SWP_NOREDRAW);
|
|
|
|
}
|
|
|
|
|
2011-09-30 15:37:13 +00:00
|
|
|
static void destroy_test_window()
|
|
|
|
{
|
|
|
|
DestroyWindow(hWnd1);
|
|
|
|
UnregisterClassW(L"testClass", 0);
|
|
|
|
UnhookWindowsHookEx(hMouseHookLL);
|
|
|
|
UnhookWindowsHookEx(hMouseHook);
|
|
|
|
}
|
|
|
|
|
2011-09-21 12:30:22 +00:00
|
|
|
static void TmeStartTracking(HWND hwnd, DWORD Flags)
|
|
|
|
{
|
|
|
|
TRACKMOUSEEVENT tme;
|
2011-09-23 11:45:44 +00:00
|
|
|
tme.cbSize = sizeof(tme);
|
2011-09-21 12:30:22 +00:00
|
|
|
tme.dwFlags = Flags;
|
2011-09-23 11:45:44 +00:00
|
|
|
tme.hwndTrack = hwnd;
|
|
|
|
tme.dwHoverTime = 1;
|
|
|
|
if(!TrackMouseEvent(&tme))
|
|
|
|
{
|
|
|
|
trace("failed!\n");
|
|
|
|
}
|
2011-09-21 12:30:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DWORD TmeQuery(HWND hwnd)
|
|
|
|
{
|
|
|
|
TRACKMOUSEEVENT tme;
|
2011-09-23 11:45:44 +00:00
|
|
|
tme.cbSize = sizeof(tme);
|
|
|
|
tme.dwFlags = TME_QUERY|TME_HOVER|TME_LEAVE;
|
|
|
|
tme.hwndTrack = hwnd;
|
|
|
|
TrackMouseEvent(&tme);
|
|
|
|
return tme.dwFlags;
|
2011-09-21 12:30:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define EXPECT_TME_FLAGS(hWnd, expected) \
|
|
|
|
{ DWORD flags = TmeQuery(hWnd); \
|
2011-09-23 11:45:44 +00:00
|
|
|
ok(flags == (expected),"wrong tme flags. expected %li, and got %li\n", (DWORD)(expected), flags); \
|
|
|
|
}
|
|
|
|
|
2011-09-25 16:05:09 +00:00
|
|
|
#define MOVE_CURSOR(x,y) mouse_event(MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE , \
|
|
|
|
x*(65535/GetSystemMetrics(SM_CXVIRTUALSCREEN)), \
|
|
|
|
y*(65535/GetSystemMetrics(SM_CYVIRTUALSCREEN)) , 0,0);
|
|
|
|
|
2011-09-21 12:30:22 +00:00
|
|
|
/* the mouse moves over hwnd2 */
|
2011-09-25 16:05:09 +00:00
|
|
|
MSG_ENTRY mousemove2_chain[]={{0, WH_MOUSE_LL, HOOK, WM_MOUSEMOVE},
|
|
|
|
{2, WM_NCHITTEST},
|
2011-09-24 11:55:19 +00:00
|
|
|
{2, WH_MOUSE,HOOK, WM_MOUSEMOVE, HTCLIENT},
|
2011-09-21 12:30:22 +00:00
|
|
|
{2, WM_SETCURSOR},
|
2011-09-23 11:45:44 +00:00
|
|
|
{1, WM_SETCURSOR},
|
2011-09-24 11:55:19 +00:00
|
|
|
{2, WM_MOUSEMOVE, POST},
|
2011-09-23 11:45:44 +00:00
|
|
|
{0,0}};
|
2011-09-21 12:30:22 +00:00
|
|
|
|
|
|
|
/* the mouse hovers hwnd2 */
|
2011-09-25 16:05:09 +00:00
|
|
|
MSG_ENTRY mousehover2_chain[]={{0, WH_MOUSE_LL, HOOK, WM_MOUSEMOVE},
|
|
|
|
{2, WM_NCHITTEST},
|
2011-09-24 11:55:19 +00:00
|
|
|
{2, WH_MOUSE,HOOK, WM_MOUSEMOVE, HTCLIENT},
|
2011-09-21 12:30:22 +00:00
|
|
|
{2, WM_SETCURSOR},
|
2011-09-23 11:45:44 +00:00
|
|
|
{1, WM_SETCURSOR},
|
2011-09-24 11:55:19 +00:00
|
|
|
{2, WM_MOUSEMOVE, POST},
|
|
|
|
{2, WM_SYSTIMER, POST, ID_TME_TIMER},
|
|
|
|
{2, WM_MOUSEHOVER, POST},
|
2011-09-23 11:45:44 +00:00
|
|
|
{0,0}};
|
2011-09-21 12:30:22 +00:00
|
|
|
|
|
|
|
/* the mouse leaves hwnd2 and moves to hwnd1 */
|
2011-09-25 16:05:09 +00:00
|
|
|
MSG_ENTRY mouseleave2to1_chain[]={{0, WH_MOUSE_LL, HOOK, WM_MOUSEMOVE},
|
|
|
|
{1, WM_NCHITTEST},
|
2011-09-24 11:55:19 +00:00
|
|
|
{1, WH_MOUSE,HOOK, WM_MOUSEMOVE, HTCLIENT},
|
2011-09-21 12:30:22 +00:00
|
|
|
{1, WM_SETCURSOR},
|
2011-09-24 11:55:19 +00:00
|
|
|
{1, WM_MOUSEMOVE, POST},
|
|
|
|
{2, WM_MOUSELEAVE, POST},
|
2011-09-23 11:45:44 +00:00
|
|
|
{0,0}};
|
2011-09-21 12:30:22 +00:00
|
|
|
|
|
|
|
/* the mouse leaves hwnd2 and moves to hwnd3 */
|
2011-09-25 16:05:09 +00:00
|
|
|
MSG_ENTRY mouseleave2to3_chain[]={{0, WH_MOUSE_LL, HOOK, WM_MOUSEMOVE},
|
|
|
|
{3, WM_NCHITTEST},
|
2011-09-24 11:55:19 +00:00
|
|
|
{3, WH_MOUSE,HOOK, WM_MOUSEMOVE, HTCLIENT},
|
2011-09-21 12:30:22 +00:00
|
|
|
{3, WM_SETCURSOR},
|
|
|
|
{1, WM_SETCURSOR},
|
2011-09-24 11:55:19 +00:00
|
|
|
{3, WM_MOUSEMOVE, POST},
|
|
|
|
{2, WM_MOUSELEAVE, POST},
|
2011-09-23 11:45:44 +00:00
|
|
|
{0,0}};
|
2011-09-21 12:30:22 +00:00
|
|
|
|
2011-09-25 16:05:09 +00:00
|
|
|
/* the mouse hovers hwnd3 */
|
|
|
|
MSG_ENTRY mousehover3_chain[]={{0, WH_MOUSE_LL, HOOK, WM_MOUSEMOVE},
|
|
|
|
{3, WM_NCHITTEST},
|
|
|
|
{3, WH_MOUSE,HOOK, WM_MOUSEMOVE, HTCLIENT},
|
|
|
|
{3, WM_SETCURSOR},
|
|
|
|
{1, WM_SETCURSOR},
|
|
|
|
{3, WM_MOUSEMOVE, POST},
|
|
|
|
{3, WM_SYSTIMER, POST, ID_TME_TIMER},
|
|
|
|
{3, WM_MOUSEHOVER, POST},
|
|
|
|
{0,0}};
|
|
|
|
|
2011-09-28 12:40:43 +00:00
|
|
|
/* the mouse hovers hwnd3 without moving */
|
|
|
|
MSG_ENTRY mousehover3_nomove_chain[]={{3, WM_SYSTIMER, POST, ID_TME_TIMER},
|
|
|
|
{3, WM_MOUSEHOVER, POST},
|
|
|
|
{0,0}};
|
|
|
|
|
2011-09-25 16:05:09 +00:00
|
|
|
/* the mouse hovers hwnd3 and the timer is not dispatched */
|
|
|
|
MSG_ENTRY mousehover3_droptimer_chain[]={{0, WH_MOUSE_LL, HOOK, WM_MOUSEMOVE},
|
|
|
|
{3, WM_NCHITTEST},
|
|
|
|
{3, WH_MOUSE,HOOK, WM_MOUSEMOVE, HTCLIENT},
|
|
|
|
{3, WM_SETCURSOR},
|
|
|
|
{1, WM_SETCURSOR},
|
|
|
|
{3, WM_MOUSEMOVE, POST},
|
|
|
|
{3, WM_SYSTIMER, POST, ID_TME_TIMER},
|
|
|
|
{0,0}};
|
|
|
|
|
|
|
|
/* the mouse hovers hwnd3 and mouse message is dropped by WH_MOUSE */
|
|
|
|
MSG_ENTRY mousehover3_dropmouse_chain[]={{0, WH_MOUSE_LL, HOOK, WM_MOUSEMOVE},
|
|
|
|
{3, WM_NCHITTEST},
|
|
|
|
{3, WH_MOUSE,HOOK, WM_MOUSEMOVE, HTCLIENT},
|
|
|
|
{3, WM_SYSTIMER, POST, ID_TME_TIMER},
|
|
|
|
{3, WM_MOUSEHOVER, POST},
|
|
|
|
{0,0}};
|
|
|
|
|
|
|
|
/* the mouse hovers hwnd3 and mouse message is dropped by WH_MOUSE_LL */
|
|
|
|
MSG_ENTRY mousehover3_dropmousell_chain[]={{0, WH_MOUSE_LL, HOOK, WM_MOUSEMOVE},
|
|
|
|
{3, WM_SYSTIMER, POST, ID_TME_TIMER},
|
|
|
|
{3, WM_MOUSEHOVER, POST},
|
|
|
|
{0,0}};
|
|
|
|
|
2011-09-28 12:40:43 +00:00
|
|
|
/* the mouse leaves hwnd3 and moves to hwnd2 and mouse message is dropped by WH_MOUSE */
|
2011-09-25 16:05:09 +00:00
|
|
|
MSG_ENTRY mouseleave3to2_dropmouse_chain[]={{0, WH_MOUSE_LL, HOOK, WM_MOUSEMOVE},
|
|
|
|
{2, WM_NCHITTEST},
|
|
|
|
{2, WH_MOUSE,HOOK, WM_MOUSEMOVE, HTCLIENT},
|
|
|
|
{0,0}};
|
|
|
|
|
2011-09-28 12:40:43 +00:00
|
|
|
/* the mouse leaves hwnd3 and moves to hwnd2 and mouse message is dropped by WH_MOUSE_LL */
|
|
|
|
MSG_ENTRY mouseleave3to2_dropmousell_chain[]={{0, WH_MOUSE_LL, HOOK, WM_MOUSEMOVE},
|
|
|
|
{0,0}};
|
|
|
|
|
|
|
|
/* after WH_MOUSE drops WM_MOUSEMOVE, WM_MOUSELEAVE is still in the queue */
|
|
|
|
MSG_ENTRY mouseleave3_remainging_chain[]={{3, WM_MOUSELEAVE, POST},
|
|
|
|
{0,0}};
|
|
|
|
|
2011-09-21 12:30:22 +00:00
|
|
|
void Test_TrackMouseEvent()
|
|
|
|
{
|
2011-09-25 16:05:09 +00:00
|
|
|
MOVE_CURSOR(0,0);
|
2011-09-21 12:30:22 +00:00
|
|
|
create_test_windows();
|
2011-09-28 12:40:43 +00:00
|
|
|
FlushMessages();
|
2012-08-13 18:04:04 +00:00
|
|
|
EMPTY_CACHE();
|
2011-09-21 12:30:22 +00:00
|
|
|
|
|
|
|
/* the mouse moves over hwnd2 */
|
2011-09-25 16:05:09 +00:00
|
|
|
MOVE_CURSOR(220,220);
|
2011-09-24 11:55:19 +00:00
|
|
|
FlushMessages();
|
2011-09-23 12:05:40 +00:00
|
|
|
COMPARE_CACHE(mousemove2_chain);
|
2011-09-23 11:45:44 +00:00
|
|
|
EXPECT_TME_FLAGS(hWnd2, 0);
|
2011-09-25 16:05:09 +00:00
|
|
|
|
|
|
|
/* Begin tracking mouse events for hWnd2 */
|
2011-09-23 11:45:44 +00:00
|
|
|
TmeStartTracking(hWnd2, TME_HOVER|TME_LEAVE);
|
|
|
|
EXPECT_TME_FLAGS(hWnd2, TME_HOVER|TME_LEAVE);
|
2011-09-24 11:55:19 +00:00
|
|
|
FlushMessages();
|
2011-09-23 12:05:40 +00:00
|
|
|
COMPARE_CACHE(empty_chain);
|
2011-09-23 11:45:44 +00:00
|
|
|
|
2011-09-21 12:30:22 +00:00
|
|
|
/* the mouse hovers hwnd2 */
|
2011-09-25 16:05:09 +00:00
|
|
|
MOVE_CURSOR(221, 221);
|
2011-09-23 11:45:44 +00:00
|
|
|
Sleep(100);
|
|
|
|
EXPECT_TME_FLAGS(hWnd2, TME_HOVER|TME_LEAVE);
|
2011-09-25 16:05:09 +00:00
|
|
|
FLUSH_MESSAGES(QS_TIMER|QS_MOUSEMOVE, 0);
|
2011-09-23 11:45:44 +00:00
|
|
|
EXPECT_TME_FLAGS(hWnd2, TME_LEAVE);
|
2011-09-23 12:05:40 +00:00
|
|
|
COMPARE_CACHE(mousehover2_chain);
|
2011-09-23 11:45:44 +00:00
|
|
|
|
|
|
|
/* the mouse leaves hwnd2 and moves to hwnd1 */
|
2011-09-25 16:05:09 +00:00
|
|
|
MOVE_CURSOR(150, 150);
|
2011-09-23 11:45:44 +00:00
|
|
|
EXPECT_TME_FLAGS(hWnd2, TME_LEAVE);
|
2011-09-25 16:05:09 +00:00
|
|
|
FLUSH_MESSAGES(QS_MOUSEMOVE,QS_TIMER );
|
2011-09-23 11:45:44 +00:00
|
|
|
EXPECT_TME_FLAGS(hWnd2, 0);
|
2011-09-23 12:05:40 +00:00
|
|
|
COMPARE_CACHE(mouseleave2to1_chain);
|
2011-09-23 11:45:44 +00:00
|
|
|
|
2011-09-24 11:55:19 +00:00
|
|
|
FlushMessages();
|
2011-09-23 12:05:40 +00:00
|
|
|
COMPARE_CACHE(empty_chain);
|
2011-09-23 11:45:44 +00:00
|
|
|
|
2011-09-21 12:30:22 +00:00
|
|
|
/* the mouse moves over hwnd2 */
|
2011-09-25 16:05:09 +00:00
|
|
|
MOVE_CURSOR(220,220);
|
|
|
|
FLUSH_MESSAGES(QS_MOUSEMOVE, QS_TIMER);
|
2011-09-23 12:05:40 +00:00
|
|
|
COMPARE_CACHE(mousemove2_chain);
|
2011-09-23 11:45:44 +00:00
|
|
|
EXPECT_TME_FLAGS(hWnd2, 0);
|
2011-09-25 16:05:09 +00:00
|
|
|
|
|
|
|
FlushMessages();
|
2011-09-23 12:05:40 +00:00
|
|
|
COMPARE_CACHE(empty_chain);
|
2011-09-25 16:05:09 +00:00
|
|
|
|
|
|
|
/* Begin tracking mouse events for hWnd2 */
|
2011-09-23 11:45:44 +00:00
|
|
|
TmeStartTracking(hWnd2, TME_HOVER|TME_LEAVE);
|
|
|
|
TmeStartTracking(hWnd2, TME_HOVER|TME_LEAVE);
|
|
|
|
TmeStartTracking(hWnd2, TME_HOVER|TME_LEAVE);
|
|
|
|
TmeStartTracking(hWnd2, TME_HOVER|TME_LEAVE);
|
2011-09-25 16:05:09 +00:00
|
|
|
FLUSH_MESSAGES(0, QS_TIMER|QS_MOUSEMOVE);
|
2011-09-23 12:05:40 +00:00
|
|
|
COMPARE_CACHE(empty_chain);
|
2011-09-23 11:45:44 +00:00
|
|
|
EXPECT_TME_FLAGS(hWnd2, TME_HOVER|TME_LEAVE);
|
|
|
|
|
2011-09-21 12:30:22 +00:00
|
|
|
/* the mouse moves from hwnd2 to the intersection of hwnd2 and hwnd3 */
|
2011-09-25 16:05:09 +00:00
|
|
|
MOVE_CURSOR(300,300);
|
|
|
|
FLUSH_MESSAGES(QS_MOUSEMOVE, QS_TIMER);
|
2011-09-23 11:45:44 +00:00
|
|
|
EXPECT_TME_FLAGS(hWnd2, TME_HOVER|TME_LEAVE);
|
2011-09-23 12:05:40 +00:00
|
|
|
COMPARE_CACHE(mousemove2_chain);
|
2011-09-23 11:45:44 +00:00
|
|
|
|
2011-09-24 11:55:19 +00:00
|
|
|
FlushMessages();
|
2011-09-23 12:05:40 +00:00
|
|
|
COMPARE_CACHE(empty_chain);
|
2011-09-23 11:45:44 +00:00
|
|
|
|
|
|
|
/* the mouse moves from hwnd2 to hwnd3 */
|
2011-09-25 16:05:09 +00:00
|
|
|
MOVE_CURSOR(400,400);
|
|
|
|
FLUSH_MESSAGES(QS_MOUSEMOVE, QS_TIMER);
|
2011-09-23 11:45:44 +00:00
|
|
|
EXPECT_TME_FLAGS(hWnd2, 0);
|
2011-09-23 12:05:40 +00:00
|
|
|
COMPARE_CACHE(mouseleave2to3_chain);
|
2011-09-23 11:45:44 +00:00
|
|
|
|
2011-09-24 11:55:19 +00:00
|
|
|
FlushMessages();
|
2011-09-23 12:05:40 +00:00
|
|
|
COMPARE_CACHE(empty_chain);
|
2011-09-25 16:05:09 +00:00
|
|
|
|
|
|
|
/* Begin tracking mouse events for hWnd3 */
|
|
|
|
TmeStartTracking(hWnd3, TME_HOVER|TME_LEAVE);
|
|
|
|
FLUSH_MESSAGES(0, QS_TIMER|QS_MOUSEMOVE);
|
|
|
|
COMPARE_CACHE(empty_chain);
|
|
|
|
EXPECT_TME_FLAGS(hWnd2, TME_HOVER|TME_LEAVE);
|
|
|
|
|
|
|
|
/* the mouse hovers hwnd3 */
|
|
|
|
MOVE_CURSOR(401,401);
|
|
|
|
Sleep(100);
|
|
|
|
EXPECT_TME_FLAGS(hWnd3, TME_HOVER|TME_LEAVE);
|
|
|
|
FLUSH_MESSAGES(QS_TIMER|QS_MOUSEMOVE, 0);
|
|
|
|
EXPECT_TME_FLAGS(hWnd3, TME_LEAVE);
|
|
|
|
COMPARE_CACHE(mousehover3_chain);
|
|
|
|
|
2011-09-28 12:40:43 +00:00
|
|
|
FlushMessages();
|
|
|
|
COMPARE_CACHE(empty_chain);
|
|
|
|
|
2011-09-25 16:05:09 +00:00
|
|
|
/* Begin tracking mouse events for hWnd3 */
|
|
|
|
TmeStartTracking(hWnd3, TME_HOVER );
|
|
|
|
FLUSH_MESSAGES(0, QS_TIMER|QS_MOUSEMOVE);
|
|
|
|
COMPARE_CACHE(empty_chain);
|
|
|
|
EXPECT_TME_FLAGS(hWnd3, TME_HOVER|TME_LEAVE);
|
|
|
|
|
2011-09-28 12:40:43 +00:00
|
|
|
/* make sure that the timer will fire before the mouse moves */
|
2011-09-25 16:05:09 +00:00
|
|
|
Sleep(100);
|
2011-09-28 12:40:43 +00:00
|
|
|
FlushMessages();
|
|
|
|
COMPARE_CACHE(mousehover3_nomove_chain);
|
|
|
|
EXPECT_TME_FLAGS(hWnd3, TME_LEAVE);
|
|
|
|
|
2011-09-25 16:05:09 +00:00
|
|
|
Sleep(100);
|
2011-09-28 12:40:43 +00:00
|
|
|
FlushMessages();
|
2011-09-25 16:05:09 +00:00
|
|
|
COMPARE_CACHE(empty_chain);
|
|
|
|
|
|
|
|
/* the mouse hovers hwnd3 and the timer is not dispatched*/
|
2011-09-28 12:40:43 +00:00
|
|
|
TmeStartTracking(hWnd3, TME_HOVER );
|
2011-09-25 16:05:09 +00:00
|
|
|
ignore_timer = TRUE;
|
|
|
|
MOVE_CURSOR(400,400);
|
|
|
|
Sleep(100);
|
|
|
|
EXPECT_TME_FLAGS(hWnd3, TME_HOVER|TME_LEAVE);
|
|
|
|
FLUSH_MESSAGES(QS_TIMER|QS_MOUSEMOVE, 0); /* the loop drops WM_SYSTIMER */
|
|
|
|
EXPECT_TME_FLAGS(hWnd3, TME_HOVER|TME_LEAVE); /* TME_HOVER is still active */
|
|
|
|
COMPARE_CACHE(mousehover3_droptimer_chain); /* we get no WM_MOUSEHOVER */
|
|
|
|
ignore_timer = FALSE;
|
2011-09-28 12:40:43 +00:00
|
|
|
|
2011-09-25 16:05:09 +00:00
|
|
|
/* the mouse hovers hwnd3 and mouse message is dropped by WH_MOUSE_LL */
|
|
|
|
ignore_mousell = TRUE;
|
|
|
|
MOVE_CURSOR(402,402);
|
|
|
|
Sleep(100);
|
|
|
|
EXPECT_TME_FLAGS(hWnd3, TME_HOVER|TME_LEAVE);
|
|
|
|
FLUSH_MESSAGES(QS_TIMER, QS_MOUSEMOVE); /* WH_MOUSE_LL drops WM_MOUSEMOVE */
|
|
|
|
EXPECT_TME_FLAGS(hWnd3, TME_LEAVE);
|
|
|
|
COMPARE_CACHE(mousehover3_dropmousell_chain); /* we get WM_MOUSEHOVER normaly */
|
|
|
|
ignore_mousell = FALSE;
|
|
|
|
|
2011-09-28 12:40:43 +00:00
|
|
|
FlushMessages();
|
|
|
|
COMPARE_CACHE(empty_chain);
|
|
|
|
|
2011-09-25 16:05:09 +00:00
|
|
|
/* the mouse hovers hwnd3 and mouse message is dropped by WH_MOUSE */
|
|
|
|
ignore_mouse = TRUE;
|
|
|
|
TmeStartTracking(hWnd3, TME_HOVER );
|
|
|
|
MOVE_CURSOR(401,401);
|
|
|
|
Sleep(100);
|
|
|
|
EXPECT_TME_FLAGS(hWnd3, TME_HOVER|TME_LEAVE);
|
|
|
|
FLUSH_MESSAGES(QS_TIMER|QS_MOUSEMOVE, 0); /* WH_MOUSE drops WM_MOUSEMOVE */
|
|
|
|
EXPECT_TME_FLAGS(hWnd3, TME_LEAVE);
|
|
|
|
COMPARE_CACHE(mousehover3_dropmouse_chain); /* we get WM_MOUSEHOVER normaly */
|
|
|
|
ignore_mouse = FALSE;
|
|
|
|
|
2011-09-28 12:40:43 +00:00
|
|
|
FlushMessages();
|
|
|
|
COMPARE_CACHE(empty_chain);
|
|
|
|
|
|
|
|
/* the mouse leaves hwnd3 and moves to hwnd2 and mouse message is dropped by WH_MOUSE_LL */
|
|
|
|
ignore_mousell = TRUE;
|
|
|
|
TmeStartTracking(hWnd3, TME_LEAVE );
|
|
|
|
MOVE_CURSOR(220,220);
|
|
|
|
FLUSH_MESSAGES(0, QS_MOUSEMOVE|QS_TIMER); /* WH_MOUSE drops WM_MOUSEMOVE */
|
|
|
|
EXPECT_TME_FLAGS(hWnd3, TME_LEAVE); /* all flags are removed */
|
|
|
|
COMPARE_CACHE(mouseleave3to2_dropmousell_chain); /* we get no WM_MOUSELEAVE */
|
|
|
|
ignore_mousell = FALSE;
|
|
|
|
|
|
|
|
FlushMessages();
|
|
|
|
COMPARE_CACHE(empty_chain);
|
|
|
|
|
|
|
|
/* the mouse leaves hwnd3 and moves to hwnd2 and mouse message is dropped by WH_MOUSE */
|
2011-09-25 16:05:09 +00:00
|
|
|
ignore_mouse = TRUE;
|
|
|
|
MOVE_CURSOR(220,220);
|
|
|
|
FLUSH_MESSAGES(QS_MOUSEMOVE, QS_TIMER); /* WH_MOUSE drops WM_MOUSEMOVE */
|
|
|
|
EXPECT_TME_FLAGS(hWnd3, 0); /* all flags are removed */
|
|
|
|
COMPARE_CACHE(mouseleave3to2_dropmouse_chain); /* we get no WM_MOUSELEAVE */
|
|
|
|
ignore_mouse = FALSE;
|
2011-09-28 12:40:43 +00:00
|
|
|
|
|
|
|
/* after WH_MOUSE drops WM_MOUSEMOVE, WM_MOUSELEAVE is still in the queue */
|
|
|
|
FLUSH_MESSAGES(QS_POSTMESSAGE, QS_TIMER|QS_MOUSEMOVE);
|
|
|
|
COMPARE_CACHE(mouseleave3_remainging_chain);
|
|
|
|
|
|
|
|
FlushMessages();
|
|
|
|
COMPARE_CACHE(empty_chain);
|
2011-09-30 15:37:13 +00:00
|
|
|
|
|
|
|
destroy_test_window();
|
2011-09-21 12:30:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
START_TEST(TrackMouseEvent)
|
|
|
|
{
|
|
|
|
Test_TrackMouseEvent();
|
|
|
|
}
|