mirror of
https://github.com/reactos/reactos.git
synced 2025-08-07 05:52:57 +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
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue