comctl32/tests: Move message testing helpers to header
Nikolay Sivov
bunglehead at gmail.com
Thu Nov 12 09:46:26 CST 2009
This will remove dummy msg entry on test results page as a side effect.
Changelog:
- Move message testing helpers to header
>From 8a02efbc5e797a0458e275a5791a703692265d97 Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <bunglehead at gmail.com>
Date: Sun, 23 Aug 2009 12:39:27 +0400
Subject: Move message testing helpers to header
---
dlls/comctl32/tests/Makefile.in | 1 -
dlls/comctl32/tests/msg.c | 256 ---------------------------------------
dlls/comctl32/tests/msg.h | 236 ++++++++++++++++++++++++++++++++++-
3 files changed, 229 insertions(+), 264 deletions(-)
delete mode 100644 dlls/comctl32/tests/msg.c
diff --git a/dlls/comctl32/tests/Makefile.in b/dlls/comctl32/tests/Makefile.in
index 6fe2000..386780d 100644
--- a/dlls/comctl32/tests/Makefile.in
+++ b/dlls/comctl32/tests/Makefile.in
@@ -16,7 +16,6 @@ CTESTS = \
misc.c \
monthcal.c \
mru.c \
- msg.c \
progress.c \
propsheet.c \
rebar.c \
diff --git a/dlls/comctl32/tests/msg.c b/dlls/comctl32/tests/msg.c
deleted file mode 100644
index 04bf1a0..0000000
--- a/dlls/comctl32/tests/msg.c
+++ /dev/null
@@ -1,256 +0,0 @@
-/* Message Sequence Testing Code
- *
- * Copyright (C) 2007 James Hawkins
- * Copyright (C) 2007 Lei Zhang
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
-#include "msg.h"
-
-void add_message(struct msg_sequence **seq, int sequence_index,
- const struct message *msg)
-{
- struct msg_sequence *msg_seq = seq[sequence_index];
-
- if (!msg_seq->sequence)
- {
- msg_seq->size = 10;
- msg_seq->sequence = HeapAlloc(GetProcessHeap(), 0,
- msg_seq->size * sizeof (struct message));
- }
-
- if (msg_seq->count == msg_seq->size)
- {
- msg_seq->size *= 2;
- msg_seq->sequence = HeapReAlloc(GetProcessHeap(), 0,
- msg_seq->sequence,
- msg_seq->size * sizeof (struct message));
- }
-
- assert(msg_seq->sequence);
-
- msg_seq->sequence[msg_seq->count].message = msg->message;
- msg_seq->sequence[msg_seq->count].flags = msg->flags;
- msg_seq->sequence[msg_seq->count].wParam = msg->wParam;
- msg_seq->sequence[msg_seq->count].lParam = msg->lParam;
- msg_seq->sequence[msg_seq->count].id = msg->id;
-
- msg_seq->count++;
-}
-
-static void flush_sequence(struct msg_sequence **seg, int sequence_index)
-{
- struct msg_sequence *msg_seq = seg[sequence_index];
- HeapFree(GetProcessHeap(), 0, msg_seq->sequence);
- msg_seq->sequence = NULL;
- msg_seq->count = msg_seq->size = 0;
-}
-
-void flush_sequences(struct msg_sequence **seq, int n)
-{
- int i;
-
- for (i = 0; i < n; i++)
- flush_sequence(seq, i);
-}
-
-void ok_sequence_(struct msg_sequence **seq, int sequence_index,
- const struct message *expected, const char *context, int todo,
- const char *file, int line)
-{
- 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;
-
- add_message(seq, sequence_index, &end_of_sequence);
-
- sequence = msg_seq->sequence;
- actual = sequence;
-
- 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)
- {
- if (expected->wParam != actual->wParam && todo)
- {
- todo_wine
- {
- failcount++;
- ok_(file, line) (FALSE,
- "%s: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
- context, expected->message, expected->wParam, actual->wParam);
- }
- }
- else
- {
- 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->flags & lparam)
- {
- if (expected->lParam != actual->lParam && todo)
- {
- todo_wine
- {
- failcount++;
- ok_(file, line) (FALSE,
- "%s: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
- context, expected->message, expected->lParam, actual->lParam);
- }
- }
- else
- {
- 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->flags & id)
- {
- if (expected->id != actual->id && expected->flags & optional)
- {
- expected++;
- continue;
- }
- if (expected->id != actual->id && todo)
- {
- todo_wine
- {
- failcount++;
- ok_(file, line) (FALSE,
- "%s: in msg 0x%04x expecting id 0x%x got 0x%x\n",
- context, expected->message, expected->id, actual->id);
- }
- }
- else
- {
- 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->flags & defwinproc) != (actual->flags & defwinproc) && todo)
- {
- todo_wine
- {
- failcount++;
- ok_(file, line) (FALSE,
- "%s: the msg 0x%04x should %shave been sent by DefWindowProc\n",
- context, expected->message, (expected->flags & defwinproc) ? "" : "NOT ");
- }
- }
- else
- {
- 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 ");
- }
-
- 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 ");
- 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");
- 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");
- 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);
- 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);
- expected++;
- actual++;
- }
- else if (expected->flags & optional)
- expected++;
- else if (todo)
- {
- failcount++;
- 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;
- }
- else
- {
- ok_(file, line) (FALSE, "%s: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
- context, expected->message, actual->message);
- expected++;
- actual++;
- }
- }
-
- /* skip all optional trailing messages */
- while (expected->message && ((expected->flags & optional)))
- expected++;
-
- if (todo)
- {
- todo_wine
- {
- if (expected->message || actual->message)
- {
- failcount++;
- ok_(file, line) (FALSE, "%s: the msg sequence is not complete: expected %04x - actual %04x\n",
- context, expected->message, actual->message);
- }
- }
- }
- else if (expected->message || actual->message)
- {
- 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 */
- {
- todo_wine
- {
- ok_(file, line)(TRUE, "%s: marked \"todo_wine\" but succeeds\n", context);
- }
- }
-
- flush_sequence(seq, sequence_index);
-}
-
-void init_msg_sequences(struct msg_sequence **seq, int n)
-{
- int i;
-
- for (i = 0; i < n; i++)
- seq[i] = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct msg_sequence));
-}
-
-START_TEST(msg)
-{
-}
diff --git a/dlls/comctl32/tests/msg.h b/dlls/comctl32/tests/msg.h
index 87c6387..8e1a83a 100644
--- a/dlls/comctl32/tests/msg.h
+++ b/dlls/comctl32/tests/msg.h
@@ -58,16 +58,238 @@ struct msg_sequence
struct message *sequence;
};
-void add_message(struct msg_sequence **seq, int sequence_index,
- const struct message *msg);
-void flush_sequences(struct msg_sequence **seq, int n);
+static void add_message(struct msg_sequence **seq, int sequence_index,
+ const struct message *msg)
+{
+ struct msg_sequence *msg_seq = seq[sequence_index];
+
+ if (!msg_seq->sequence)
+ {
+ msg_seq->size = 10;
+ msg_seq->sequence = HeapAlloc(GetProcessHeap(), 0,
+ msg_seq->size * sizeof (struct message));
+ }
+
+ if (msg_seq->count == msg_seq->size)
+ {
+ msg_seq->size *= 2;
+ msg_seq->sequence = HeapReAlloc(GetProcessHeap(), 0,
+ msg_seq->sequence,
+ msg_seq->size * sizeof (struct message));
+ }
+
+ assert(msg_seq->sequence);
+
+ msg_seq->sequence[msg_seq->count].message = msg->message;
+ msg_seq->sequence[msg_seq->count].flags = msg->flags;
+ msg_seq->sequence[msg_seq->count].wParam = msg->wParam;
+ msg_seq->sequence[msg_seq->count].lParam = msg->lParam;
+ msg_seq->sequence[msg_seq->count].id = msg->id;
+
+ msg_seq->count++;
+}
+
+static void flush_sequence(struct msg_sequence **seg, int sequence_index)
+{
+ struct msg_sequence *msg_seq = seg[sequence_index];
+ HeapFree(GetProcessHeap(), 0, msg_seq->sequence);
+ msg_seq->sequence = NULL;
+ msg_seq->count = msg_seq->size = 0;
+}
+
+static void flush_sequences(struct msg_sequence **seq, int n)
+{
+ int i;
+
+ for (i = 0; i < n; i++)
+ flush_sequence(seq, i);
+}
+
+static void ok_sequence_(struct msg_sequence **seq, int sequence_index,
+ const struct message *expected, const char *context, int todo,
+ const char *file, int line)
+{
+ 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;
+
+ add_message(seq, sequence_index, &end_of_sequence);
+
+ sequence = msg_seq->sequence;
+ actual = sequence;
+
+ 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)
+ {
+ if (expected->wParam != actual->wParam && todo)
+ {
+ todo_wine
+ {
+ failcount++;
+ ok_(file, line) (FALSE,
+ "%s: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
+ context, expected->message, expected->wParam, actual->wParam);
+ }
+ }
+ else
+ {
+ 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->flags & lparam)
+ {
+ if (expected->lParam != actual->lParam && todo)
+ {
+ todo_wine
+ {
+ failcount++;
+ ok_(file, line) (FALSE,
+ "%s: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
+ context, expected->message, expected->lParam, actual->lParam);
+ }
+ }
+ else
+ {
+ 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->flags & id)
+ {
+ if (expected->id != actual->id && expected->flags & optional)
+ {
+ expected++;
+ continue;
+ }
+ if (expected->id != actual->id && todo)
+ {
+ todo_wine
+ {
+ failcount++;
+ ok_(file, line) (FALSE,
+ "%s: in msg 0x%04x expecting id 0x%x got 0x%x\n",
+ context, expected->message, expected->id, actual->id);
+ }
+ }
+ else
+ {
+ 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->flags & defwinproc) != (actual->flags & defwinproc) && todo)
+ {
+ todo_wine
+ {
+ failcount++;
+ ok_(file, line) (FALSE,
+ "%s: the msg 0x%04x should %shave been sent by DefWindowProc\n",
+ context, expected->message, (expected->flags & defwinproc) ? "" : "NOT ");
+ }
+ }
+ else
+ {
+ 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 ");
+ }
+
+ 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 ");
+ 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");
+ 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");
+ 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);
+ 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);
+ expected++;
+ actual++;
+ }
+ else if (expected->flags & optional)
+ expected++;
+ else if (todo)
+ {
+ failcount++;
+ 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;
+ }
+ else
+ {
+ ok_(file, line) (FALSE, "%s: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
+ context, expected->message, actual->message);
+ expected++;
+ actual++;
+ }
+ }
+
+ /* skip all optional trailing messages */
+ while (expected->message && ((expected->flags & optional)))
+ expected++;
+
+ if (todo)
+ {
+ todo_wine
+ {
+ if (expected->message || actual->message)
+ {
+ failcount++;
+ ok_(file, line) (FALSE, "%s: the msg sequence is not complete: expected %04x - actual %04x\n",
+ context, expected->message, actual->message);
+ }
+ }
+ }
+ else if (expected->message || actual->message)
+ {
+ 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 */
+ {
+ todo_wine
+ {
+ ok_(file, line)(TRUE, "%s: marked \"todo_wine\" but succeeds\n", context);
+ }
+ }
+
+ flush_sequence(seq, sequence_index);
+}
#define ok_sequence(seq, index, exp, contx, todo) \
ok_sequence_(seq, index, (exp), (contx), (todo), __FILE__, __LINE__)
-void ok_sequence_(struct msg_sequence **seq, int sequence_index,
- const struct message *expected, const char *context, int todo,
- const char *file, int line);
+static void init_msg_sequences(struct msg_sequence **seq, int n)
+{
+ int i;
+
+ for (i = 0; i < n; i++)
+ seq[i] = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct msg_sequence));
+}
-void init_msg_sequences(struct msg_sequence **seq, int n);
--
1.5.6.5
More information about the wine-patches
mailing list