ReactOS  0.4.13-dev-551-gf37fb1f
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 }
#define PeekMessage
Definition: winuser.h:5696
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
Definition: msgtrace.h:7
#define WM_USER
Definition: winuser.h:1856
#define msg(x)
Definition: auth_time.c:54
#define RECORD_MESSAGE(...)
Definition: msgtrace.h:60
#define PM_REMOVE
Definition: winuser.h:1182
static int get_iwnd(HWND hWnd)

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 205 of file DrawThemeParentBackground.c.

206 {
207  Test_Messages();
208  Test_Params();
209 }
void Test_Messages()
void Test_Params()

◆ 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 
66  FlushMessages();
67  EMPTY_CACHE();
68 
69  hdc = GetDC(hWnd1);
70 
72  FlushMessages();
74 
76  FlushMessages();
78 
83 
84  FlushMessages();
85  EMPTY_CACHE();
86 
88  FlushMessages();
90 
92  FlushMessages();
94 
96  FlushMessages();
98 
100  FlushMessages();
102 
103  memset(&rc, 0, sizeof(rc));
104 
106  FlushMessages();
108 
110  FlushMessages();
112 }
HDC WINAPI GetDC(_In_opt_ HWND)
MSG_ENTRY draw_parent_chain[]
static HDC
Definition: imagelist.c:92
BOOL WINAPI UpdateWindow(_In_ HWND)
#define WS_CHILD
Definition: pedump.c:617
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define CreateWindowW(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4185
static void FlushMessages()
static LRESULT CALLBACK TestProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
#define SW_SHOW
Definition: winuser.h:769
static __inline ATOM RegisterSimpleClass(WNDPROC lpfnWndProc, LPCWSTR lpszClassName)
HRESULT WINAPI DrawThemeParentBackground(HWND hwnd, HDC hdc, RECT *prc)
Definition: draw.c:72
#define COMPARE_CACHE(msg_chain)
Definition: msgtrace.h:57
static const WCHAR L[]
Definition: oid.c:1250
HDC hdc
Definition: main.c:9
#define EMPTY_CACHE()
Definition: msgtrace.h:59
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define WS_VISIBLE
Definition: pedump.c:620
#define memset(x, y, z)
Definition: compat.h:39
MSG_ENTRY empty_chain[]
Definition: msgtrace.c:20

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 
152  RegisterSimpleClass(DefWindowProcW, L"testClass2");
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  ok (hr == S_FALSE, "Expected S_FALSE got 0x%lx error\n", hr);
190 
191  ReleaseDC(hWnd1, hdc);
192  hdc = GetDC(hWnd2);
193  ok (hdc != NULL, "Expected GetDC to succeed\n");
194 
196  ok (hr == S_OK, "Expected success got 0x%lx error\n", hr);
197 
199  ok (hr == S_FALSE, "Expected S_FALSE got 0x%lx error\n", hr);
200  ReleaseDC(hWnd2, hdc);
201 
202 
203 }
#define TRUE
Definition: types.h:120
#define E_HANDLE
Definition: winerror.h:2850
HRESULT hr
Definition: shlfolder.c:183
HDC WINAPI GetDC(_In_opt_ HWND)
static HDC
Definition: imagelist.c:92
BOOL WINAPI UpdateWindow(_In_ HWND)
#define WS_CHILD
Definition: pedump.c:617
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define CreateWindowW(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4185
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
uint32_t ULONG_PTR
Definition: typedefs.h:63
static LONG WINAPI VEHandler_1(PEXCEPTION_POINTERS ExceptionInfo)
BOOL bGotException
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define ok(value,...)
#define S_FALSE
Definition: winerror.h:2357
smooth NULL
Definition: ftsmooth.c:416
#define SW_SHOW
Definition: winuser.h:769
static __inline ATOM RegisterSimpleClass(WNDPROC lpfnWndProc, LPCWSTR lpszClassName)
HRESULT WINAPI DrawThemeParentBackground(HWND hwnd, HDC hdc, RECT *prc)
Definition: draw.c:72
LONG HRESULT
Definition: typedefs.h:77
static const WCHAR L[]
Definition: oid.c:1250
HDC hdc
Definition: main.c:9
#define S_OK
Definition: intsafe.h:59
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define E_POINTER
Definition: winerror.h:2365
static LONG WINAPI VEHandler_2(PEXCEPTION_POINTERS ExceptionInfo)
#define WS_VISIBLE
Definition: pedump.c:620

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 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
Definition: tftpd.h:59
WPARAM wParam
Definition: combotst.c:138
#define DefWindowProc
Definition: ros2win.h:31
#define WM_USER
Definition: winuser.h:1856
Definition: msgtrace.h:6
#define RECORD_MESSAGE(...)
Definition: msgtrace.h:60
LPARAM lParam
Definition: combotst.c:139
static int get_iwnd(HWND hWnd)

Referenced by Test_Messages().

◆ 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
#define ok(value,...)

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 }
#define TRUE
Definition: types.h:120
BOOL bGotException
#define EXCEPTION_CONTINUE_SEARCH
Definition: excpt.h:86

Referenced by Test_Params().

Variable Documentation

◆ bGotException

BOOL bGotException

Definition at line 114 of file DrawThemeParentBackground.c.

Referenced by Test_ExtCreatePen_Helper(), Test_Params(), and VEHandler_2().

◆ 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:1607

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().