1 /*
2  * PROJECT:     ReactOS API tests
3  * LICENSE:     LGPL-2.1+ (https://spdx.org/licenses/LGPL-2.1+)
4  * PURPOSE:     Test for RedrawWindow
5  * COPYRIGHT:   Copyright 2018 Thomas Faber <thomas.faber@reactos.org>
6  */
7 
8 #include "precomp.h"
9 
10 static DWORD dwThreadId;
11 static BOOL got_paint;
12 
13 static
14 LRESULT
15 CALLBACK
16 WndProc(
17     _In_ HWND hWnd,
18     _In_ UINT message,
19     _In_ WPARAM wParam,
20     _In_ LPARAM lParam)
21 {
22     disable_success_count
23     ok(GetCurrentThreadId() == dwThreadId, "Thread 0x%lx instead of 0x%lx\n", GetCurrentThreadId(), dwThreadId);
24     if (message == WM_PAINT)
25     {
26         got_paint = TRUE;
27     }
28     return DefWindowProcW(hWnd, message, wParam, lParam);
29 }
30 
31 
32 START_TEST(RedrawWindow)
33 {
34     HWND hWnd;
35     MSG msg;
36     HRGN hRgn;
37     BOOL ret;
38     int i;
39 
40     SetCursorPos(0,0);
41 
42     dwThreadId = GetCurrentThreadId();
43     RegisterSimpleClass(WndProc, L"CreateTest");
44 
45     hWnd = CreateWindowExW(0, L"CreateTest", NULL, 0,  10, 10, 20, 20,  NULL, NULL, 0, NULL);
46     ok(hWnd != NULL, "CreateWindow failed\n");
47 
48     ShowWindow(hWnd, SW_SHOW);
49 
50     while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
51     {
52         DispatchMessageA( &msg );
53     }
54 
55     ok(got_paint == TRUE, "Did not process WM_PAINT message\n");
56     got_paint = FALSE;
57 
58     hRgn = CreateRectRgn(0, 0, 1, 1);
59     ok(hRgn != NULL, "CreateRectRgn failed\n");
60     ret = RedrawWindow(hWnd, NULL, hRgn, RDW_INTERNALPAINT | RDW_INVALIDATE);
61     ok(ret == TRUE, "RedrawWindow failed\n");
62 
63     i = 0;
64     while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
65     {
66         RECORD_MESSAGE(1, msg.message, POST, 0, 0);
67         if (msg.message == WM_PAINT)
68         {
69             i++;
70             if (i == 10)
71             {
72                 ok(got_paint == FALSE, "Received unexpected WM_PAINT message\n");
73             }
74         }
75         if (msg.message != WM_PAINT || i >= 10)
76         {
77             DispatchMessageA( &msg );
78         }
79     }
80 
81     ok(i == 10, "Received %d WM_PAINT messages\n", i);
82     ok(got_paint == TRUE, "Did not process WM_PAINT message\n");
83 
84     TRACE_CACHE();
85 
86     DeleteObject(hRgn);
87     DestroyWindow(hWnd);
88 }
89