[USER32_APITEST] Add a test for PeekMessage without DispatchMessage for WM_PAINT...
authorThomas Faber <thomas.faber@reactos.org>
Wed, 7 Mar 2018 12:02:52 +0000 (13:02 +0100)
committerThomas Faber <thomas.faber@reactos.org>
Wed, 7 Mar 2018 12:20:42 +0000 (13:20 +0100)
modules/rostests/apitests/user32/CMakeLists.txt
modules/rostests/apitests/user32/RedrawWindow.c [new file with mode: 0644]
modules/rostests/apitests/user32/testlist.c

index 5a0c2d1..6b1ad32 100644 (file)
@@ -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 (file)
index 0000000..eb39f9b
--- /dev/null
@@ -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@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);
+}
index 494137a..f5214b8 100644 (file)
@@ -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 },