https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7905efdf357ad830d4abb…
commit 7905efdf357ad830d4abba23a428dcd9e6195247
Author: Thomas Faber <thomas.faber(a)reactos.org>
AuthorDate: Wed Mar 7 13:02:52 2018 +0100
Commit: Thomas Faber <thomas.faber(a)reactos.org>
CommitDate: Wed Mar 7 13:20:42 2018 +0100
[USER32_APITEST] Add a test for PeekMessage without DispatchMessage for WM_PAINT.
CORE-13734
---
modules/rostests/apitests/user32/CMakeLists.txt | 1 +
modules/rostests/apitests/user32/RedrawWindow.c | 86 +++++++++++++++++++++++++
modules/rostests/apitests/user32/testlist.c | 2 +
3 files changed, 89 insertions(+)
diff --git a/modules/rostests/apitests/user32/CMakeLists.txt
b/modules/rostests/apitests/user32/CMakeLists.txt
index 5a0c2d1844..6b1ad32939 100644
--- a/modules/rostests/apitests/user32/CMakeLists.txt
+++ b/modules/rostests/apitests/user32/CMakeLists.txt
@@ -23,6 +23,7 @@ list(APPEND SOURCE
LookupIconIdFromDirectoryEx.c
NextDlgItem.c
RealGetWindowClass.c
+ RedrawWindow.c
RegisterClassEx.c
RegisterHotKey.c
ScrollDC.c
diff --git a/modules/rostests/apitests/user32/RedrawWindow.c
b/modules/rostests/apitests/user32/RedrawWindow.c
new file mode 100644
index 0000000000..eb39f9b714
--- /dev/null
+++ b/modules/rostests/apitests/user32/RedrawWindow.c
@@ -0,0 +1,86 @@
+/*
+ * PROJECT: ReactOS API tests
+ * LICENSE: LGPL-2.1+ (
https://spdx.org/licenses/LGPL-2.1+)
+ * PURPOSE: Test for RedrawWindow
+ * COPYRIGHT: Copyright 2018 Thomas Faber <thomas.faber(a)reactos.org>
+ */
+
+#include "precomp.h"
+
+static DWORD dwThreadId;
+static BOOL got_paint;
+
+static
+LRESULT
+CALLBACK
+WndProc(
+ _In_ HWND hWnd,
+ _In_ UINT message,
+ _In_ WPARAM wParam,
+ _In_ LPARAM lParam)
+{
+ ok(GetCurrentThreadId() == dwThreadId, "Thread 0x%lx instead of 0x%lx\n",
GetCurrentThreadId(), dwThreadId);
+ if (message == WM_PAINT)
+ {
+ got_paint = TRUE;
+ }
+ return DefWindowProcW(hWnd, message, wParam, lParam);
+}
+
+
+START_TEST(RedrawWindow)
+{
+ HWND hWnd;
+ MSG msg;
+ HRGN hRgn;
+ BOOL ret;
+ int i;
+
+ SetCursorPos(0,0);
+
+ dwThreadId = GetCurrentThreadId();
+ RegisterSimpleClass(WndProc, L"CreateTest");
+
+ hWnd = CreateWindowExW(0, L"CreateTest", NULL, 0, 10, 10, 20, 20, NULL,
NULL, 0, NULL);
+ ok(hWnd != NULL, "CreateWindow failed\n");
+
+ ShowWindow(hWnd, SW_SHOW);
+
+ while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
+ {
+ DispatchMessageA( &msg );
+ }
+
+ ok(got_paint == TRUE, "Did not process WM_PAINT message\n");
+ got_paint = FALSE;
+
+ hRgn = CreateRectRgn(0, 0, 1, 1);
+ ok(hRgn != NULL, "CreateRectRgn failed\n");
+ ret = RedrawWindow(hWnd, NULL, hRgn, RDW_INTERNALPAINT | RDW_INVALIDATE);
+ ok(ret == TRUE, "RedrawWindow failed\n");
+
+ i = 0;
+ while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
+ {
+ RECORD_MESSAGE(1, msg.message, POST, 0, 0);
+ if (msg.message == WM_PAINT)
+ {
+ i++;
+ if (i == 10)
+ {
+ ok(got_paint == FALSE, "Received unexpected WM_PAINT
message\n");
+ }
+ }
+ if (msg.message != WM_PAINT || i >= 10)
+ {
+ DispatchMessageA( &msg );
+ }
+ }
+
+ ok(i == 10, "Received %d WM_PAINT messages\n", i);
+ ok(got_paint == TRUE, "Did not process WM_PAINT message\n");
+
+ TRACE_CACHE();
+
+ DeleteObject(hRgn);
+}
diff --git a/modules/rostests/apitests/user32/testlist.c
b/modules/rostests/apitests/user32/testlist.c
index 494137a8c0..f5214b8bd2 100644
--- a/modules/rostests/apitests/user32/testlist.c
+++ b/modules/rostests/apitests/user32/testlist.c
@@ -25,6 +25,7 @@ extern void func_LoadImage(void);
extern void func_LookupIconIdFromDirectoryEx(void);
extern void func_NextDlgItem(void);
extern void func_RealGetWindowClass(void);
+extern void func_RedrawWindow(void);
extern void func_RegisterHotKey(void);
extern void func_RegisterClassEx(void);
extern void func_ScrollDC(void);
@@ -65,6 +66,7 @@ const struct test winetest_testlist[] =
{ "LookupIconIdFromDirectoryEx", func_LookupIconIdFromDirectoryEx },
{ "NextDlgItem", func_NextDlgItem },
{ "RealGetWindowClass", func_RealGetWindowClass },
+ { "RedrawWindow", func_RedrawWindow },
{ "RegisterHotKey", func_RegisterHotKey },
{ "RegisterClassEx", func_RegisterClassEx },
{ "ScrollDC", func_ScrollDC },