ReactOS 0.4.16-dev-197-g92996da
DrawThemeParentBackground.c File Reference
#include <apitest.h>
#include <stdio.h>
#include <windows.h>
#include <uxtheme.h>
#include <undocuser.h>
#include <msgtrace.h>
#include <user32testhelpers.h>
Include dependency graph for DrawThemeParentBackground.c:

Go to the source code of this file.

Functions

static int get_iwnd (HWND hWnd)
 
static LRESULT CALLBACK TestProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
 
static void FlushMessages ()
 
void Test_Messages ()
 
static LONG WINAPI VEHandler_1 (PEXCEPTION_POINTERS ExceptionInfo)
 
static LONG WINAPI VEHandler_2 (PEXCEPTION_POINTERS ExceptionInfo)
 
void Test_Params ()
 
 START_TEST (DrawThemeParentBackground)
 

Variables

HWND hWnd1
 
HWND hWnd2
 
MSG_ENTRY draw_parent_chain []
 
BOOL bGotException
 

Function Documentation

◆ FlushMessages()

static void FlushMessages ( )
static

Definition at line 36 of file DrawThemeParentBackground.c.

37{
38 MSG msg;
39
40 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
41 {
42 int iwnd = get_iwnd(msg.hwnd);
43 if(iwnd && msg.message <= WM_USER)
44 RECORD_MESSAGE(iwnd, msg.message, POST,0,0);
46 }
47}
static int get_iwnd(HWND hWnd)
#define msg(x)
Definition: auth_time.c:54
#define RECORD_MESSAGE(...)
Definition: msgtrace.h:60
@ POST
Definition: msgtrace.h:7
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
#define PM_REMOVE
Definition: winuser.h:1199
#define PeekMessage
Definition: winuser.h:5842
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
#define WM_USER
Definition: winuser.h:1898

Referenced by Test_Messages().

◆ get_iwnd()

static int get_iwnd ( HWND  hWnd)
static

Definition at line 18 of file DrawThemeParentBackground.c.

19{
20 if(hWnd == hWnd1) return 1;
21 else if(hWnd == hWnd2) return 2;
22 else return 0;
23}
HWND hWnd
Definition: settings.c:17

Referenced by FlushMessages(), and TestProc().

◆ START_TEST()

START_TEST ( DrawThemeParentBackground  )

Definition at line 211 of file DrawThemeParentBackground.c.

212{
214 Test_Params();
215}
void Test_Params()
void Test_Messages()

◆ Test_Messages()

void Test_Messages ( void  )

Definition at line 53 of file DrawThemeParentBackground.c.

54{
55 HDC hdc;
56 RECT rc;
57
58 RegisterSimpleClass(TestProc, L"testClass");
59
60 hWnd1 = CreateWindowW(L"testClass", L"Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 100, 100, 200, 200, 0, NULL, NULL, NULL);
61 ok (hWnd1 != NULL, "Expected CreateWindowW to succeed\n");
62
63 hWnd2 = CreateWindowW(L"testClass", L"test window", WS_CHILD | WS_VISIBLE, 0, 0, 100, 100, hWnd1, NULL, NULL, NULL);
64 ok (hWnd2 != NULL, "Expected CreateWindowW to succeed\n");
65
68
69 hdc = GetDC(hWnd1);
70
74
78
83
86
90
94
98
102
103 memset(&rc, 0, sizeof(rc));
104
108
112}
static void FlushMessages()
MSG_ENTRY draw_parent_chain[]
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
HRESULT WINAPI DrawThemeParentBackground(HWND hwnd, HDC hdc, RECT *prc)
Definition: draw.c:72
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:88
MSG_ENTRY empty_chain[]
Definition: msgtrace.c:20
#define EMPTY_CACHE()
Definition: msgtrace.h:59
#define COMPARE_CACHE(msg_chain)
Definition: msgtrace.h:57
#define L(x)
Definition: ntvdm.h:50
#define WS_CHILD
Definition: pedump.c:617
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define WS_VISIBLE
Definition: pedump.c:620
#define TestProc(n)
Definition: queuetest.c:15
#define memset(x, y, z)
Definition: compat.h:39
static __inline ATOM RegisterSimpleClass(WNDPROC lpfnWndProc, LPCWSTR lpszClassName)
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI UpdateWindow(_In_ HWND)
HDC WINAPI GetDC(_In_opt_ HWND)
#define CreateWindowW(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4319
#define SW_SHOW
Definition: winuser.h:778

Referenced by START_TEST().

◆ Test_Params()

void Test_Params ( void  )

Definition at line 128 of file DrawThemeParentBackground.c.

129{
130 HRESULT hr;
131 HDC hdc;
132 PVOID pVEH;
133
135
136 pVEH = AddVectoredExceptionHandler(1, VEHandler_1);
137
139 ok (hr == E_HANDLE, "Expected E_HANDLE got 0x%lx error\n", hr);
140
141 hr = DrawThemeParentBackground((HWND)(ULONG_PTR)0xdeaddeaddeaddeadULL, NULL, NULL);
142 ok (hr == E_HANDLE, "Expected E_HANDLE got 0x%lx error\n", hr);
143
144 hr = DrawThemeParentBackground(NULL, (HDC)(ULONG_PTR)0xdeaddeaddeaddeadULL, NULL);
145 ok (hr == E_HANDLE, "Expected E_HANDLE got 0x%lx error\n", hr);
146
147 hr = DrawThemeParentBackground((HWND)(ULONG_PTR)0xdeaddeaddeaddeadULL, (HDC)(ULONG_PTR)0xdeaddeaddeaddeadULL, NULL);
148 ok (hr == E_HANDLE, "Expected E_HANDLE got 0x%lx error\n", hr);
149
150 RemoveVectoredExceptionHandler(pVEH);
151
153
154 hWnd1 = CreateWindowW(L"testClass2", L"Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 100, 100, 200, 200, 0, NULL, NULL, NULL);
155 ok (hWnd1 != NULL, "Expected CreateWindowW to succeed\n");
156 hWnd2 = CreateWindowW(L"testClass2", L"test window", WS_CHILD | WS_VISIBLE, 0, 0, 100, 100, hWnd1, NULL, NULL, NULL);
157 ok (hWnd2 != NULL, "Expected CreateWindowW to succeed\n");
158
163
165 ok (hr == E_HANDLE, "Expected E_HANDLE got 0x%lx error\n", hr);
166
167 hdc = GetDC(hWnd1);
168 ok (hdc != NULL, "Expected GetDC to succeed\n");
169
171 ok (hr == E_HANDLE, "Expected E_HANDLE got 0x%lx error\n", hr);
172
174 ok (hr == S_OK, "Expected success got 0x%lx error\n", hr);
175
176 hr = DrawThemeParentBackground(hWnd1, (HDC)(ULONG_PTR)0xdeaddeaddeaddeadULL, NULL);
177 ok (hr == S_OK, "Expected success got 0x%lx error\n", hr);
178
179 pVEH = AddVectoredExceptionHandler(1, VEHandler_2);
180 hr = DrawThemeParentBackground(hWnd1, hdc, (RECT*)(ULONG_PTR)0xdeaddeaddeaddeadULL);
181 ok (hr == E_POINTER, "Expected success got 0x%lx error\n", hr);
182 RemoveVectoredExceptionHandler(pVEH);
183 ok (bGotException == TRUE, "Excepted a handled exception\n");
184
186 ok (hr == E_HANDLE, "Expected E_HANDLE got 0x%lx error\n", hr);
187
189 if (IsThemeActive())
190 ok (hr == S_FALSE, "Expected S_FALSE got 0x%lx error\n", hr);
191 else
192 skip("Theme not active\n");
193
195 hdc = GetDC(hWnd2);
196 ok (hdc != NULL, "Expected GetDC to succeed\n");
197
199 ok (hr == S_OK, "Expected success got 0x%lx error\n", hr);
200
202 if (IsThemeActive())
203 ok (hr == S_FALSE, "Expected S_FALSE got 0x%lx error\n", hr);
204 else
205 skip("Theme not active\n");
207
208
209}
static LONG WINAPI VEHandler_2(PEXCEPTION_POINTERS ExceptionInfo)
BOOL bGotException
static LONG WINAPI VEHandler_1(PEXCEPTION_POINTERS ExceptionInfo)
#define skip(...)
Definition: atltest.h:64
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
BOOL WINAPI IsThemeActive(void)
Definition: system.c:606
#define S_OK
Definition: intsafe.h:52
HRESULT hr
Definition: shlfolder.c:183
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define S_FALSE
Definition: winerror.h:2357
#define E_HANDLE
Definition: winerror.h:2850
#define E_POINTER
Definition: winerror.h:2365
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by START_TEST().

◆ TestProc()

static LRESULT CALLBACK TestProc ( HWND  hwnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 25 of file DrawThemeParentBackground.c.

26{
27 int iwnd = get_iwnd(hwnd);
28
29 if(message > WM_USER || !iwnd || message == WM_GETICON)
31
32 RECORD_MESSAGE(iwnd, message, SENT, 0,0);
34}
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
@ SENT
Definition: msgtrace.h:6
#define DefWindowProc
Definition: ros2win.h:31
Definition: tftpd.h:60
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023

◆ VEHandler_1()

static LONG WINAPI VEHandler_1 ( PEXCEPTION_POINTERS  ExceptionInfo)
static

Definition at line 116 of file DrawThemeParentBackground.c.

117{
118 ok(FALSE, "VEHandler_1 called!\n");
120}
#define EXCEPTION_CONTINUE_SEARCH
Definition: excpt.h:86

Referenced by Test_Params().

◆ VEHandler_2()

static LONG WINAPI VEHandler_2 ( PEXCEPTION_POINTERS  ExceptionInfo)
static

Definition at line 122 of file DrawThemeParentBackground.c.

123{
126}

Referenced by Test_Params().

Variable Documentation

◆ bGotException

◆ draw_parent_chain

MSG_ENTRY draw_parent_chain[]
Initial value:
{0,0}}
#define WM_PRINTCLIENT
Definition: richedit.h:70
#define WM_ERASEBKGND
Definition: winuser.h:1628

Definition at line 49 of file DrawThemeParentBackground.c.

Referenced by Test_Messages().

◆ hWnd1

HWND hWnd1

Definition at line 16 of file DrawThemeParentBackground.c.

Referenced by get_iwnd(), Test_Messages(), and Test_Params().

◆ hWnd2

HWND hWnd2

Definition at line 16 of file DrawThemeParentBackground.c.

Referenced by get_iwnd(), Test_Messages(), and Test_Params().