mirror of
https://github.com/reactos/reactos.git
synced 2025-01-03 21:09:19 +00:00
[user32_apitest.rbuild]
- Move shared code used to log window messages in helper.c - Implement logging hooks - Fix comparing the logged messages to show the correct line of the test - Add tests for hooks in TrackMouseEvent test svn path=/trunk/; revision=53812
This commit is contained in:
parent
34f9dc947a
commit
a947b9c6fc
7 changed files with 275 additions and 298 deletions
|
@ -4,6 +4,7 @@ add_definitions(-D_DLL -D__USE_CRTIMP)
|
|||
set_rc_compiler()
|
||||
|
||||
list(APPEND SOURCE
|
||||
helper.c
|
||||
DeferWindowPos.c
|
||||
GetIconInfo.c
|
||||
GetKeyState.c
|
||||
|
|
|
@ -8,104 +8,18 @@
|
|||
#include <stdio.h>
|
||||
#include <wine/test.h>
|
||||
#include <windows.h>
|
||||
|
||||
typedef struct _MSG_ENTRY
|
||||
{
|
||||
int iwnd;
|
||||
UINT msg;
|
||||
} MSG_ENTRY;
|
||||
#include "helper.h"
|
||||
|
||||
MSG_ENTRY message_cache[100];
|
||||
int message_cache_size = 0;
|
||||
|
||||
HWND hWnd1, hWnd2, hWnd3, hWnd4;
|
||||
|
||||
/* helper functions */
|
||||
|
||||
static char* get_msg_name(UINT msg)
|
||||
static int get_iwnd(HWND hWnd)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case WM_NCACTIVATE: return "WM_NCACTIVATE";
|
||||
case WM_ACTIVATE: return "WM_ACTIVATE";
|
||||
case WM_ACTIVATEAPP: return "WM_ACTIVATEAPP";
|
||||
case WM_WINDOWPOSCHANGING: return "WM_WINDOWPOSCHANGING";
|
||||
case WM_WINDOWPOSCHANGED: return "WM_WINDOWPOSCHANGED";
|
||||
case WM_SETFOCUS: return "WM_SETFOCUS";
|
||||
case WM_KILLFOCUS: return "WM_KILLFOCUS";
|
||||
case WM_NCPAINT: return "WM_NCPAINT";
|
||||
case WM_PAINT: return "WM_PAINT";
|
||||
case WM_ERASEBKGND: return "WM_ERASEBKGND";
|
||||
case WM_SIZE: return "WM_SIZE";
|
||||
case WM_MOVE: return "WM_MOVE";
|
||||
case WM_SHOWWINDOW: return "WM_SHOWWINDOW";
|
||||
case WM_QUERYNEWPALETTE: return "WM_QUERYNEWPALETTE";
|
||||
default: return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void empty_message_cache()
|
||||
{
|
||||
memset(message_cache, 0, sizeof(message_cache));
|
||||
message_cache_size = 0;
|
||||
}
|
||||
|
||||
void trace_cache()
|
||||
{
|
||||
int i;
|
||||
char *szMsgName;
|
||||
|
||||
for (i=0; i < message_cache_size; i++)
|
||||
{
|
||||
if((szMsgName = get_msg_name(message_cache[i].msg)))
|
||||
{
|
||||
trace("hwnd%d, msg:%s\n",message_cache[i].iwnd, szMsgName );
|
||||
}
|
||||
else
|
||||
{
|
||||
trace("hwnd%d, msg:%d\n",message_cache[i].iwnd, message_cache[i].msg );
|
||||
}
|
||||
}
|
||||
trace("\n");
|
||||
}
|
||||
|
||||
void compare_cache(char* testname, MSG_ENTRY *msg_chain)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
while(1)
|
||||
{
|
||||
char *szMsgExpected, *szMsgGot;
|
||||
szMsgExpected = get_msg_name(msg_chain->msg);
|
||||
szMsgGot = get_msg_name(message_cache[i].msg);
|
||||
if(szMsgExpected && szMsgGot)
|
||||
{
|
||||
ok(message_cache[i].iwnd == msg_chain->iwnd &&
|
||||
message_cache[i].msg == msg_chain->msg,
|
||||
"%s, message %d: expected %s to hwnd%d and got %s to hwnd%d\n",
|
||||
testname,i, szMsgExpected, msg_chain->iwnd, szMsgGot, message_cache[i].iwnd);
|
||||
}
|
||||
else
|
||||
{
|
||||
ok(message_cache[i].iwnd == msg_chain->iwnd &&
|
||||
message_cache[i].msg == msg_chain->msg,
|
||||
"%s, message %d: expected msg %d to hwnd%d and got msg %d to hwnd%d\n",
|
||||
testname,i, msg_chain->msg, msg_chain->iwnd, message_cache[i].msg, message_cache[i].iwnd);
|
||||
}
|
||||
|
||||
if(msg_chain->msg !=0 && msg_chain->iwnd != 0)
|
||||
{
|
||||
msg_chain++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(i>message_cache_size)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if(hWnd == hWnd1) return 1;
|
||||
else if(hWnd == hWnd2) return 2;
|
||||
else if(hWnd == hWnd3) return 3;
|
||||
else if(hWnd == hWnd4) return 4;
|
||||
else return 0;
|
||||
}
|
||||
|
||||
LRESULT CALLBACK OwnerTestProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
|
@ -121,20 +35,10 @@ LRESULT CALLBACK OwnerTestProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lP
|
|||
message != WM_PAINT &&
|
||||
message != 0x031f /*WM_DWMNCRENDERINGCHANGED*/)
|
||||
{
|
||||
if (message_cache_size<100)
|
||||
{
|
||||
int iwnd;
|
||||
if(hWnd == hWnd1) iwnd = 1;
|
||||
else if(hWnd == hWnd2) iwnd = 2;
|
||||
else if(hWnd == hWnd3) iwnd = 3;
|
||||
else if(hWnd == hWnd4) iwnd = 4;
|
||||
else
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
|
||||
message_cache[message_cache_size].iwnd = iwnd;
|
||||
message_cache[message_cache_size].msg = message;
|
||||
message_cache_size++;
|
||||
}
|
||||
int iwnd;
|
||||
iwnd = get_iwnd(hWnd);
|
||||
if(iwnd)
|
||||
record_message(iwnd, message, FALSE, 0,0);
|
||||
}
|
||||
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
|
@ -142,23 +46,7 @@ LRESULT CALLBACK OwnerTestProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lP
|
|||
|
||||
static void create_test_windows()
|
||||
{
|
||||
WNDCLASSEXW wcex;
|
||||
|
||||
wcex.cbSize = sizeof(WNDCLASSEX);
|
||||
wcex.style = 0;
|
||||
wcex.lpfnWndProc = OwnerTestProc;
|
||||
wcex.cbClsExtra = 0;
|
||||
wcex.cbWndExtra = 0;
|
||||
wcex.hInstance = 0;
|
||||
wcex.hIcon = 0;
|
||||
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
|
||||
wcex.lpszMenuName = 0;
|
||||
wcex.lpszClassName = L"ownertest";
|
||||
wcex.hIconSm = 0;
|
||||
|
||||
RegisterClassExW(&wcex);
|
||||
|
||||
RegisterSimpleClass(OwnerTestProc, L"ownertest");
|
||||
hWnd1 = CreateWindowW(L"ownertest", L"ownertest", WS_OVERLAPPEDWINDOW,
|
||||
20, 20, 300, 300, NULL, NULL, 0, NULL);
|
||||
|
||||
|
@ -222,15 +110,12 @@ MSG_ENTRY Activate4_chain[]={{2,WM_NCACTIVATE},
|
|||
{1,WM_SETFOCUS},
|
||||
{0,0}};
|
||||
|
||||
#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 FLUSH_MESSAGES(msg) while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg );
|
||||
|
||||
|
||||
void Test_SetActiveWindow()
|
||||
{
|
||||
MSG msg;
|
||||
|
||||
SetCursorPos(0,0);
|
||||
|
||||
create_test_windows();
|
||||
|
||||
ShowWindow(hWnd1, SW_SHOW);
|
||||
|
@ -268,9 +153,7 @@ void Test_SetActiveWindow()
|
|||
EXPECT_NEXT(hWnd2,hWnd1);
|
||||
EXPECT_NEXT(hWnd1,hWnd3);
|
||||
EXPECT_ACTIVE(hWnd1);
|
||||
compare_cache("Activate1", Activate1_chain);
|
||||
trace_cache();
|
||||
empty_message_cache();
|
||||
COMPARE_CACHE(Activate1_chain);
|
||||
|
||||
SetActiveWindow(hWnd3);
|
||||
FLUSH_MESSAGES(msg);
|
||||
|
@ -278,9 +161,7 @@ void Test_SetActiveWindow()
|
|||
EXPECT_NEXT(hWnd4,hWnd2);
|
||||
EXPECT_NEXT(hWnd2,hWnd1);
|
||||
EXPECT_ACTIVE(hWnd3);
|
||||
compare_cache("Activate2", Activate2_chain);
|
||||
trace_cache();
|
||||
empty_message_cache();
|
||||
COMPARE_CACHE(Activate2_chain);
|
||||
|
||||
SetActiveWindow(hWnd2);
|
||||
FLUSH_MESSAGES(msg);
|
||||
|
@ -288,9 +169,7 @@ void Test_SetActiveWindow()
|
|||
EXPECT_NEXT(hWnd4,hWnd1);
|
||||
EXPECT_NEXT(hWnd1,hWnd3);
|
||||
EXPECT_ACTIVE(hWnd2);
|
||||
compare_cache("Activate3", Activate3_chain);
|
||||
trace_cache();
|
||||
empty_message_cache();
|
||||
COMPARE_CACHE(Activate3_chain);
|
||||
|
||||
SetActiveWindow(hWnd1);
|
||||
FLUSH_MESSAGES(msg);
|
||||
|
@ -298,9 +177,7 @@ void Test_SetActiveWindow()
|
|||
EXPECT_NEXT(hWnd4,hWnd1);
|
||||
EXPECT_NEXT(hWnd1,hWnd3);
|
||||
EXPECT_ACTIVE(hWnd1);
|
||||
compare_cache("Activate4", Activate4_chain);
|
||||
trace_cache();
|
||||
empty_message_cache();
|
||||
COMPARE_CACHE(Activate4_chain);
|
||||
}
|
||||
|
||||
START_TEST(SetActiveWindow)
|
||||
|
|
|
@ -20,7 +20,7 @@ struct _test_info
|
|||
};
|
||||
|
||||
struct _test_info info[] = { {0,0,0}, /* SetCursorPos without a window */
|
||||
{1,2,0}, /* mouse_event without a window */
|
||||
{1,1,0}, /* mouse_event without a window */
|
||||
{0,1,1}, /* SetCursorPos with a window */
|
||||
{1,1,1}, /* mouse_event with a window */
|
||||
{0,1,1}, /* multiple SetCursorPos with a window with coalescing */
|
||||
|
@ -97,7 +97,7 @@ void Test_SetCursorPos()
|
|||
memset(results, sizeof(results), 0);
|
||||
|
||||
hMouseHookLL = SetWindowsHookEx(WH_MOUSE_LL, MouseLLHookProc, GetModuleHandleA( NULL ), 0);
|
||||
hMouseHook = SetWindowsHookEx(WH_MOUSE, MouseHookProc, GetModuleHandleA( 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");
|
||||
|
||||
|
|
|
@ -8,121 +8,17 @@
|
|||
#include <stdio.h>
|
||||
#include <wine/test.h>
|
||||
#include <windows.h>
|
||||
|
||||
typedef struct _MSG_ENTRY
|
||||
{
|
||||
int iwnd;
|
||||
UINT msg;
|
||||
} MSG_ENTRY;
|
||||
|
||||
MSG_ENTRY message_cache[100];
|
||||
static int message_cache_size = 0;
|
||||
#include "helper.h"
|
||||
|
||||
HWND hWnd1, hWnd2, hWnd3;
|
||||
HHOOK hMouseHookLL, hMouseHook;
|
||||
|
||||
/* helper functions */
|
||||
|
||||
static char* get_msg_name(UINT msg)
|
||||
static int get_iwnd(HWND hWnd)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case WM_NCACTIVATE: return "WM_NCACTIVATE";
|
||||
case WM_ACTIVATE: return "WM_ACTIVATE";
|
||||
case WM_ACTIVATEAPP: return "WM_ACTIVATEAPP";
|
||||
case WM_WINDOWPOSCHANGING: return "WM_WINDOWPOSCHANGING";
|
||||
case WM_WINDOWPOSCHANGED: return "WM_WINDOWPOSCHANGED";
|
||||
case WM_SETFOCUS: return "WM_SETFOCUS";
|
||||
case WM_KILLFOCUS: return "WM_KILLFOCUS";
|
||||
case WM_NCPAINT: return "WM_NCPAINT";
|
||||
case WM_PAINT: return "WM_PAINT";
|
||||
case WM_ERASEBKGND: return "WM_ERASEBKGND";
|
||||
case WM_SIZE: return "WM_SIZE";
|
||||
case WM_MOVE: return "WM_MOVE";
|
||||
case WM_SHOWWINDOW: return "WM_SHOWWINDOW";
|
||||
case WM_QUERYNEWPALETTE: return "WM_QUERYNEWPALETTE";
|
||||
case WM_MOUSELEAVE: return "WM_MOUSELEAVE";
|
||||
case WM_MOUSEHOVER: return "WM_MOUSEHOVER";
|
||||
case WM_NCMOUSELEAVE: return "WM_NCMOUSELEAVE";
|
||||
case WM_NCMOUSEHOVER: return "WM_NCMOUSEHOVER";
|
||||
case WM_NCHITTEST: return "WM_NCHITTEST";
|
||||
case WM_SETCURSOR: return "WM_SETCURSOR";
|
||||
case WM_MOUSEMOVE: return "WM_MOUSEMOVE";
|
||||
default: return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void empty_message_cache()
|
||||
{
|
||||
memset(message_cache, 0, sizeof(message_cache));
|
||||
message_cache_size = 0;
|
||||
}
|
||||
#if 0
|
||||
static void trace_cache()
|
||||
{
|
||||
int i;
|
||||
char *szMsgName;
|
||||
|
||||
for (i=0; i < message_cache_size; i++)
|
||||
{
|
||||
if((szMsgName = get_msg_name(message_cache[i].msg)))
|
||||
{
|
||||
trace("hwnd%d, msg:%s\n",message_cache[i].iwnd, szMsgName );
|
||||
}
|
||||
else
|
||||
{
|
||||
trace("hwnd%d, msg:%d\n",message_cache[i].iwnd, message_cache[i].msg );
|
||||
}
|
||||
}
|
||||
trace("\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
static void compare_cache(char* testname, MSG_ENTRY *msg_chain)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
while(1)
|
||||
{
|
||||
char *szMsgExpected, *szMsgGot;
|
||||
szMsgExpected = get_msg_name(msg_chain->msg);
|
||||
szMsgGot = get_msg_name(message_cache[i].msg);
|
||||
if(szMsgExpected && szMsgGot)
|
||||
{
|
||||
ok(message_cache[i].iwnd == msg_chain->iwnd &&
|
||||
message_cache[i].msg == msg_chain->msg,
|
||||
"%s, message %d: expected %s to hwnd%d and got %s to hwnd%d\n",
|
||||
testname,i, szMsgExpected, msg_chain->iwnd, szMsgGot, message_cache[i].iwnd);
|
||||
}
|
||||
else
|
||||
{
|
||||
ok(message_cache[i].iwnd == msg_chain->iwnd &&
|
||||
message_cache[i].msg == msg_chain->msg,
|
||||
"%s, message %d: expected msg %d to hwnd%d and got msg %d to hwnd%d\n",
|
||||
testname,i, msg_chain->msg, msg_chain->iwnd, message_cache[i].msg, message_cache[i].iwnd);
|
||||
}
|
||||
|
||||
if(msg_chain->msg !=0 && msg_chain->iwnd != 0)
|
||||
{
|
||||
msg_chain++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(i>message_cache_size)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
empty_message_cache();
|
||||
}
|
||||
|
||||
static void record_message(int iwnd, UINT message)
|
||||
{
|
||||
message_cache[message_cache_size].iwnd = iwnd;
|
||||
message_cache[message_cache_size].msg = message;
|
||||
message_cache_size++;
|
||||
if(hWnd == hWnd1) return 1;
|
||||
else if(hWnd == hWnd2) return 2;
|
||||
else if(hWnd == hWnd3) return 3;
|
||||
else return 0;
|
||||
}
|
||||
|
||||
LRESULT CALLBACK TmeTestProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
|
@ -138,17 +34,9 @@ LRESULT CALLBACK TmeTestProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPar
|
|||
message != WM_PAINT &&
|
||||
message != 0x031f /*WM_DWMNCRENDERINGCHANGED*/)
|
||||
{
|
||||
if (message_cache_size<100)
|
||||
{
|
||||
int iwnd;
|
||||
if(hWnd == hWnd1) iwnd = 1;
|
||||
else if(hWnd == hWnd2) iwnd = 2;
|
||||
else if(hWnd == hWnd3) iwnd = 3;
|
||||
else
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
|
||||
record_message(iwnd, message);
|
||||
}
|
||||
int iwnd = get_iwnd(hWnd);
|
||||
if(iwnd)
|
||||
record_message(iwnd, message, FALSE,0,0);
|
||||
}
|
||||
|
||||
if(message == WM_PAINT)
|
||||
|
@ -158,27 +46,33 @@ 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);
|
||||
EndPaint(hWnd, &ps);
|
||||
}
|
||||
|
||||
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
}
|
||||
|
||||
static LRESULT CALLBACK MouseLLHookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
record_message(0, WH_MOUSE_LL, TRUE, wParam, 0);
|
||||
return CallNextHookEx(hMouseHookLL, nCode, wParam, lParam);
|
||||
}
|
||||
|
||||
static LRESULT CALLBACK MouseHookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
MOUSEHOOKSTRUCT *hs = (MOUSEHOOKSTRUCT*) lParam;
|
||||
record_message(get_iwnd(hs->hwnd), WH_MOUSE, TRUE, wParam, hs->wHitTestCode);
|
||||
return CallNextHookEx(hMouseHook, nCode, wParam, lParam);
|
||||
}
|
||||
|
||||
static void create_test_windows()
|
||||
{
|
||||
WNDCLASSEXW wcex;
|
||||
|
||||
wcex.cbSize = sizeof(WNDCLASSEX);
|
||||
wcex.style = 0;
|
||||
wcex.lpfnWndProc = TmeTestProc;
|
||||
wcex.cbClsExtra = 0;
|
||||
wcex.cbWndExtra = 0;
|
||||
wcex.hInstance = 0;
|
||||
wcex.hIcon = 0;
|
||||
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
|
||||
wcex.lpszMenuName = 0;
|
||||
wcex.lpszClassName = L"testClass";
|
||||
wcex.hIconSm = 0;
|
||||
|
||||
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");
|
||||
RegisterClassExW(&wcex);
|
||||
|
||||
hWnd1 = CreateWindowW(L"testClass", L"test", WS_OVERLAPPEDWINDOW,
|
||||
|
@ -238,6 +132,7 @@ MSG_ENTRY empty_chain[]= {{0,0}};
|
|||
|
||||
/* the mouse moves over hwnd2 */
|
||||
MSG_ENTRY mousemove2_chain[]={{2, WM_NCHITTEST},
|
||||
{2, WH_MOUSE,1, WM_MOUSEMOVE, HTCLIENT},
|
||||
{2, WM_SETCURSOR},
|
||||
{1, WM_SETCURSOR},
|
||||
{2, WM_MOUSEMOVE},
|
||||
|
@ -245,6 +140,7 @@ MSG_ENTRY mousemove2_chain[]={{2, WM_NCHITTEST},
|
|||
|
||||
/* the mouse hovers hwnd2 */
|
||||
MSG_ENTRY mousehover2_chain[]={{2, WM_NCHITTEST},
|
||||
{2, WH_MOUSE,1, WM_MOUSEMOVE, HTCLIENT},
|
||||
{2, WM_SETCURSOR},
|
||||
{1, WM_SETCURSOR},
|
||||
{2, WM_MOUSEMOVE},
|
||||
|
@ -253,6 +149,7 @@ MSG_ENTRY mousehover2_chain[]={{2, WM_NCHITTEST},
|
|||
|
||||
/* the mouse leaves hwnd2 and moves to hwnd1 */
|
||||
MSG_ENTRY mouseleave2to1_chain[]={{1, WM_NCHITTEST},
|
||||
{1, WH_MOUSE,1, WM_MOUSEMOVE, HTCLIENT},
|
||||
{1, WM_SETCURSOR},
|
||||
{1, WM_MOUSEMOVE},
|
||||
{2, WM_MOUSELEAVE},
|
||||
|
@ -260,6 +157,7 @@ MSG_ENTRY mouseleave2to1_chain[]={{1, WM_NCHITTEST},
|
|||
|
||||
/* the mouse leaves hwnd2 and moves to hwnd3 */
|
||||
MSG_ENTRY mouseleave2to3_chain[]={{3, WM_NCHITTEST},
|
||||
{3, WH_MOUSE,1, WM_MOUSEMOVE, HTCLIENT},
|
||||
{3, WM_SETCURSOR},
|
||||
{1, WM_SETCURSOR},
|
||||
{3, WM_MOUSEMOVE},
|
||||
|
@ -278,71 +176,71 @@ void Test_TrackMouseEvent()
|
|||
/* the mouse moves over hwnd2 */
|
||||
SetCursorPos(220,220);
|
||||
FLUSH_MESSAGES(msg);
|
||||
compare_cache("mousemove2", mousemove2_chain);
|
||||
COMPARE_CACHE(mousemove2_chain);
|
||||
EXPECT_TME_FLAGS(hWnd2, 0);
|
||||
TmeStartTracking(hWnd2, TME_HOVER|TME_LEAVE);
|
||||
EXPECT_TME_FLAGS(hWnd2, TME_HOVER|TME_LEAVE);
|
||||
FLUSH_MESSAGES(msg);
|
||||
compare_cache("empty1", empty_chain);
|
||||
COMPARE_CACHE(empty_chain);
|
||||
|
||||
/* the mouse hovers hwnd2 */
|
||||
SetCursorPos(221,221);
|
||||
Sleep(100);
|
||||
EXPECT_QUEUE_STATUS(QS_TIMER|QS_MOUSEMOVE, QS_POSTMESSAGE);
|
||||
EXPECT_QUEUE_STATUS(QS_TIMER|QS_MOUSEMOVE, 0);
|
||||
EXPECT_TME_FLAGS(hWnd2, TME_HOVER|TME_LEAVE);
|
||||
FLUSH_MESSAGES(msg);
|
||||
EXPECT_TME_FLAGS(hWnd2, TME_LEAVE);
|
||||
compare_cache("mousehover2", mousehover2_chain);
|
||||
COMPARE_CACHE(mousehover2_chain);
|
||||
|
||||
/* the mouse leaves hwnd2 and moves to hwnd1 */
|
||||
SetCursorPos(150,150);
|
||||
EXPECT_QUEUE_STATUS(QS_MOUSEMOVE,QS_TIMER|QS_POSTMESSAGE );
|
||||
EXPECT_QUEUE_STATUS(QS_MOUSEMOVE,QS_TIMER );
|
||||
EXPECT_TME_FLAGS(hWnd2, TME_LEAVE);
|
||||
FLUSH_MESSAGES(msg);
|
||||
EXPECT_TME_FLAGS(hWnd2, 0);
|
||||
compare_cache("mouseleave2to1", mouseleave2to1_chain);
|
||||
COMPARE_CACHE(mouseleave2to1_chain);
|
||||
|
||||
FLUSH_MESSAGES(msg);
|
||||
compare_cache("empty2", empty_chain);
|
||||
COMPARE_CACHE(empty_chain);
|
||||
|
||||
/* the mouse moves over hwnd2 */
|
||||
SetCursorPos(220,220);
|
||||
EXPECT_QUEUE_STATUS(QS_MOUSEMOVE, QS_TIMER|QS_POSTMESSAGE);
|
||||
EXPECT_QUEUE_STATUS(QS_MOUSEMOVE, QS_TIMER);
|
||||
FLUSH_MESSAGES(msg);
|
||||
compare_cache("mousemove2", mousemove2_chain);
|
||||
COMPARE_CACHE(mousemove2_chain);
|
||||
EXPECT_TME_FLAGS(hWnd2, 0);
|
||||
compare_cache("empty3", empty_chain);
|
||||
COMPARE_CACHE(empty_chain);
|
||||
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|QS_POSTMESSAGE);
|
||||
EXPECT_QUEUE_STATUS(0, QS_TIMER|QS_MOUSEMOVE);
|
||||
FLUSH_MESSAGES(msg);
|
||||
compare_cache("empty4", empty_chain);
|
||||
COMPARE_CACHE(empty_chain);
|
||||
EXPECT_TME_FLAGS(hWnd2, TME_HOVER|TME_LEAVE);
|
||||
|
||||
FLUSH_MESSAGES(msg);
|
||||
compare_cache("empty5", empty_chain);
|
||||
COMPARE_CACHE(empty_chain);
|
||||
|
||||
/* the mouse moves from hwnd2 to the intersection of hwnd2 and hwnd3 */
|
||||
SetCursorPos(300,300);
|
||||
EXPECT_QUEUE_STATUS(QS_MOUSEMOVE, QS_TIMER|QS_POSTMESSAGE);
|
||||
EXPECT_QUEUE_STATUS(QS_MOUSEMOVE, QS_TIMER);
|
||||
FLUSH_MESSAGES(msg);
|
||||
EXPECT_TME_FLAGS(hWnd2, TME_HOVER|TME_LEAVE);
|
||||
compare_cache("mousemove2", mousemove2_chain);
|
||||
COMPARE_CACHE(mousemove2_chain);
|
||||
|
||||
FLUSH_MESSAGES(msg);
|
||||
compare_cache("empty6", empty_chain);
|
||||
COMPARE_CACHE(empty_chain);
|
||||
|
||||
/* the mouse moves from hwnd2 to hwnd3 */
|
||||
SetCursorPos(400,400);
|
||||
EXPECT_QUEUE_STATUS(QS_MOUSEMOVE, QS_TIMER|QS_POSTMESSAGE);
|
||||
EXPECT_QUEUE_STATUS(QS_MOUSEMOVE, QS_TIMER);
|
||||
FLUSH_MESSAGES(msg);
|
||||
EXPECT_TME_FLAGS(hWnd2, 0);
|
||||
compare_cache("mousemove2to3", mouseleave2to3_chain);
|
||||
COMPARE_CACHE(mouseleave2to3_chain);
|
||||
|
||||
FLUSH_MESSAGES(msg);
|
||||
compare_cache("empty7", empty_chain);
|
||||
COMPARE_CACHE(empty_chain);
|
||||
}
|
||||
|
||||
START_TEST(TrackMouseEvent)
|
||||
|
|
169
rostests/apitests/user32/helper.c
Normal file
169
rostests/apitests/user32/helper.c
Normal file
|
@ -0,0 +1,169 @@
|
|||
/*
|
||||
* PROJECT: ReactOS api tests
|
||||
* LICENSE: GPL - See COPYING in the top level directory
|
||||
* PURPOSE: helper functions
|
||||
* PROGRAMMERS: Giannis Adamopoulos
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <wine/test.h>
|
||||
#include <windows.h>
|
||||
#include "helper.h"
|
||||
|
||||
MSG_ENTRY message_cache[100];
|
||||
static int message_cache_size = 0;
|
||||
|
||||
static char* get_msg_name(UINT msg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case WM_NCACTIVATE: return "WM_NCACTIVATE";
|
||||
case WM_ACTIVATE: return "WM_ACTIVATE";
|
||||
case WM_ACTIVATEAPP: return "WM_ACTIVATEAPP";
|
||||
case WM_WINDOWPOSCHANGING: return "WM_WINDOWPOSCHANGING";
|
||||
case WM_WINDOWPOSCHANGED: return "WM_WINDOWPOSCHANGED";
|
||||
case WM_SETFOCUS: return "WM_SETFOCUS";
|
||||
case WM_KILLFOCUS: return "WM_KILLFOCUS";
|
||||
case WM_NCPAINT: return "WM_NCPAINT";
|
||||
case WM_PAINT: return "WM_PAINT";
|
||||
case WM_ERASEBKGND: return "WM_ERASEBKGND";
|
||||
case WM_SIZE: return "WM_SIZE";
|
||||
case WM_MOVE: return "WM_MOVE";
|
||||
case WM_SHOWWINDOW: return "WM_SHOWWINDOW";
|
||||
case WM_QUERYNEWPALETTE: return "WM_QUERYNEWPALETTE";
|
||||
case WM_MOUSELEAVE: return "WM_MOUSELEAVE";
|
||||
case WM_MOUSEHOVER: return "WM_MOUSEHOVER";
|
||||
case WM_NCMOUSELEAVE: return "WM_NCMOUSELEAVE";
|
||||
case WM_NCMOUSEHOVER: return "WM_NCMOUSEHOVER";
|
||||
case WM_NCHITTEST: return "WM_NCHITTEST";
|
||||
case WM_SETCURSOR: return "WM_SETCURSOR";
|
||||
case WM_MOUSEMOVE: return "WM_MOUSEMOVE";
|
||||
default: return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void empty_message_cache()
|
||||
{
|
||||
memset(message_cache, 0, sizeof(message_cache));
|
||||
message_cache_size = 0;
|
||||
}
|
||||
|
||||
void trace_cache(const char* file, int line)
|
||||
{
|
||||
int i;
|
||||
char *szMsgName;
|
||||
|
||||
for (i=0; i < message_cache_size; i++)
|
||||
{
|
||||
if(!message_cache[i].hook)
|
||||
{
|
||||
if((szMsgName = get_msg_name(message_cache[i].msg)))
|
||||
{
|
||||
trace_(file,line)("hwnd%d, msg:%s\n",message_cache[i].iwnd, szMsgName );
|
||||
}
|
||||
else
|
||||
{
|
||||
trace_(file,line)("hwnd%d, msg:%d\n",message_cache[i].iwnd, message_cache[i].msg );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
trace_(file,line)("hwnd%d, hook:%d, param1:%d, param2:%d\n",message_cache[i].iwnd,
|
||||
message_cache[i].msg,
|
||||
message_cache[i].param1,
|
||||
message_cache[i].param2);
|
||||
}
|
||||
}
|
||||
trace("\n");
|
||||
}
|
||||
|
||||
void compare_cache(const char* file, int line, MSG_ENTRY *msg_chain)
|
||||
{
|
||||
int i = 0;
|
||||
BOOL got_error = FALSE;
|
||||
|
||||
while(1)
|
||||
{
|
||||
char *szMsgExpected, *szMsgGot;
|
||||
BOOL same = !memcmp(&message_cache[i],msg_chain, sizeof(MSG_ENTRY));
|
||||
|
||||
szMsgExpected = get_msg_name(msg_chain->msg);
|
||||
szMsgGot = get_msg_name(message_cache[i].msg);
|
||||
if(!msg_chain->hook)
|
||||
{
|
||||
if(szMsgExpected && szMsgGot)
|
||||
{
|
||||
ok_(file,line)(same,
|
||||
"message %d: expected %s to hwnd%d and got %s to hwnd%d\n",
|
||||
i, szMsgExpected, msg_chain->iwnd, szMsgGot, message_cache[i].iwnd);
|
||||
}
|
||||
else
|
||||
{
|
||||
ok_(file,line)(same,
|
||||
"message %d: expected msg %d to hwnd%d and got msg %d to hwnd%d\n",
|
||||
i, msg_chain->msg, msg_chain->iwnd, message_cache[i].msg, message_cache[i].iwnd);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ok_(file,line)(same,
|
||||
"message %d: expected hook %d, hwnd%d, param1 %d, param2 %d and got hook %d, hwnd%d, param1 %d, param2 %d\n",
|
||||
i, msg_chain->msg, msg_chain->iwnd,msg_chain->param1, msg_chain->param2,
|
||||
message_cache[i].msg, message_cache[i].iwnd, message_cache[i].param1, message_cache[i].param2);
|
||||
}
|
||||
|
||||
if(!got_error && !same)
|
||||
{
|
||||
got_error = TRUE;
|
||||
}
|
||||
|
||||
if(msg_chain->msg !=0 && msg_chain->iwnd != 0)
|
||||
{
|
||||
msg_chain++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(i>message_cache_size)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
if(got_error )
|
||||
{
|
||||
trace_(file,line)("The complete list of messages got is:\n");
|
||||
trace_cache(file,line);
|
||||
}
|
||||
|
||||
empty_message_cache();
|
||||
}
|
||||
|
||||
void record_message(int iwnd, UINT message, BOOL hook, int param1,int param2)
|
||||
{
|
||||
if(message_cache_size>=100)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
message_cache[message_cache_size].iwnd = iwnd;
|
||||
message_cache[message_cache_size].msg = message;
|
||||
message_cache[message_cache_size].hook = hook;
|
||||
message_cache[message_cache_size].param1 = param1;
|
||||
message_cache[message_cache_size].param2 = param2;
|
||||
message_cache_size++;
|
||||
}
|
||||
|
||||
ATOM RegisterSimpleClass(WNDPROC lpfnWndProc, LPCWSTR lpszClassName)
|
||||
{
|
||||
WNDCLASSEXW wcex;
|
||||
|
||||
memset(&wcex, 0, sizeof(wcex));
|
||||
wcex.cbSize = sizeof(WNDCLASSEX);
|
||||
wcex.lpfnWndProc = lpfnWndProc;
|
||||
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
|
||||
wcex.lpszClassName = lpszClassName;
|
||||
return RegisterClassExW(&wcex);
|
||||
}
|
31
rostests/apitests/user32/helper.h
Normal file
31
rostests/apitests/user32/helper.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
|
||||
|
||||
typedef struct _MSG_ENTRY
|
||||
{
|
||||
int iwnd;
|
||||
UINT msg;
|
||||
BOOL hook;
|
||||
int param1;
|
||||
int param2;
|
||||
} MSG_ENTRY;
|
||||
|
||||
void record_message(int iwnd, UINT message, BOOL hook, int param1,int param2);
|
||||
void compare_cache(const char* file, int line, MSG_ENTRY *msg_chain);
|
||||
void trace_cache(const char* file, int line);
|
||||
void empty_message_cache();
|
||||
ATOM RegisterSimpleClass(WNDPROC lpfnWndProc, LPCWSTR lpszClassName);
|
||||
|
||||
#define COMPARE_CACHE(...) compare_cache(__FILE__, __LINE__, ##__VA_ARGS__)
|
||||
#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_ACTIVE(hwnd) ok(GetActiveWindow() == hwnd, "Expected %p to be the active window, not %p\n",hwnd,GetActiveWindow())
|
||||
|
||||
#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)); \
|
||||
}
|
|
@ -10,6 +10,7 @@
|
|||
<file>testlist.c</file>
|
||||
<file>user32_apitest.rc</file>
|
||||
|
||||
<file>helper.c</file>
|
||||
<file>GetKeyState.c</file>
|
||||
<file>InitializeLpkHooks.c</file>
|
||||
<file>RealGetWindowClass.c</file>
|
||||
|
|
Loading…
Reference in a new issue