mirror of
https://github.com/reactos/reactos.git
synced 2025-04-22 05:00:27 +00:00
[user32_apitest]
- Implement logging post messages or winevents - For SetActiveWindow test, also test the parameters of WM_WINDOWPOSCHANGING and WM_WINDOWPOSCHANGED messages - For TrackMouseEvent test, also test the WM_SYSTIMER that is possible to be logged now svn path=/trunk/; revision=53830
This commit is contained in:
parent
0048dee2cc
commit
31eb9d7849
4 changed files with 199 additions and 103 deletions
|
@ -9,10 +9,12 @@
|
||||||
#include <wine/test.h>
|
#include <wine/test.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include "helper.h"
|
#include "helper.h"
|
||||||
|
#include <undocuser.h>
|
||||||
|
|
||||||
MSG_ENTRY message_cache[100];
|
MSG_ENTRY message_cache[100];
|
||||||
HWND hWnd1, hWnd2, hWnd3, hWnd4;
|
HWND hWnd1, hWnd2, hWnd3, hWnd4;
|
||||||
|
|
||||||
|
/* FIXME: test for HWND_TOP, etc...*/
|
||||||
static int get_iwnd(HWND hWnd)
|
static int get_iwnd(HWND hWnd)
|
||||||
{
|
{
|
||||||
if(hWnd == hWnd1) return 1;
|
if(hWnd == hWnd1) return 1;
|
||||||
|
@ -24,26 +26,45 @@ static int get_iwnd(HWND hWnd)
|
||||||
|
|
||||||
LRESULT CALLBACK OwnerTestProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
LRESULT CALLBACK OwnerTestProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
if(message < WM_USER &&
|
int iwnd = get_iwnd(hWnd);
|
||||||
message != WM_IME_SETCONTEXT &&
|
|
||||||
message != WM_IME_NOTIFY &&
|
|
||||||
message != WM_KEYUP &&
|
|
||||||
message != WM_GETICON &&
|
|
||||||
message != WM_GETTEXT && /* the following messages have to be ignroed because dwm changes the time they are sent */
|
|
||||||
message != WM_NCPAINT &&
|
|
||||||
message != WM_ERASEBKGND &&
|
|
||||||
message != WM_PAINT &&
|
|
||||||
message != 0x031f /*WM_DWMNCRENDERINGCHANGED*/)
|
|
||||||
{
|
|
||||||
int iwnd;
|
|
||||||
iwnd = get_iwnd(hWnd);
|
|
||||||
if(iwnd)
|
|
||||||
record_message(iwnd, message, FALSE, 0,0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
case WM_WINDOWPOSCHANGING:
|
||||||
|
case WM_WINDOWPOSCHANGED:
|
||||||
|
{
|
||||||
|
WINDOWPOS* pwp = (WINDOWPOS*)lParam;
|
||||||
|
ok(wParam==0,"expected wParam=0\n");
|
||||||
|
record_message(iwnd, message, SENT, get_iwnd(pwp->hwndInsertAfter), pwp->flags);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
record_message(iwnd, message, SENT, 0,0);
|
||||||
|
}
|
||||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void FlushMessages()
|
||||||
|
{
|
||||||
|
MSG msg;
|
||||||
|
|
||||||
|
while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
|
||||||
|
{
|
||||||
|
int iwnd = get_iwnd(msg.hwnd);
|
||||||
|
if(!(msg.message > WM_USER || !iwnd || IsDWmMsg(msg.message) || IseKeyMsg(msg.message)))
|
||||||
|
record_message(iwnd, msg.message, POST,0,0);
|
||||||
|
DispatchMessageA( &msg );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void create_test_windows()
|
static void create_test_windows()
|
||||||
{
|
{
|
||||||
RegisterSimpleClass(OwnerTestProc, L"ownertest");
|
RegisterSimpleClass(OwnerTestProc, L"ownertest");
|
||||||
|
@ -58,17 +79,15 @@ static void create_test_windows()
|
||||||
|
|
||||||
hWnd4 = CreateWindowW(L"ownertest", L"ownertest", WS_OVERLAPPEDWINDOW,
|
hWnd4 = CreateWindowW(L"ownertest", L"ownertest", WS_OVERLAPPEDWINDOW,
|
||||||
250, 250, 200, 200, hWnd1, NULL, 0, NULL);
|
250, 250, 200, 200, hWnd1, NULL, 0, NULL);
|
||||||
|
|
||||||
trace("1:%p, 2:%p, 3:%p,4:%p\n", hWnd1, hWnd2, hWnd3, hWnd4);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* the actual test begins here */
|
/* the actual test begins here */
|
||||||
|
|
||||||
MSG_ENTRY Activate1_chain[]={{4,WM_NCACTIVATE},
|
MSG_ENTRY Activate1_chain[]={{4,WM_NCACTIVATE},
|
||||||
{4,WM_ACTIVATE},
|
{4,WM_ACTIVATE},
|
||||||
{4,WM_WINDOWPOSCHANGING},
|
{4,WM_WINDOWPOSCHANGING,SENT,0,SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE},
|
||||||
{2,WM_WINDOWPOSCHANGING},
|
{2,WM_WINDOWPOSCHANGING,SENT,4,SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE},
|
||||||
{1,WM_WINDOWPOSCHANGING},
|
{1,WM_WINDOWPOSCHANGING,SENT,2,SWP_NOMOVE | SWP_NOSIZE},
|
||||||
{1,WM_NCACTIVATE},
|
{1,WM_NCACTIVATE},
|
||||||
{1,WM_ACTIVATE},
|
{1,WM_ACTIVATE},
|
||||||
{4,WM_KILLFOCUS},
|
{4,WM_KILLFOCUS},
|
||||||
|
@ -77,8 +96,8 @@ MSG_ENTRY Activate1_chain[]={{4,WM_NCACTIVATE},
|
||||||
|
|
||||||
MSG_ENTRY Activate2_chain[]={{1,WM_NCACTIVATE},
|
MSG_ENTRY Activate2_chain[]={{1,WM_NCACTIVATE},
|
||||||
{1,WM_ACTIVATE},
|
{1,WM_ACTIVATE},
|
||||||
{3,WM_WINDOWPOSCHANGING},
|
{3,WM_WINDOWPOSCHANGING,SENT, 0, SWP_NOMOVE | SWP_NOSIZE},
|
||||||
{3,WM_WINDOWPOSCHANGED},
|
{3,WM_WINDOWPOSCHANGED ,SENT, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOCLIENTMOVE|SWP_NOCLIENTSIZE},
|
||||||
{3,WM_NCACTIVATE},
|
{3,WM_NCACTIVATE},
|
||||||
{3,WM_ACTIVATE},
|
{3,WM_ACTIVATE},
|
||||||
{1,WM_KILLFOCUS},
|
{1,WM_KILLFOCUS},
|
||||||
|
@ -87,23 +106,23 @@ MSG_ENTRY Activate2_chain[]={{1,WM_NCACTIVATE},
|
||||||
|
|
||||||
MSG_ENTRY Activate3_chain[]={{3,WM_NCACTIVATE},
|
MSG_ENTRY Activate3_chain[]={{3,WM_NCACTIVATE},
|
||||||
{3,WM_ACTIVATE},
|
{3,WM_ACTIVATE},
|
||||||
{2,WM_WINDOWPOSCHANGING},
|
{2,WM_WINDOWPOSCHANGING, SENT,0, SWP_NOMOVE | SWP_NOSIZE },
|
||||||
{4,WM_WINDOWPOSCHANGING},
|
{4,WM_WINDOWPOSCHANGING, SENT,2, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE},
|
||||||
{1,WM_WINDOWPOSCHANGING},
|
{1,WM_WINDOWPOSCHANGING, SENT,4, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE},
|
||||||
{2,WM_WINDOWPOSCHANGED},
|
{2,WM_WINDOWPOSCHANGED, SENT,0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOCLIENTMOVE |SWP_NOCLIENTSIZE },
|
||||||
{4,WM_WINDOWPOSCHANGED},
|
{4,WM_WINDOWPOSCHANGED, SENT,2, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE |SWP_NOCLIENTMOVE|SWP_NOCLIENTSIZE},
|
||||||
{1,WM_WINDOWPOSCHANGED},
|
{1,WM_WINDOWPOSCHANGED, SENT,4, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE |SWP_NOCLIENTMOVE|SWP_NOCLIENTSIZE},
|
||||||
{2,WM_NCACTIVATE},
|
{2,WM_NCACTIVATE},
|
||||||
{2,WM_ACTIVATE},
|
{2,WM_ACTIVATE},
|
||||||
{3,WM_KILLFOCUS},
|
{3,WM_KILLFOCUS},
|
||||||
{2,WM_SETFOCUS},
|
{2,WM_SETFOCUS},
|
||||||
{0,0}};
|
{0,0}};
|
||||||
|
|
||||||
MSG_ENTRY Activate4_chain[]={{2,WM_NCACTIVATE},
|
MSG_ENTRY Activate4_chain[]={{2,WM_NCACTIVATE, },
|
||||||
{2,WM_ACTIVATE},
|
{2,WM_ACTIVATE},
|
||||||
{2,WM_WINDOWPOSCHANGING},
|
{2,WM_WINDOWPOSCHANGING, SENT ,0 ,SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE},
|
||||||
{4,WM_WINDOWPOSCHANGING},
|
{4,WM_WINDOWPOSCHANGING, SENT, 2, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE} ,
|
||||||
{1,WM_WINDOWPOSCHANGING},
|
{1,WM_WINDOWPOSCHANGING, SENT, 4, SWP_NOMOVE | SWP_NOSIZE},
|
||||||
{1,WM_NCACTIVATE},
|
{1,WM_NCACTIVATE},
|
||||||
{1,WM_ACTIVATE},
|
{1,WM_ACTIVATE},
|
||||||
{2,WM_KILLFOCUS},
|
{2,WM_KILLFOCUS},
|
||||||
|
@ -112,34 +131,32 @@ MSG_ENTRY Activate4_chain[]={{2,WM_NCACTIVATE},
|
||||||
|
|
||||||
void Test_SetActiveWindow()
|
void Test_SetActiveWindow()
|
||||||
{
|
{
|
||||||
MSG msg;
|
|
||||||
|
|
||||||
SetCursorPos(0,0);
|
SetCursorPos(0,0);
|
||||||
|
|
||||||
create_test_windows();
|
create_test_windows();
|
||||||
|
|
||||||
ShowWindow(hWnd1, SW_SHOW);
|
ShowWindow(hWnd1, SW_SHOW);
|
||||||
UpdateWindow(hWnd1);
|
UpdateWindow(hWnd1);
|
||||||
FLUSH_MESSAGES(msg);
|
FlushMessages();
|
||||||
EXPECT_NEXT(hWnd4,hWnd2);
|
EXPECT_NEXT(hWnd4,hWnd2);
|
||||||
EXPECT_NEXT(hWnd1,hWnd3);
|
EXPECT_NEXT(hWnd1,hWnd3);
|
||||||
|
|
||||||
ShowWindow(hWnd2, SW_SHOW);
|
ShowWindow(hWnd2, SW_SHOW);
|
||||||
UpdateWindow(hWnd2);
|
UpdateWindow(hWnd2);
|
||||||
FLUSH_MESSAGES(msg);
|
FlushMessages();
|
||||||
EXPECT_NEXT(hWnd2,hWnd4);
|
EXPECT_NEXT(hWnd2,hWnd4);
|
||||||
EXPECT_NEXT(hWnd4,hWnd1);
|
EXPECT_NEXT(hWnd4,hWnd1);
|
||||||
|
|
||||||
ShowWindow(hWnd3, SW_SHOW);
|
ShowWindow(hWnd3, SW_SHOW);
|
||||||
UpdateWindow(hWnd3);
|
UpdateWindow(hWnd3);
|
||||||
FLUSH_MESSAGES(msg);
|
FlushMessages();
|
||||||
EXPECT_NEXT(hWnd3,hWnd2);
|
EXPECT_NEXT(hWnd3,hWnd2);
|
||||||
EXPECT_NEXT(hWnd2,hWnd4);
|
EXPECT_NEXT(hWnd2,hWnd4);
|
||||||
EXPECT_NEXT(hWnd4,hWnd1);
|
EXPECT_NEXT(hWnd4,hWnd1);
|
||||||
|
|
||||||
ShowWindow(hWnd4, SW_SHOW);
|
ShowWindow(hWnd4, SW_SHOW);
|
||||||
UpdateWindow(hWnd4);
|
UpdateWindow(hWnd4);
|
||||||
FLUSH_MESSAGES(msg);
|
FlushMessages();
|
||||||
EXPECT_NEXT(hWnd4,hWnd2);
|
EXPECT_NEXT(hWnd4,hWnd2);
|
||||||
EXPECT_NEXT(hWnd2,hWnd1);
|
EXPECT_NEXT(hWnd2,hWnd1);
|
||||||
EXPECT_NEXT(hWnd1,hWnd3);
|
EXPECT_NEXT(hWnd1,hWnd3);
|
||||||
|
@ -148,7 +165,7 @@ void Test_SetActiveWindow()
|
||||||
empty_message_cache();
|
empty_message_cache();
|
||||||
|
|
||||||
SetActiveWindow(hWnd1);
|
SetActiveWindow(hWnd1);
|
||||||
FLUSH_MESSAGES(msg);
|
FlushMessages();
|
||||||
EXPECT_NEXT(hWnd4,hWnd2);
|
EXPECT_NEXT(hWnd4,hWnd2);
|
||||||
EXPECT_NEXT(hWnd2,hWnd1);
|
EXPECT_NEXT(hWnd2,hWnd1);
|
||||||
EXPECT_NEXT(hWnd1,hWnd3);
|
EXPECT_NEXT(hWnd1,hWnd3);
|
||||||
|
@ -156,7 +173,7 @@ void Test_SetActiveWindow()
|
||||||
COMPARE_CACHE(Activate1_chain);
|
COMPARE_CACHE(Activate1_chain);
|
||||||
|
|
||||||
SetActiveWindow(hWnd3);
|
SetActiveWindow(hWnd3);
|
||||||
FLUSH_MESSAGES(msg);
|
FlushMessages();
|
||||||
EXPECT_NEXT(hWnd3,hWnd4);
|
EXPECT_NEXT(hWnd3,hWnd4);
|
||||||
EXPECT_NEXT(hWnd4,hWnd2);
|
EXPECT_NEXT(hWnd4,hWnd2);
|
||||||
EXPECT_NEXT(hWnd2,hWnd1);
|
EXPECT_NEXT(hWnd2,hWnd1);
|
||||||
|
@ -164,7 +181,7 @@ void Test_SetActiveWindow()
|
||||||
COMPARE_CACHE(Activate2_chain);
|
COMPARE_CACHE(Activate2_chain);
|
||||||
|
|
||||||
SetActiveWindow(hWnd2);
|
SetActiveWindow(hWnd2);
|
||||||
FLUSH_MESSAGES(msg);
|
FlushMessages();
|
||||||
EXPECT_NEXT(hWnd2,hWnd4);
|
EXPECT_NEXT(hWnd2,hWnd4);
|
||||||
EXPECT_NEXT(hWnd4,hWnd1);
|
EXPECT_NEXT(hWnd4,hWnd1);
|
||||||
EXPECT_NEXT(hWnd1,hWnd3);
|
EXPECT_NEXT(hWnd1,hWnd3);
|
||||||
|
@ -172,7 +189,7 @@ void Test_SetActiveWindow()
|
||||||
COMPARE_CACHE(Activate3_chain);
|
COMPARE_CACHE(Activate3_chain);
|
||||||
|
|
||||||
SetActiveWindow(hWnd1);
|
SetActiveWindow(hWnd1);
|
||||||
FLUSH_MESSAGES(msg);
|
FlushMessages();
|
||||||
EXPECT_NEXT(hWnd2,hWnd4);
|
EXPECT_NEXT(hWnd2,hWnd4);
|
||||||
EXPECT_NEXT(hWnd4,hWnd1);
|
EXPECT_NEXT(hWnd4,hWnd1);
|
||||||
EXPECT_NEXT(hWnd1,hWnd3);
|
EXPECT_NEXT(hWnd1,hWnd3);
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <wine/test.h>
|
#include <wine/test.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include "helper.h"
|
#include "helper.h"
|
||||||
|
#include <undocuser.h>
|
||||||
|
|
||||||
HWND hWnd1, hWnd2, hWnd3;
|
HWND hWnd1, hWnd2, hWnd3;
|
||||||
HHOOK hMouseHookLL, hMouseHook;
|
HHOOK hMouseHookLL, hMouseHook;
|
||||||
|
@ -23,21 +24,7 @@ static int get_iwnd(HWND hWnd)
|
||||||
|
|
||||||
LRESULT CALLBACK TmeTestProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
LRESULT CALLBACK TmeTestProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
if(message < WM_USER &&
|
int iwnd = get_iwnd(hWnd);
|
||||||
message != WM_IME_SETCONTEXT &&
|
|
||||||
message != WM_IME_NOTIFY &&
|
|
||||||
message != WM_KEYUP &&
|
|
||||||
message != WM_GETICON &&
|
|
||||||
message != WM_GETTEXT && /* the following messages have to be ignroed because dwm changes the time they are sent */
|
|
||||||
message != WM_NCPAINT &&
|
|
||||||
message != WM_ERASEBKGND &&
|
|
||||||
message != WM_PAINT &&
|
|
||||||
message != 0x031f /*WM_DWMNCRENDERINGCHANGED*/)
|
|
||||||
{
|
|
||||||
int iwnd = get_iwnd(hWnd);
|
|
||||||
if(iwnd)
|
|
||||||
record_message(iwnd, message, FALSE,0,0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(message == WM_PAINT)
|
if(message == WM_PAINT)
|
||||||
{
|
{
|
||||||
|
@ -46,23 +33,54 @@ LRESULT CALLBACK TmeTestProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPar
|
||||||
Rectangle(ps.hdc, ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom);
|
Rectangle(ps.hdc, ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom);
|
||||||
EndPaint(hWnd, &ps);
|
EndPaint(hWnd, &ps);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
default:
|
||||||
|
record_message(iwnd, message, SENT, 0,0);
|
||||||
|
}
|
||||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
static LRESULT CALLBACK MouseLLHookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
static LRESULT CALLBACK MouseLLHookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
record_message(0, WH_MOUSE_LL, TRUE, wParam, 0);
|
record_message(0, WH_MOUSE_LL, HOOK, wParam, 0);
|
||||||
return CallNextHookEx(hMouseHookLL, nCode, wParam, lParam);
|
return CallNextHookEx(hMouseHookLL, nCode, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
static LRESULT CALLBACK MouseHookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
static LRESULT CALLBACK MouseHookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
MOUSEHOOKSTRUCT *hs = (MOUSEHOOKSTRUCT*) lParam;
|
MOUSEHOOKSTRUCT *hs = (MOUSEHOOKSTRUCT*) lParam;
|
||||||
record_message(get_iwnd(hs->hwnd), WH_MOUSE, TRUE, wParam, hs->wHitTestCode);
|
record_message(get_iwnd(hs->hwnd), WH_MOUSE, HOOK, wParam, hs->wHitTestCode);
|
||||||
return CallNextHookEx(hMouseHook, nCode, wParam, lParam);
|
return CallNextHookEx(hMouseHook, nCode, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
record_message(iwnd, msg.message, POST,msg.wParam,0);
|
||||||
|
else if(!(msg.message > WM_USER || !iwnd || IsDWmMsg(msg.message) || IseKeyMsg(msg.message)))
|
||||||
|
record_message(iwnd, msg.message, POST,0,0);
|
||||||
|
}
|
||||||
|
DispatchMessageA( &msg );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void create_test_windows()
|
static void create_test_windows()
|
||||||
{
|
{
|
||||||
WNDCLASSEXW wcex;
|
WNDCLASSEXW wcex;
|
||||||
|
@ -114,73 +132,63 @@ DWORD TmeQuery(HWND hwnd)
|
||||||
return tme.dwFlags;
|
return tme.dwFlags;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FLUSH_MESSAGES(msg) while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg );
|
|
||||||
#define EXPECT_TME_FLAGS(hWnd, expected) \
|
#define EXPECT_TME_FLAGS(hWnd, expected) \
|
||||||
{ DWORD flags = TmeQuery(hWnd); \
|
{ DWORD flags = TmeQuery(hWnd); \
|
||||||
ok(flags == (expected),"wrong tme flags. expected %li, and got %li\n", (DWORD)(expected), flags); \
|
ok(flags == (expected),"wrong tme flags. expected %li, and got %li\n", (DWORD)(expected), flags); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define EXPECT_QUEUE_STATUS(expected, notexpected) \
|
|
||||||
{ \
|
|
||||||
DWORD status = HIWORD(GetQueueStatus(QS_ALLEVENTS)); \
|
|
||||||
ok(((status) & (expected))== (expected),"wrong queue status. expected %li, and got %li\n", (DWORD)(expected), status); \
|
|
||||||
if(notexpected) \
|
|
||||||
ok((status & (notexpected))!=(notexpected), "wrong queue status. got non expected %li\n", (DWORD)(notexpected)); \
|
|
||||||
}
|
|
||||||
|
|
||||||
MSG_ENTRY empty_chain[]= {{0,0}};
|
MSG_ENTRY empty_chain[]= {{0,0}};
|
||||||
|
|
||||||
/* the mouse moves over hwnd2 */
|
/* the mouse moves over hwnd2 */
|
||||||
MSG_ENTRY mousemove2_chain[]={{2, WM_NCHITTEST},
|
MSG_ENTRY mousemove2_chain[]={{2, WM_NCHITTEST},
|
||||||
{2, WH_MOUSE,1, WM_MOUSEMOVE, HTCLIENT},
|
{2, WH_MOUSE,HOOK, WM_MOUSEMOVE, HTCLIENT},
|
||||||
{2, WM_SETCURSOR},
|
{2, WM_SETCURSOR},
|
||||||
{1, WM_SETCURSOR},
|
{1, WM_SETCURSOR},
|
||||||
{2, WM_MOUSEMOVE},
|
{2, WM_MOUSEMOVE, POST},
|
||||||
{0,0}};
|
{0,0}};
|
||||||
|
|
||||||
/* the mouse hovers hwnd2 */
|
/* the mouse hovers hwnd2 */
|
||||||
MSG_ENTRY mousehover2_chain[]={{2, WM_NCHITTEST},
|
MSG_ENTRY mousehover2_chain[]={{2, WM_NCHITTEST},
|
||||||
{2, WH_MOUSE,1, WM_MOUSEMOVE, HTCLIENT},
|
{2, WH_MOUSE,HOOK, WM_MOUSEMOVE, HTCLIENT},
|
||||||
{2, WM_SETCURSOR},
|
{2, WM_SETCURSOR},
|
||||||
{1, WM_SETCURSOR},
|
{1, WM_SETCURSOR},
|
||||||
{2, WM_MOUSEMOVE},
|
{2, WM_MOUSEMOVE, POST},
|
||||||
{2, WM_MOUSEHOVER},
|
{2, WM_SYSTIMER, POST, ID_TME_TIMER},
|
||||||
|
{2, WM_MOUSEHOVER, POST},
|
||||||
{0,0}};
|
{0,0}};
|
||||||
|
|
||||||
/* the mouse leaves hwnd2 and moves to hwnd1 */
|
/* the mouse leaves hwnd2 and moves to hwnd1 */
|
||||||
MSG_ENTRY mouseleave2to1_chain[]={{1, WM_NCHITTEST},
|
MSG_ENTRY mouseleave2to1_chain[]={{1, WM_NCHITTEST},
|
||||||
{1, WH_MOUSE,1, WM_MOUSEMOVE, HTCLIENT},
|
{1, WH_MOUSE,HOOK, WM_MOUSEMOVE, HTCLIENT},
|
||||||
{1, WM_SETCURSOR},
|
{1, WM_SETCURSOR},
|
||||||
{1, WM_MOUSEMOVE},
|
{1, WM_MOUSEMOVE, POST},
|
||||||
{2, WM_MOUSELEAVE},
|
{2, WM_MOUSELEAVE, POST},
|
||||||
{0,0}};
|
{0,0}};
|
||||||
|
|
||||||
/* the mouse leaves hwnd2 and moves to hwnd3 */
|
/* the mouse leaves hwnd2 and moves to hwnd3 */
|
||||||
MSG_ENTRY mouseleave2to3_chain[]={{3, WM_NCHITTEST},
|
MSG_ENTRY mouseleave2to3_chain[]={{3, WM_NCHITTEST},
|
||||||
{3, WH_MOUSE,1, WM_MOUSEMOVE, HTCLIENT},
|
{3, WH_MOUSE,HOOK, WM_MOUSEMOVE, HTCLIENT},
|
||||||
{3, WM_SETCURSOR},
|
{3, WM_SETCURSOR},
|
||||||
{1, WM_SETCURSOR},
|
{1, WM_SETCURSOR},
|
||||||
{3, WM_MOUSEMOVE},
|
{3, WM_MOUSEMOVE, POST},
|
||||||
{2, WM_MOUSELEAVE},
|
{2, WM_MOUSELEAVE, POST},
|
||||||
{0,0}};
|
{0,0}};
|
||||||
|
|
||||||
void Test_TrackMouseEvent()
|
void Test_TrackMouseEvent()
|
||||||
{
|
{
|
||||||
MSG msg;
|
|
||||||
|
|
||||||
SetCursorPos(0,0);
|
SetCursorPos(0,0);
|
||||||
create_test_windows();
|
create_test_windows();
|
||||||
FLUSH_MESSAGES(msg);
|
FlushMessages();
|
||||||
empty_message_cache();
|
empty_message_cache();
|
||||||
|
|
||||||
/* the mouse moves over hwnd2 */
|
/* the mouse moves over hwnd2 */
|
||||||
SetCursorPos(220,220);
|
SetCursorPos(220,220);
|
||||||
FLUSH_MESSAGES(msg);
|
FlushMessages();
|
||||||
COMPARE_CACHE(mousemove2_chain);
|
COMPARE_CACHE(mousemove2_chain);
|
||||||
EXPECT_TME_FLAGS(hWnd2, 0);
|
EXPECT_TME_FLAGS(hWnd2, 0);
|
||||||
TmeStartTracking(hWnd2, TME_HOVER|TME_LEAVE);
|
TmeStartTracking(hWnd2, TME_HOVER|TME_LEAVE);
|
||||||
EXPECT_TME_FLAGS(hWnd2, TME_HOVER|TME_LEAVE);
|
EXPECT_TME_FLAGS(hWnd2, TME_HOVER|TME_LEAVE);
|
||||||
FLUSH_MESSAGES(msg);
|
FlushMessages();
|
||||||
COMPARE_CACHE(empty_chain);
|
COMPARE_CACHE(empty_chain);
|
||||||
|
|
||||||
/* the mouse hovers hwnd2 */
|
/* the mouse hovers hwnd2 */
|
||||||
|
@ -188,7 +196,7 @@ void Test_TrackMouseEvent()
|
||||||
Sleep(100);
|
Sleep(100);
|
||||||
EXPECT_QUEUE_STATUS(QS_TIMER|QS_MOUSEMOVE, 0);
|
EXPECT_QUEUE_STATUS(QS_TIMER|QS_MOUSEMOVE, 0);
|
||||||
EXPECT_TME_FLAGS(hWnd2, TME_HOVER|TME_LEAVE);
|
EXPECT_TME_FLAGS(hWnd2, TME_HOVER|TME_LEAVE);
|
||||||
FLUSH_MESSAGES(msg);
|
FlushMessages();
|
||||||
EXPECT_TME_FLAGS(hWnd2, TME_LEAVE);
|
EXPECT_TME_FLAGS(hWnd2, TME_LEAVE);
|
||||||
COMPARE_CACHE(mousehover2_chain);
|
COMPARE_CACHE(mousehover2_chain);
|
||||||
|
|
||||||
|
@ -196,17 +204,17 @@ void Test_TrackMouseEvent()
|
||||||
SetCursorPos(150,150);
|
SetCursorPos(150,150);
|
||||||
EXPECT_QUEUE_STATUS(QS_MOUSEMOVE,QS_TIMER );
|
EXPECT_QUEUE_STATUS(QS_MOUSEMOVE,QS_TIMER );
|
||||||
EXPECT_TME_FLAGS(hWnd2, TME_LEAVE);
|
EXPECT_TME_FLAGS(hWnd2, TME_LEAVE);
|
||||||
FLUSH_MESSAGES(msg);
|
FlushMessages();
|
||||||
EXPECT_TME_FLAGS(hWnd2, 0);
|
EXPECT_TME_FLAGS(hWnd2, 0);
|
||||||
COMPARE_CACHE(mouseleave2to1_chain);
|
COMPARE_CACHE(mouseleave2to1_chain);
|
||||||
|
|
||||||
FLUSH_MESSAGES(msg);
|
FlushMessages();
|
||||||
COMPARE_CACHE(empty_chain);
|
COMPARE_CACHE(empty_chain);
|
||||||
|
|
||||||
/* the mouse moves over hwnd2 */
|
/* the mouse moves over hwnd2 */
|
||||||
SetCursorPos(220,220);
|
SetCursorPos(220,220);
|
||||||
EXPECT_QUEUE_STATUS(QS_MOUSEMOVE, QS_TIMER);
|
EXPECT_QUEUE_STATUS(QS_MOUSEMOVE, QS_TIMER);
|
||||||
FLUSH_MESSAGES(msg);
|
FlushMessages();
|
||||||
COMPARE_CACHE(mousemove2_chain);
|
COMPARE_CACHE(mousemove2_chain);
|
||||||
EXPECT_TME_FLAGS(hWnd2, 0);
|
EXPECT_TME_FLAGS(hWnd2, 0);
|
||||||
COMPARE_CACHE(empty_chain);
|
COMPARE_CACHE(empty_chain);
|
||||||
|
@ -215,31 +223,31 @@ void Test_TrackMouseEvent()
|
||||||
TmeStartTracking(hWnd2, TME_HOVER|TME_LEAVE);
|
TmeStartTracking(hWnd2, TME_HOVER|TME_LEAVE);
|
||||||
TmeStartTracking(hWnd2, TME_HOVER|TME_LEAVE);
|
TmeStartTracking(hWnd2, TME_HOVER|TME_LEAVE);
|
||||||
EXPECT_QUEUE_STATUS(0, QS_TIMER|QS_MOUSEMOVE);
|
EXPECT_QUEUE_STATUS(0, QS_TIMER|QS_MOUSEMOVE);
|
||||||
FLUSH_MESSAGES(msg);
|
FlushMessages();
|
||||||
COMPARE_CACHE(empty_chain);
|
COMPARE_CACHE(empty_chain);
|
||||||
EXPECT_TME_FLAGS(hWnd2, TME_HOVER|TME_LEAVE);
|
EXPECT_TME_FLAGS(hWnd2, TME_HOVER|TME_LEAVE);
|
||||||
|
|
||||||
FLUSH_MESSAGES(msg);
|
FlushMessages();
|
||||||
COMPARE_CACHE(empty_chain);
|
COMPARE_CACHE(empty_chain);
|
||||||
|
|
||||||
/* the mouse moves from hwnd2 to the intersection of hwnd2 and hwnd3 */
|
/* the mouse moves from hwnd2 to the intersection of hwnd2 and hwnd3 */
|
||||||
SetCursorPos(300,300);
|
SetCursorPos(300,300);
|
||||||
EXPECT_QUEUE_STATUS(QS_MOUSEMOVE, QS_TIMER);
|
EXPECT_QUEUE_STATUS(QS_MOUSEMOVE, QS_TIMER);
|
||||||
FLUSH_MESSAGES(msg);
|
FlushMessages();
|
||||||
EXPECT_TME_FLAGS(hWnd2, TME_HOVER|TME_LEAVE);
|
EXPECT_TME_FLAGS(hWnd2, TME_HOVER|TME_LEAVE);
|
||||||
COMPARE_CACHE(mousemove2_chain);
|
COMPARE_CACHE(mousemove2_chain);
|
||||||
|
|
||||||
FLUSH_MESSAGES(msg);
|
FlushMessages();
|
||||||
COMPARE_CACHE(empty_chain);
|
COMPARE_CACHE(empty_chain);
|
||||||
|
|
||||||
/* the mouse moves from hwnd2 to hwnd3 */
|
/* the mouse moves from hwnd2 to hwnd3 */
|
||||||
SetCursorPos(400,400);
|
SetCursorPos(400,400);
|
||||||
EXPECT_QUEUE_STATUS(QS_MOUSEMOVE, QS_TIMER);
|
EXPECT_QUEUE_STATUS(QS_MOUSEMOVE, QS_TIMER);
|
||||||
FLUSH_MESSAGES(msg);
|
FlushMessages();
|
||||||
EXPECT_TME_FLAGS(hWnd2, 0);
|
EXPECT_TME_FLAGS(hWnd2, 0);
|
||||||
COMPARE_CACHE(mouseleave2to3_chain);
|
COMPARE_CACHE(mouseleave2to3_chain);
|
||||||
|
|
||||||
FLUSH_MESSAGES(msg);
|
FlushMessages();
|
||||||
COMPARE_CACHE(empty_chain);
|
COMPARE_CACHE(empty_chain);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,9 @@
|
||||||
#include <wine/test.h>
|
#include <wine/test.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include "helper.h"
|
#include "helper.h"
|
||||||
|
#include <undocuser.h>
|
||||||
|
|
||||||
|
MSG_ENTRY last_post_message;
|
||||||
MSG_ENTRY message_cache[100];
|
MSG_ENTRY message_cache[100];
|
||||||
static int message_cache_size = 0;
|
static int message_cache_size = 0;
|
||||||
|
|
||||||
|
@ -38,6 +40,7 @@ static char* get_msg_name(UINT msg)
|
||||||
case WM_NCHITTEST: return "WM_NCHITTEST";
|
case WM_NCHITTEST: return "WM_NCHITTEST";
|
||||||
case WM_SETCURSOR: return "WM_SETCURSOR";
|
case WM_SETCURSOR: return "WM_SETCURSOR";
|
||||||
case WM_MOUSEMOVE: return "WM_MOUSEMOVE";
|
case WM_MOUSEMOVE: return "WM_MOUSEMOVE";
|
||||||
|
case WM_SYSTIMER: return "WM_SYSTIMER";
|
||||||
default: return NULL;
|
default: return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,6 +59,7 @@ static char* get_hook_name(UINT id)
|
||||||
|
|
||||||
void empty_message_cache()
|
void empty_message_cache()
|
||||||
{
|
{
|
||||||
|
memset(&last_post_message, 0, sizeof(last_post_message));
|
||||||
memset(message_cache, 0, sizeof(message_cache));
|
memset(message_cache, 0, sizeof(message_cache));
|
||||||
message_cache_size = 0;
|
message_cache_size = 0;
|
||||||
}
|
}
|
||||||
|
@ -68,8 +72,29 @@ void sprintf_msg_entry(char* buffer, MSG_ENTRY* msg)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char* msgName = msg->hook ? get_hook_name(msg->msg) : get_msg_name(msg->msg);
|
char* msgName;
|
||||||
char* msgType = msg->hook ? "hook" : "msg";
|
char* msgType;
|
||||||
|
|
||||||
|
switch (msg->type)
|
||||||
|
{
|
||||||
|
case POST:
|
||||||
|
msgName = get_msg_name(msg->msg);
|
||||||
|
msgType = "post msg";
|
||||||
|
break;
|
||||||
|
case SENT:
|
||||||
|
msgName = get_msg_name(msg->msg);
|
||||||
|
msgType = "sent msg";
|
||||||
|
break;
|
||||||
|
case HOOK:
|
||||||
|
msgName = get_hook_name(msg->msg);
|
||||||
|
msgType = "hook";
|
||||||
|
break;
|
||||||
|
case EVENT:
|
||||||
|
msgName = NULL;
|
||||||
|
msgType = "event";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if(msgName)
|
if(msgName)
|
||||||
sprintf(buffer, "hwnd%d %s %s %d %d", msg->iwnd, msgType, msgName, msg->param1, msg->param2);
|
sprintf(buffer, "hwnd%d %s %s %d %d", msg->iwnd, msgType, msgName, msg->param1, msg->param2);
|
||||||
else
|
else
|
||||||
|
@ -126,18 +151,39 @@ void compare_cache(const char* file, int line, MSG_ENTRY *msg_chain)
|
||||||
empty_message_cache();
|
empty_message_cache();
|
||||||
}
|
}
|
||||||
|
|
||||||
void record_message(int iwnd, UINT message, BOOL hook, int param1,int param2)
|
void record_message(int iwnd, UINT message, MSG_TYPE type, int param1,int param2)
|
||||||
{
|
{
|
||||||
if(message_cache_size>=100)
|
if(message_cache_size>=100)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* do not report a post message a second time */
|
||||||
|
if(type == SENT &&
|
||||||
|
last_post_message.iwnd == iwnd &&
|
||||||
|
last_post_message.msg == message &&
|
||||||
|
last_post_message.param1 == param1 &&
|
||||||
|
last_post_message.param2 == param2)
|
||||||
|
{
|
||||||
|
memset(&last_post_message, 0, sizeof(last_post_message));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
message_cache[message_cache_size].iwnd = iwnd;
|
message_cache[message_cache_size].iwnd = iwnd;
|
||||||
message_cache[message_cache_size].msg = message;
|
message_cache[message_cache_size].msg = message;
|
||||||
message_cache[message_cache_size].hook = hook;
|
message_cache[message_cache_size].type = type;
|
||||||
message_cache[message_cache_size].param1 = param1;
|
message_cache[message_cache_size].param1 = param1;
|
||||||
message_cache[message_cache_size].param2 = param2;
|
message_cache[message_cache_size].param2 = param2;
|
||||||
|
|
||||||
|
if(message_cache[message_cache_size].type == POST)
|
||||||
|
{
|
||||||
|
last_post_message = message_cache[message_cache_size];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
memset(&last_post_message, 0, sizeof(last_post_message));
|
||||||
|
}
|
||||||
|
|
||||||
message_cache_size++;
|
message_cache_size++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,24 +1,49 @@
|
||||||
|
|
||||||
|
typedef enum _MSG_TYPE
|
||||||
|
{
|
||||||
|
SENT,
|
||||||
|
POST,
|
||||||
|
HOOK,
|
||||||
|
EVENT
|
||||||
|
} MSG_TYPE;
|
||||||
|
|
||||||
typedef struct _MSG_ENTRY
|
typedef struct _MSG_ENTRY
|
||||||
{
|
{
|
||||||
int iwnd;
|
int iwnd;
|
||||||
UINT msg;
|
UINT msg;
|
||||||
BOOL hook;
|
MSG_TYPE type;
|
||||||
int param1;
|
int param1;
|
||||||
int param2;
|
int param2;
|
||||||
} MSG_ENTRY;
|
} MSG_ENTRY;
|
||||||
|
|
||||||
void record_message(int iwnd, UINT message, BOOL hook, int param1,int param2);
|
void record_message(int iwnd, UINT message, MSG_TYPE type, int param1,int param2);
|
||||||
void compare_cache(const char* file, int line, MSG_ENTRY *msg_chain);
|
void compare_cache(const char* file, int line, MSG_ENTRY *msg_chain);
|
||||||
void trace_cache(const char* file, int line);
|
void trace_cache(const char* file, int line);
|
||||||
void empty_message_cache();
|
void empty_message_cache();
|
||||||
ATOM RegisterSimpleClass(WNDPROC lpfnWndProc, LPCWSTR lpszClassName);
|
ATOM RegisterSimpleClass(WNDPROC lpfnWndProc, LPCWSTR lpszClassName);
|
||||||
|
|
||||||
|
/* filter messages that are affected by dwm */
|
||||||
|
static _inline BOOL IsDWmMsg(UINT msg)
|
||||||
|
{
|
||||||
|
switch(msg)
|
||||||
|
{
|
||||||
|
case WM_NCPAINT:
|
||||||
|
case WM_ERASEBKGND:
|
||||||
|
case WM_PAINT:
|
||||||
|
case 0x031f: /*WM_DWMNCRENDERINGCHANGED*/
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static _inline BOOL IseKeyMsg(UINT msg)
|
||||||
|
{
|
||||||
|
return (msg == WM_KEYUP || msg == WM_KEYDOWN);
|
||||||
|
}
|
||||||
|
|
||||||
#define COMPARE_CACHE(...) compare_cache(__FILE__, __LINE__, ##__VA_ARGS__)
|
#define COMPARE_CACHE(...) compare_cache(__FILE__, __LINE__, ##__VA_ARGS__)
|
||||||
#define TRACE_CACHE() trace_cache(__FILE__, __LINE__)
|
#define TRACE_CACHE() trace_cache(__FILE__, __LINE__)
|
||||||
|
|
||||||
#define FLUSH_MESSAGES(msg) while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg );
|
|
||||||
#define EXPECT_NEXT(hWnd1, hWnd2) ok(GetWindow(hWnd1,GW_HWNDNEXT) == hWnd2, "Expected %p after %p, not %p\n",hWnd2,hWnd1,GetWindow(hWnd1,GW_HWNDNEXT) )
|
#define EXPECT_NEXT(hWnd1, hWnd2) ok(GetWindow(hWnd1,GW_HWNDNEXT) == hWnd2, "Expected %p after %p, not %p\n",hWnd2,hWnd1,GetWindow(hWnd1,GW_HWNDNEXT) )
|
||||||
#define EXPECT_ACTIVE(hwnd) ok(GetActiveWindow() == hwnd, "Expected %p to be the active window, not %p\n",hwnd,GetActiveWindow())
|
#define EXPECT_ACTIVE(hwnd) ok(GetActiveWindow() == hwnd, "Expected %p to be the active window, not %p\n",hwnd,GetActiveWindow())
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue