user32/tests: Print the failure position in the message sequence.

This commit is contained in:
Alexandre Julliard 2009-01-15 14:45:53 +01:00
parent 2d15dd54c6
commit 078689adb0
1 changed files with 40 additions and 36 deletions

View File

@ -1836,6 +1836,7 @@ static void flush_sequence(void)
static void dump_sequence(const struct message *expected, const char *context, const char *file, int line) static void dump_sequence(const struct message *expected, const char *context, const char *file, int line)
{ {
const struct recvd_message *actual = sequence; const struct recvd_message *actual = sequence;
unsigned int count = 0;
trace_(file, line)("Failed sequence %s:\n", context ); trace_(file, line)("Failed sequence %s:\n", context );
while (expected->message && actual->message) while (expected->message && actual->message)
@ -1844,18 +1845,18 @@ static void dump_sequence(const struct message *expected, const char *context, c
{ {
if (expected->flags & hook) if (expected->flags & hook)
{ {
trace_(file, line)( " expected: hook %04x - actual: %s\n", trace_(file, line)( " %u: expected: hook %04x - actual: %s\n",
expected->message, actual->output ); count, expected->message, actual->output );
} }
else if (expected->flags & winevent_hook) else if (expected->flags & winevent_hook)
{ {
trace_(file, line)( " expected: winevent %04x - actual: %s\n", trace_(file, line)( " %u: expected: winevent %04x - actual: %s\n",
expected->message, actual->output ); count, expected->message, actual->output );
} }
else else
{ {
trace_(file, line)( " expected: msg %04x - actual: %s\n", trace_(file, line)( " %u: expected: msg %04x - actual: %s\n",
expected->message, actual->output ); count, expected->message, actual->output );
} }
} }
@ -1872,6 +1873,7 @@ static void dump_sequence(const struct message *expected, const char *context, c
expected++; expected++;
actual++; actual++;
} }
count++;
} }
/* optional trailing messages */ /* optional trailing messages */
@ -1893,6 +1895,7 @@ static void ok_sequence_(const struct message *expected_list, const char *contex
const struct message *expected = expected_list; const struct message *expected = expected_list;
const struct recvd_message *actual; const struct recvd_message *actual;
int failcount = 0, dump = 0; int failcount = 0, dump = 0;
unsigned int count = 0;
add_message(&end_of_sequence); add_message(&end_of_sequence);
@ -1910,15 +1913,15 @@ static void ok_sequence_(const struct message *expected_list, const char *contex
failcount ++; failcount ++;
if (strcmp(winetest_platform, "wine")) dump++; if (strcmp(winetest_platform, "wine")) dump++;
ok_( file, line) (FALSE, ok_( file, line) (FALSE,
"%s: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n", "%s: %u: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
context, expected->message, expected->wParam, actual->wParam); context, count, expected->message, expected->wParam, actual->wParam);
} }
} }
else else
{ {
ok_( file, line)(expected->wParam == actual->wParam, ok_( file, line)(expected->wParam == actual->wParam,
"%s: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n", "%s: %u: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
context, expected->message, expected->wParam, actual->wParam); context, count, expected->message, expected->wParam, actual->wParam);
if (expected->wParam != actual->wParam) dump++; if (expected->wParam != actual->wParam) dump++;
} }
@ -1931,15 +1934,15 @@ static void ok_sequence_(const struct message *expected_list, const char *contex
failcount ++; failcount ++;
if (strcmp(winetest_platform, "wine")) dump++; if (strcmp(winetest_platform, "wine")) dump++;
ok_( file, line) (FALSE, ok_( file, line) (FALSE,
"%s: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n", "%s: %u: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
context, expected->message, expected->lParam, actual->lParam); context, count, expected->message, expected->lParam, actual->lParam);
} }
} }
else else
{ {
ok_( file, line)(expected->lParam == actual->lParam, ok_( file, line)(expected->lParam == actual->lParam,
"%s: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n", "%s: %u: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
context, expected->message, expected->lParam, actual->lParam); context, count, expected->message, expected->lParam, actual->lParam);
if (expected->lParam != actual->lParam) dump++; if (expected->lParam != actual->lParam) dump++;
} }
} }
@ -1949,41 +1952,41 @@ static void ok_sequence_(const struct message *expected_list, const char *contex
failcount ++; failcount ++;
if (strcmp(winetest_platform, "wine")) dump++; if (strcmp(winetest_platform, "wine")) dump++;
ok_( file, line) (FALSE, ok_( file, line) (FALSE,
"%s: the msg 0x%04x should %shave been sent by DefWindowProc\n", "%s: %u: the msg 0x%04x should %shave been sent by DefWindowProc\n",
context, expected->message, (expected->flags & defwinproc) ? "" : "NOT "); context, count, expected->message, (expected->flags & defwinproc) ? "" : "NOT ");
} }
} }
else else
{ {
ok_( file, line) ((expected->flags & defwinproc) == (actual->flags & defwinproc), ok_( file, line) ((expected->flags & defwinproc) == (actual->flags & defwinproc),
"%s: the msg 0x%04x should %shave been sent by DefWindowProc\n", "%s: %u: the msg 0x%04x should %shave been sent by DefWindowProc\n",
context, expected->message, (expected->flags & defwinproc) ? "" : "NOT "); context, count, expected->message, (expected->flags & defwinproc) ? "" : "NOT ");
if ((expected->flags & defwinproc) != (actual->flags & defwinproc)) dump++; if ((expected->flags & defwinproc) != (actual->flags & defwinproc)) dump++;
} }
ok_( file, line) ((expected->flags & beginpaint) == (actual->flags & beginpaint), ok_( file, line) ((expected->flags & beginpaint) == (actual->flags & beginpaint),
"%s: the msg 0x%04x should %shave been sent by BeginPaint\n", "%s: %u: the msg 0x%04x should %shave been sent by BeginPaint\n",
context, expected->message, (expected->flags & beginpaint) ? "" : "NOT "); context, count, expected->message, (expected->flags & beginpaint) ? "" : "NOT ");
if ((expected->flags & beginpaint) != (actual->flags & beginpaint)) dump++; if ((expected->flags & beginpaint) != (actual->flags & beginpaint)) dump++;
ok_( file, line) ((expected->flags & (sent|posted)) == (actual->flags & (sent|posted)), ok_( file, line) ((expected->flags & (sent|posted)) == (actual->flags & (sent|posted)),
"%s: the msg 0x%04x should have been %s\n", "%s: %u: the msg 0x%04x should have been %s\n",
context, expected->message, (expected->flags & posted) ? "posted" : "sent"); context, count, expected->message, (expected->flags & posted) ? "posted" : "sent");
if ((expected->flags & (sent|posted)) != (actual->flags & (sent|posted))) dump++; if ((expected->flags & (sent|posted)) != (actual->flags & (sent|posted))) dump++;
ok_( file, line) ((expected->flags & parent) == (actual->flags & parent), ok_( file, line) ((expected->flags & parent) == (actual->flags & parent),
"%s: the msg 0x%04x was expected in %s\n", "%s: %u: the msg 0x%04x was expected in %s\n",
context, expected->message, (expected->flags & parent) ? "parent" : "child"); context, count, expected->message, (expected->flags & parent) ? "parent" : "child");
if ((expected->flags & parent) != (actual->flags & parent)) dump++; if ((expected->flags & parent) != (actual->flags & parent)) dump++;
ok_( file, line) ((expected->flags & hook) == (actual->flags & hook), ok_( file, line) ((expected->flags & hook) == (actual->flags & hook),
"%s: the msg 0x%04x should have been sent by a hook\n", "%s: %u: the msg 0x%04x should have been sent by a hook\n",
context, expected->message); context, count, expected->message);
if ((expected->flags & hook) != (actual->flags & hook)) dump++; if ((expected->flags & hook) != (actual->flags & hook)) dump++;
ok_( file, line) ((expected->flags & winevent_hook) == (actual->flags & winevent_hook), ok_( file, line) ((expected->flags & winevent_hook) == (actual->flags & winevent_hook),
"%s: the msg 0x%04x should have been sent by a winevent hook\n", "%s: %u: the msg 0x%04x should have been sent by a winevent hook\n",
context, expected->message); context, count, expected->message);
if ((expected->flags & winevent_hook) != (actual->flags & winevent_hook)) dump++; if ((expected->flags & winevent_hook) != (actual->flags & winevent_hook)) dump++;
expected++; expected++;
@ -1997,19 +2000,20 @@ static void ok_sequence_(const struct message *expected_list, const char *contex
failcount++; failcount++;
todo_wine { todo_wine {
if (strcmp(winetest_platform, "wine")) dump++; if (strcmp(winetest_platform, "wine")) dump++;
ok_( file, line) (FALSE, "%s: the msg 0x%04x was expected, but got msg 0x%04x instead\n", ok_( file, line) (FALSE, "%s: %u: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
context, expected->message, actual->message); context, count, expected->message, actual->message);
} }
goto done; goto done;
} }
else else
{ {
ok_( file, line) (FALSE, "%s: the msg 0x%04x was expected, but got msg 0x%04x instead\n", ok_( file, line) (FALSE, "%s: %u: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
context, expected->message, actual->message); context, count, expected->message, actual->message);
dump++; dump++;
expected++; expected++;
actual++; actual++;
} }
count++;
} }
/* skip all optional trailing messages */ /* skip all optional trailing messages */
@ -2023,8 +2027,8 @@ static void ok_sequence_(const struct message *expected_list, const char *contex
if (expected->message || actual->message) { if (expected->message || actual->message) {
failcount++; failcount++;
if (strcmp(winetest_platform, "wine")) dump++; if (strcmp(winetest_platform, "wine")) dump++;
ok_( file, line) (FALSE, "%s: the msg sequence is not complete: expected %04x - actual %04x\n", ok_( file, line) (FALSE, "%s: %u: the msg sequence is not complete: expected %04x - actual %04x\n",
context, expected->message, actual->message); context, count, expected->message, actual->message);
} }
} }
} }
@ -2033,8 +2037,8 @@ static void ok_sequence_(const struct message *expected_list, const char *contex
if (expected->message || actual->message) if (expected->message || actual->message)
{ {
dump++; dump++;
ok_( file, line) (FALSE, "%s: the msg sequence is not complete: expected %04x - actual %04x\n", ok_( file, line) (FALSE, "%s: %u: the msg sequence is not complete: expected %04x - actual %04x\n",
context, expected->message, actual->message); context, count, expected->message, actual->message);
} }
} }
if( todo && !failcount) /* succeeded yet marked todo */ if( todo && !failcount) /* succeeded yet marked todo */