ReactOS 0.4.15-dev-8419-g7f0e8a3
DrawThemeParentBackground.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for DrawThemeParentBackground
5 * PROGRAMMERS: Giannis Adamopoulos
6 */
7
8#include <apitest.h>
9#include <stdio.h>
10#include <windows.h>
11#include <uxtheme.h>
12#include <undocuser.h>
13#include <msgtrace.h>
14#include <user32testhelpers.h>
15
17
18static int get_iwnd(HWND hWnd)
19{
20 if(hWnd == hWnd1) return 1;
21 else if(hWnd == hWnd2) return 2;
22 else return 0;
23}
24
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}
35
36static void FlushMessages()
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}
48
50 {1, WM_PRINTCLIENT},
51 {0,0}};
52
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}
113
115
117{
118 ok(FALSE, "VEHandler_1 called!\n");
120}
121
123{
126}
127
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}
210
212{
214 Test_Params();
215}
void Test_Params()
static void FlushMessages()
static LONG WINAPI VEHandler_2(PEXCEPTION_POINTERS ExceptionInfo)
BOOL bGotException
static int get_iwnd(HWND hWnd)
MSG_ENTRY draw_parent_chain[]
void Test_Messages()
static LONG WINAPI VEHandler_1(PEXCEPTION_POINTERS ExceptionInfo)
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define START_TEST(x)
Definition: atltest.h:75
#define msg(x)
Definition: auth_time.c:54
HWND hWnd
Definition: settings.c:17
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define CALLBACK
Definition: compat.h:35
HRESULT WINAPI DrawThemeParentBackground(HWND hwnd, HDC hdc, RECT *prc)
Definition: draw.c:72
BOOL WINAPI IsThemeActive(void)
Definition: system.c:606
unsigned int BOOL
Definition: ntddk_ex.h:94
#define EXCEPTION_CONTINUE_SEARCH
Definition: excpt.h:86
#define S_OK
Definition: intsafe.h:52
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:92
MSG_ENTRY empty_chain[]
Definition: msgtrace.c:20
#define EMPTY_CACHE()
Definition: msgtrace.h:59
#define RECORD_MESSAGE(...)
Definition: msgtrace.h:60
#define COMPARE_CACHE(msg_chain)
Definition: msgtrace.h:57
@ POST
Definition: msgtrace.h:7
@ SENT
Definition: msgtrace.h:6
unsigned int UINT
Definition: ndis.h:50
#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
long LONG
Definition: pedump.c:60
#define TestProc(n)
Definition: queuetest.c:15
#define WM_PRINTCLIENT
Definition: richedit.h:70
#define DefWindowProc
Definition: ros2win.h:31
#define memset(x, y, z)
Definition: compat.h:39
HRESULT hr
Definition: shlfolder.c:183
Definition: msgtrace.h:15
Definition: tftpd.h:60
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
uint32_t ULONG_PTR
Definition: typedefs.h:65
static __inline ATOM RegisterSimpleClass(WNDPROC lpfnWndProc, LPCWSTR lpszClassName)
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
UINT_PTR WPARAM
Definition: windef.h:207
#define WINAPI
Definition: msvc.h:6
#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)
#define WM_ERASEBKGND
Definition: winuser.h:1625
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define PM_REMOVE
Definition: winuser.h:1196
BOOL WINAPI UpdateWindow(_In_ HWND)
#define PeekMessage
Definition: winuser.h:5839
HDC WINAPI GetDC(_In_opt_ HWND)
#define CreateWindowW(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4316
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
#define WM_USER
Definition: winuser.h:1895
#define SW_SHOW
Definition: winuser.h:775