mirror of
https://github.com/reactos/reactos.git
synced 2025-06-07 18:30:37 +00:00
[user32_apitest]
- Simplify compare_cache and make it show more meaningful results svn path=/trunk/; revision=53813
This commit is contained in:
parent
a947b9c6fc
commit
d55b76ab43
1 changed files with 37 additions and 50 deletions
|
@ -42,92 +42,79 @@ static char* get_msg_name(UINT msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char* get_hook_name(UINT id)
|
||||||
|
{
|
||||||
|
switch (id)
|
||||||
|
{
|
||||||
|
case WH_KEYBOARD: return "WH_KEYBOARD";
|
||||||
|
case WH_KEYBOARD_LL: return "WH_KEYBOARD_LL";
|
||||||
|
case WH_MOUSE: return "WH_MOUSE";
|
||||||
|
case WH_MOUSE_LL: return "WH_MOUSE_LL";
|
||||||
|
default: return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void empty_message_cache()
|
void empty_message_cache()
|
||||||
{
|
{
|
||||||
memset(message_cache, 0, sizeof(message_cache));
|
memset(message_cache, 0, sizeof(message_cache));
|
||||||
message_cache_size = 0;
|
message_cache_size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sprintf_msg_entry(char* buffer, MSG_ENTRY* msg)
|
||||||
|
{
|
||||||
|
if(!msg->iwnd && !msg->msg)
|
||||||
|
{
|
||||||
|
sprintf(buffer, "nothing");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
char* msgName = msg->hook ? get_hook_name(msg->msg) : get_msg_name(msg->msg);
|
||||||
|
char* msgType = msg->hook ? "hook" : "msg";
|
||||||
|
if(msgName)
|
||||||
|
sprintf(buffer, "hwnd%d %s %s %d %d", msg->iwnd, msgType, msgName, msg->param1, msg->param2);
|
||||||
|
else
|
||||||
|
sprintf(buffer, "hwnd%d %s %d %d %d", msg->iwnd, msgType, msg->msg, msg->param1, msg->param2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void trace_cache(const char* file, int line)
|
void trace_cache(const char* file, int line)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
char buff[100];
|
||||||
char *szMsgName;
|
char *szMsgName;
|
||||||
|
|
||||||
for (i=0; i < message_cache_size; i++)
|
for (i=0; i < message_cache_size; i++)
|
||||||
{
|
{
|
||||||
if(!message_cache[i].hook)
|
sprintf_msg_entry(buff, &message_cache[i]);
|
||||||
{
|
trace_(file,line)("%s\n", buff);
|
||||||
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)("\n");
|
||||||
{
|
|
||||||
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)
|
void compare_cache(const char* file, int line, MSG_ENTRY *msg_chain)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
char buffGot[100], buffExp[100];
|
||||||
BOOL got_error = FALSE;
|
BOOL got_error = FALSE;
|
||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
char *szMsgExpected, *szMsgGot;
|
|
||||||
BOOL same = !memcmp(&message_cache[i],msg_chain, sizeof(MSG_ENTRY));
|
BOOL same = !memcmp(&message_cache[i],msg_chain, sizeof(MSG_ENTRY));
|
||||||
|
|
||||||
szMsgExpected = get_msg_name(msg_chain->msg);
|
sprintf_msg_entry(buffGot, &message_cache[i]);
|
||||||
szMsgGot = get_msg_name(message_cache[i].msg);
|
sprintf_msg_entry(buffExp, msg_chain);
|
||||||
if(!msg_chain->hook)
|
ok_(file,line)(same,"got %s, expected %s\n", buffGot, buffExp);
|
||||||
{
|
|
||||||
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)
|
if(!got_error && !same)
|
||||||
{
|
|
||||||
got_error = TRUE;
|
got_error = TRUE;
|
||||||
}
|
|
||||||
|
|
||||||
if(msg_chain->msg !=0 && msg_chain->iwnd != 0)
|
if(msg_chain->msg !=0 && msg_chain->iwnd != 0)
|
||||||
{
|
|
||||||
msg_chain++;
|
msg_chain++;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(i>message_cache_size)
|
if(i>message_cache_size)
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue