[PATCH] Added test_PeekMessage2 to check that successive peekMessage calls with
Karl Relton
karllinuxtest.relton at ntlworld.com
Mon Sep 24 09:12:58 CDT 2007
the PM_NOREMOVE flag do see WM_MOUSEMOVE events with changed
parameters as the user moves the mouse - in other words the WM_MOUSEMOVE
event at the head of the queue gets 'merged' when new WM_MOUSEMOVE events
come in.
---
dlls/user32/tests/msg.c | 100 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 100 insertions(+), 0 deletions(-)
diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c
index af05f7b..15fcab4 100644
--- a/dlls/user32/tests/msg.c
+++ b/dlls/user32/tests/msg.c
@@ -8368,6 +8368,105 @@ todo_wine {
DestroyWindow(info.hwnd);
}
+static void wait_move_event(HWND hwnd, int x, int y)
+{
+ MSG msg;
+ DWORD time;
+ BOOL ret;
+ int go = 0;
+
+ time = GetTickCount();
+ while (GetTickCount() - time < 200 && !go) {
+ ret = PeekMessageA(&msg, hwnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_NOREMOVE);
+ go = ret && msg.pt.x > x && msg.pt.y > y;
+ }
+}
+
+#define STEP 20
+static void test_PeekMessage2(void)
+{
+ HWND hwnd;
+ BOOL ret;
+ MSG msg;
+ UINT message;
+ DWORD time1, time2, time3;
+ int x1, y1, x2, y2, x3, y3;
+
+ time1 = time2 = time3 = 0;
+ x1 = y1 = x2 = y2 = x3 = y3 = 0;
+
+ /* Initialise window and make sure it is ready for events */
+ hwnd = CreateWindow("TestWindowClass", "PeekMessage2", WS_OVERLAPPEDWINDOW,
+ 10, 10, 800, 800, NULL, NULL, NULL, NULL);
+ assert(hwnd);
+ trace("Window for test_PeekMessage2 %p\n", hwnd);
+ ShowWindow(hwnd, SW_SHOW);
+ UpdateWindow(hwnd);
+ SetFocus(hwnd);
+ SetCursorPos(100, 100);
+ mouse_event(MOUSEEVENTF_MOVE, -STEP, -STEP, 0, 0);
+ flush_events();
+
+ /* Do initial mousemove, wait until we can see it
+ and then do our test peek with PM_NOREMOVE. */
+ mouse_event(MOUSEEVENTF_MOVE, STEP, STEP, 0, 0);
+ wait_move_event(hwnd, 80, 80);
+
+ ret = PeekMessageA(&msg, hwnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_NOREMOVE);
+ ok(ret, "no message available\n");
+ if (ret) {
+ trace("1st move event: %04x %x %d %d\n", msg.message, msg.time, msg.pt.x, msg.pt.y);
+ message = msg.message;
+ time1 = msg.time;
+ x1 = msg.pt.x;
+ y1 = msg.pt.y;
+ ok(message == WM_MOUSEMOVE, "message not WM_MOUSEMOVE, %04x instead\n", message);
+ }
+
+ /* Allow time to advance a bit, and then simulate the user moving their
+ * mouse around. After that we peek again with PM_NOREMOVE.
+ * Although the previous mousemove message was never removed, the
+ * mousemove we now peek should reflect the recent mouse movements
+ * because the input queue will merge the move events. */
+ Sleep(1);
+ mouse_event(MOUSEEVENTF_MOVE, STEP, STEP, 0, 0);
+ wait_move_event(hwnd, x1, y1);
+
+ ret = PeekMessageA(&msg, hwnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_NOREMOVE);
+ ok(ret, "no message available\n");
+ if (ret) {
+ trace("2nd move event: %04x %x %d %d\n", msg.message, msg.time, msg.pt.x, msg.pt.y);
+ message = msg.message;
+ time2 = msg.time;
+ x2 = msg.pt.x;
+ y2 = msg.pt.y;
+ ok(message == WM_MOUSEMOVE, "message not WM_MOUSEMOVE, %04x instead\n", message);
+ ok(time2 > time1, "message time not advanced: %x %x\n", time1, time2);
+ ok(x2 != x1 && y2 != y1, "coords not changed: (%d %d) (%d %d)\n", x1, y1, x2, y2);
+ }
+
+ /* Have another go, to drive the point home */
+ Sleep(1);
+ mouse_event(MOUSEEVENTF_MOVE, STEP, STEP, 0, 0);
+ wait_move_event(hwnd, x2, y2);
+
+ ret = PeekMessageA(&msg, hwnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_NOREMOVE);
+ ok(ret, "no message available\n");
+ if (ret) {
+ trace("3rd move event: %04x %x %d %d\n", msg.message, msg.time, msg.pt.x, msg.pt.y);
+ message = msg.message;
+ time3 = msg.time;
+ x3 = msg.pt.x;
+ y3 = msg.pt.y;
+ ok(message == WM_MOUSEMOVE, "message not WM_MOUSEMOVE, %04x instead\n", message);
+ ok(time3 > time2, "message time not advanced: %x %x\n", time2, time3);
+ ok(x3 != x2 && y3 != y2, "coords not changed: (%d %d) (%d %d)\n", x2, y2, x3, y3);
+ }
+
+ /* Now remove the message from the queue to clean up */
+ PeekMessageA(&msg, hwnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE);
+ DestroyWindow(hwnd);
+}
static void test_quit_message(void)
{
@@ -9604,6 +9703,7 @@ START_TEST(msg)
test_ShowWindow();
test_PeekMessage();
+ test_PeekMessage2();
test_scrollwindowex();
test_messages();
test_showwindow();
--
1.4.4.2
--=-gKKKS/Qhz/6ph7ANK3s5--
More information about the wine-patches
mailing list