From 6ad2cf9b5350adff859d36e3438be6a4a54c9fe0 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Thu, 12 Jun 2014 10:18:23 +0200 Subject: [PATCH] comctl32/tests: Output message sequences only on failure. --- dlls/comctl32/tests/msg.h | 97 +++++++++++++++++++++++++++++++++++++++--- dlls/comctl32/tests/syslink.c | 4 -- dlls/comctl32/tests/tab.c | 4 -- dlls/comctl32/tests/toolbar.c | 1 - dlls/comctl32/tests/trackbar.c | 4 -- dlls/comctl32/tests/treeview.c | 1 - dlls/comctl32/tests/updown.c | 6 --- 7 files changed, 91 insertions(+), 26 deletions(-) diff --git a/dlls/comctl32/tests/msg.h b/dlls/comctl32/tests/msg.h index 0e7ca994b1d..3fa0fae311c 100644 --- a/dlls/comctl32/tests/msg.h +++ b/dlls/comctl32/tests/msg.h @@ -102,6 +102,68 @@ static inline void flush_sequences(struct msg_sequence **seq, int n) flush_sequence(seq, i); } +static void dump_sequence( struct msg_sequence **seq, int sequence_index, + const struct message *expected, const char *context, + const char *file, int line ) +{ + struct msg_sequence *msg_seq = seq[sequence_index]; + const struct message *actual, *sequence; + unsigned int count = 0; + + sequence = msg_seq->sequence; + actual = sequence; + + trace_(file, line)("Failed sequence %s:\n", context ); + while (expected->message && actual->message) + { + trace_(file, line)( " %u: expected: %04x - actual: %04x wp %08lx lp %08lx\n", + count, expected->message, actual->message, actual->wParam, actual->lParam ); + + if (expected->message == actual->message) + { + if ((expected->flags & defwinproc) != (actual->flags & defwinproc) && + (expected->flags & optional)) + { + /* don't match messages if their defwinproc status differs */ + expected++; + } + else + { + expected++; + actual++; + } + } + else + { + expected++; + actual++; + } + count++; + } + + /* optional trailing messages */ + while (expected->message && expected->flags & optional) + { + trace_(file, line)( " %u: expected: msg %04x - actual: nothing\n", count, expected->message ); + expected++; + count++; + } + + if (expected->message) + { + trace_(file, line)( " %u: expected: msg %04x - actual: nothing\n", count, expected->message ); + return; + } + + while (actual->message) + { + trace_(file, line)( " %u: expected: nothing - actual: %04x wp %08lx lp %08lx\n", + count, actual->message, actual->wParam, actual->lParam ); + actual++; + count++; + } +} + static void ok_sequence_(struct msg_sequence **seq, int sequence_index, const struct message *expected, const char *context, BOOL todo, const char *file, int line) @@ -109,7 +171,7 @@ static void ok_sequence_(struct msg_sequence **seq, int sequence_index, struct msg_sequence *msg_seq = seq[sequence_index]; static const struct message end_of_sequence = {0, 0, 0, 0}; const struct message *actual, *sequence; - int failcount = 0; + int failcount = 0, dump = 0; add_message(seq, sequence_index, &end_of_sequence); @@ -118,8 +180,6 @@ static void ok_sequence_(struct msg_sequence **seq, int sequence_index, while (expected->message && actual->message) { - trace_( file, line)("expected %04x - actual %04x\n", expected->message, actual->message); - if (expected->message == actual->message) { if (expected->flags & wparam) @@ -129,6 +189,7 @@ static void ok_sequence_(struct msg_sequence **seq, int sequence_index, todo_wine { failcount++; + dump++; ok_(file, line) (FALSE, "%s: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n", context, expected->message, expected->wParam, actual->wParam); @@ -139,6 +200,7 @@ static void ok_sequence_(struct msg_sequence **seq, int sequence_index, ok_(file, line) (expected->wParam == actual->wParam, "%s: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n", context, expected->message, expected->wParam, actual->wParam); + if (expected->wParam != actual->wParam) dump++; } } @@ -149,6 +211,7 @@ static void ok_sequence_(struct msg_sequence **seq, int sequence_index, todo_wine { failcount++; + dump++; ok_(file, line) (FALSE, "%s: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n", context, expected->message, expected->lParam, actual->lParam); @@ -159,6 +222,7 @@ static void ok_sequence_(struct msg_sequence **seq, int sequence_index, ok_(file, line) (expected->lParam == actual->lParam, "%s: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n", context, expected->message, expected->lParam, actual->lParam); + if (expected->lParam != actual->lParam) dump++; } } @@ -169,6 +233,7 @@ static void ok_sequence_(struct msg_sequence **seq, int sequence_index, todo_wine { failcount++; + dump++; ok_(file, line) (FALSE, "%s: in msg 0x%04x expecting cd stage 0x%08x got 0x%08x\n", context, expected->message, expected->stage, actual->stage); @@ -179,6 +244,7 @@ static void ok_sequence_(struct msg_sequence **seq, int sequence_index, ok_(file, line) (expected->stage == actual->stage, "%s: in msg 0x%04x expecting cd stage 0x%08x got 0x%08x\n", context, expected->message, expected->stage, actual->stage); + if (expected->stage != actual->stage) dump++; } } @@ -194,6 +260,7 @@ static void ok_sequence_(struct msg_sequence **seq, int sequence_index, todo_wine { failcount++; + dump++; ok_(file, line) (FALSE, "%s: in msg 0x%04x expecting id 0x%x got 0x%x\n", context, expected->message, expected->id, actual->id); @@ -204,6 +271,7 @@ static void ok_sequence_(struct msg_sequence **seq, int sequence_index, ok_(file, line) (expected->id == actual->id, "%s: in msg 0x%04x expecting id 0x%x got 0x%x\n", context, expected->message, expected->id, actual->id); + if (expected->id != actual->id) dump++; } } @@ -212,6 +280,7 @@ static void ok_sequence_(struct msg_sequence **seq, int sequence_index, todo_wine { failcount++; + dump++; ok_(file, line) (FALSE, "%s: the msg 0x%04x should %shave been sent by DefWindowProc\n", context, expected->message, (expected->flags & defwinproc) ? "" : "NOT "); @@ -222,23 +291,34 @@ static void ok_sequence_(struct msg_sequence **seq, int sequence_index, ok_(file, line) ((expected->flags & defwinproc) == (actual->flags & defwinproc), "%s: the msg 0x%04x should %shave been sent by DefWindowProc\n", context, expected->message, (expected->flags & defwinproc) ? "" : "NOT "); + if ((expected->flags & defwinproc) != (actual->flags & defwinproc)) dump++; } ok_(file, line) ((expected->flags & beginpaint) == (actual->flags & beginpaint), "%s: the msg 0x%04x should %shave been sent by BeginPaint\n", context, expected->message, (expected->flags & beginpaint) ? "" : "NOT "); + if ((expected->flags & beginpaint) != (actual->flags & beginpaint)) dump++; + ok_(file, line) ((expected->flags & (sent|posted)) == (actual->flags & (sent|posted)), "%s: the msg 0x%04x should have been %s\n", context, expected->message, (expected->flags & posted) ? "posted" : "sent"); + if ((expected->flags & (sent|posted)) != (actual->flags & (sent|posted))) dump++; + ok_(file, line) ((expected->flags & parent) == (actual->flags & parent), "%s: the msg 0x%04x was expected in %s\n", context, expected->message, (expected->flags & parent) ? "parent" : "child"); + if ((expected->flags & parent) != (actual->flags & parent)) dump++; + ok_(file, line) ((expected->flags & hook) == (actual->flags & hook), "%s: the msg 0x%04x should have been sent by a hook\n", context, expected->message); + if ((expected->flags & hook) != (actual->flags & hook)) dump++; + 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", context, expected->message); + if ((expected->flags & winevent_hook) != (actual->flags & winevent_hook)) dump++; + expected++; actual++; } @@ -247,19 +327,19 @@ static void ok_sequence_(struct msg_sequence **seq, int sequence_index, else if (todo) { failcount++; + dump++; todo_wine { ok_(file, line) (FALSE, "%s: the msg 0x%04x was expected, but got msg 0x%04x instead\n", context, expected->message, actual->message); } - - flush_sequence(seq, sequence_index); - return; + goto done; } else { ok_(file, line) (FALSE, "%s: the msg 0x%04x was expected, but got msg 0x%04x instead\n", context, expected->message, actual->message); + dump++; expected++; actual++; } @@ -276,6 +356,7 @@ static void ok_sequence_(struct msg_sequence **seq, int sequence_index, if (expected->message || actual->message) { failcount++; + dump++; ok_(file, line) (FALSE, "%s: the msg sequence is not complete: expected %04x - actual %04x\n", context, expected->message, actual->message); } @@ -283,18 +364,22 @@ static void ok_sequence_(struct msg_sequence **seq, int sequence_index, } else if (expected->message || actual->message) { + dump++; ok_(file, line) (FALSE, "%s: the msg sequence is not complete: expected %04x - actual %04x\n", context, expected->message, actual->message); } if(todo && !failcount) /* succeeded yet marked todo */ { + dump++; todo_wine { ok_(file, line)(TRUE, "%s: marked \"todo_wine\" but succeeds\n", context); } } +done: + if (dump) dump_sequence( seq, sequence_index, expected, context, file, line ); flush_sequence(seq, sequence_index); } diff --git a/dlls/comctl32/tests/syslink.c b/dlls/comctl32/tests/syslink.c index d493cb75d37..918b7746b71 100644 --- a/dlls/comctl32/tests/syslink.c +++ b/dlls/comctl32/tests/syslink.c @@ -91,8 +91,6 @@ static LRESULT WINAPI parent_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LP message != WM_GETICON && message != WM_DEVICECHANGE) { - trace("parent: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam); - msg.message = message; msg.flags = sent|wparam|lparam; if (defwndproc_counter) msg.flags |= defwinproc; @@ -148,8 +146,6 @@ static LRESULT WINAPI syslink_subclass_proc(HWND hwnd, UINT message, WPARAM wPar LRESULT ret; struct message msg; - trace("syslink: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam); - msg.message = message; msg.flags = sent|wparam|lparam; if (defwndproc_counter) msg.flags |= defwinproc; diff --git a/dlls/comctl32/tests/tab.c b/dlls/comctl32/tests/tab.c index b5bdef17977..2b7f6d3dc0d 100644 --- a/dlls/comctl32/tests/tab.c +++ b/dlls/comctl32/tests/tab.c @@ -340,8 +340,6 @@ static LRESULT WINAPI parentWindowProcess(HWND hwnd, UINT message, WPARAM wParam message != WM_GETICON && message != WM_DEVICECHANGE) { - trace("parent: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam); - msg.message = message; msg.flags = sent|wparam|lparam; if (defwndproc_counter) msg.flags |= defwinproc; @@ -405,8 +403,6 @@ static LRESULT WINAPI tabSubclassProcess(HWND hwnd, UINT message, WPARAM wParam, message != WM_GETICON && message != WM_DEVICECHANGE) { - trace("tab: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam); - msg.message = message; msg.flags = sent|wparam|lparam; if (defwndproc_counter) msg.flags |= defwinproc; diff --git a/dlls/comctl32/tests/toolbar.c b/dlls/comctl32/tests/toolbar.c index c492763a8f6..da21924da94 100644 --- a/dlls/comctl32/tests/toolbar.c +++ b/dlls/comctl32/tests/toolbar.c @@ -160,7 +160,6 @@ static LRESULT CALLBACK parent_wnd_proc(HWND hWnd, UINT message, WPARAM wParam, message != WM_GETICON && message != WM_DEVICECHANGE) { - trace("parent: %p, %04x, %08lx, %08lx\n", hWnd, message, wParam, lParam); add_message(sequences, PARENT_SEQ_INDEX, &msg); } diff --git a/dlls/comctl32/tests/trackbar.c b/dlls/comctl32/tests/trackbar.c index 32c9575d8e7..5a468ee7527 100644 --- a/dlls/comctl32/tests/trackbar.c +++ b/dlls/comctl32/tests/trackbar.c @@ -384,8 +384,6 @@ static LRESULT WINAPI parent_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LP message != WM_GETICON && message != WM_DEVICECHANGE) { - trace("parent: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam); - msg.message = message; msg.flags = sent|wparam|lparam; if (defwndproc_counter) msg.flags |= defwinproc; @@ -433,8 +431,6 @@ static LRESULT WINAPI trackbar_subclass_proc(HWND hwnd, UINT message, WPARAM wPa LRESULT ret; struct message msg; - trace("trackbar: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam); - msg.message = message; msg.flags = sent|wparam|lparam; if (defwndproc_counter) msg.flags |= defwinproc; diff --git a/dlls/comctl32/tests/treeview.c b/dlls/comctl32/tests/treeview.c index 24a63d8af2a..ce65f068671 100644 --- a/dlls/comctl32/tests/treeview.c +++ b/dlls/comctl32/tests/treeview.c @@ -1034,7 +1034,6 @@ static LRESULT CALLBACK parent_wnd_proc(HWND hWnd, UINT message, WPARAM wParam, message != WM_GETICON && message != WM_DEVICECHANGE) { - trace("parent: %p, %04x, %08lx, %08lx\n", hWnd, message, wParam, lParam); add_message(sequences, PARENT_SEQ_INDEX, &msg); } diff --git a/dlls/comctl32/tests/updown.c b/dlls/comctl32/tests/updown.c index 6e0c92c5c27..cc06f650a81 100644 --- a/dlls/comctl32/tests/updown.c +++ b/dlls/comctl32/tests/updown.c @@ -179,8 +179,6 @@ static LRESULT WINAPI parent_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LP message != WM_GETICON && message != WM_DEVICECHANGE) { - trace("parent: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam); - msg.message = message; msg.flags = sent|wparam|lparam; if (defwndproc_counter) msg.flags |= defwinproc; @@ -234,8 +232,6 @@ static LRESULT WINAPI edit_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LRESULT ret; struct message msg; - trace("edit: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam); - msg.message = message; msg.flags = sent|wparam|lparam; if (defwndproc_counter) msg.flags |= defwinproc; @@ -276,8 +272,6 @@ static LRESULT WINAPI updown_subclass_proc(HWND hwnd, UINT message, WPARAM wPara LRESULT ret; struct message msg; - trace("updown: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam); - msg.message = message; msg.flags = sent|wparam|lparam; if (defwndproc_counter) msg.flags |= defwinproc; -- 2.11.4.GIT