1 /* Unit test suite for uxtheme API functions
3 * Copyright 2006 Paul Vriens
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #include "wine/test.h"
29 static HTHEME (WINAPI
* pOpenThemeDataEx
)(HWND
, LPCWSTR
, DWORD
);
30 static HPAINTBUFFER (WINAPI
*pBeginBufferedPaint
)(HDC
, const RECT
*, BP_BUFFERFORMAT
, BP_PAINTPARAMS
*, HDC
*);
31 static HRESULT (WINAPI
*pBufferedPaintClear
)(HPAINTBUFFER
, const RECT
*);
32 static HRESULT (WINAPI
*pEndBufferedPaint
)(HPAINTBUFFER
, BOOL
);
33 static HRESULT (WINAPI
*pGetBufferedPaintBits
)(HPAINTBUFFER
, RGBQUAD
**, int *);
34 static HDC (WINAPI
*pGetBufferedPaintDC
)(HPAINTBUFFER
);
35 static HDC (WINAPI
*pGetBufferedPaintTargetDC
)(HPAINTBUFFER
);
36 static HRESULT (WINAPI
*pGetBufferedPaintTargetRect
)(HPAINTBUFFER
, RECT
*);
38 static void init_funcs(void)
40 HMODULE hUxtheme
= GetModuleHandleA("uxtheme.dll");
42 #define UXTHEME_GET_PROC(func) p ## func = (void*)GetProcAddress(hUxtheme, #func)
43 UXTHEME_GET_PROC(BeginBufferedPaint
);
44 UXTHEME_GET_PROC(BufferedPaintClear
);
45 UXTHEME_GET_PROC(EndBufferedPaint
);
46 UXTHEME_GET_PROC(GetBufferedPaintBits
);
47 UXTHEME_GET_PROC(GetBufferedPaintDC
);
48 UXTHEME_GET_PROC(GetBufferedPaintTargetDC
);
49 UXTHEME_GET_PROC(GetBufferedPaintTargetRect
);
50 UXTHEME_GET_PROC(BufferedPaintClear
);
52 UXTHEME_GET_PROC(OpenThemeDataEx
);
53 #undef UXTHEME_GET_PROC
56 static void test_IsThemed(void)
62 bThemeActive
= IsThemeActive();
63 trace("Theming is %s\n", (bThemeActive
) ? "active" : "inactive");
65 bAppThemed
= IsAppThemed();
66 trace("Test executable is %s\n", (bAppThemed
) ? "themed" : "not themed");
68 SetLastError(0xdeadbeef);
69 bTPDefined
= IsThemePartDefined(NULL
, 0 , 0);
70 ok( bTPDefined
== FALSE
, "Expected FALSE\n");
71 ok( GetLastError() == E_HANDLE
,
72 "Expected E_HANDLE, got 0x%08x\n",
76 static void test_GetWindowTheme(void)
82 SetLastError(0xdeadbeef);
83 hTheme
= GetWindowTheme(NULL
);
84 ok( hTheme
== NULL
, "Expected a NULL return, got %p\n", hTheme
);
86 ok( GetLastError() == E_HANDLE
,
87 "Expected E_HANDLE, got 0x%08x\n",
90 /* Only do the bare minimum to get a valid hwnd */
91 hWnd
= CreateWindowExA(0, "static", "", WS_POPUP
, 0,0,100,100,0, 0, 0, NULL
);
94 SetLastError(0xdeadbeef);
95 hTheme
= GetWindowTheme(hWnd
);
96 ok( hTheme
== NULL
, "Expected a NULL return, got %p\n", hTheme
);
97 ok( GetLastError() == 0xdeadbeef,
98 "Expected 0xdeadbeef, got 0x%08x\n",
101 bDestroyed
= DestroyWindow(hWnd
);
103 trace("Window %p couldn't be destroyed : 0x%08x\n",
104 hWnd
, GetLastError());
107 static void test_SetWindowTheme(void)
113 hRes
= SetWindowTheme(NULL
, NULL
, NULL
);
115 ok( hRes
== E_HANDLE
, "Expected E_HANDLE, got 0x%08x\n", hRes
);
117 /* Only do the bare minimum to get a valid hwnd */
118 hWnd
= CreateWindowExA(0, "static", "", WS_POPUP
, 0,0,100,100,0, 0, 0, NULL
);
121 hRes
= SetWindowTheme(hWnd
, NULL
, NULL
);
122 ok( hRes
== S_OK
, "Expected S_OK, got 0x%08x\n", hRes
);
124 bDestroyed
= DestroyWindow(hWnd
);
126 trace("Window %p couldn't be destroyed : 0x%08x\n",
127 hWnd
, GetLastError());
130 static void test_OpenThemeData(void)
132 HTHEME hTheme
, hTheme2
;
139 WCHAR szInvalidClassList
[] = {'D','E','A','D','B','E','E','F', 0 };
140 WCHAR szButtonClassList
[] = {'B','u','t','t','o','n', 0 };
141 WCHAR szButtonClassList2
[] = {'b','U','t','T','o','N', 0 };
142 WCHAR szClassList
[] = {'B','u','t','t','o','n',';','L','i','s','t','B','o','x', 0 };
144 bThemeActive
= IsThemeActive();
147 SetLastError(0xdeadbeef);
148 hTheme
= OpenThemeData(NULL
, NULL
);
149 ok( hTheme
== NULL
, "Expected a NULL return, got %p\n", hTheme
);
150 ok( GetLastError() == E_POINTER
,
151 "Expected GLE() to be E_POINTER, got 0x%08x\n",
154 /* A NULL hWnd and an invalid classlist */
155 SetLastError(0xdeadbeef);
156 hTheme
= OpenThemeData(NULL
, szInvalidClassList
);
157 ok( hTheme
== NULL
, "Expected a NULL return, got %p\n", hTheme
);
159 ok( GetLastError() == E_PROP_ID_UNSUPPORTED
,
160 "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08x\n",
163 SetLastError(0xdeadbeef);
164 hTheme
= OpenThemeData(NULL
, szClassList
);
167 ok( hTheme
!= NULL
, "got NULL, expected a HTHEME handle\n");
169 ok( GetLastError() == ERROR_SUCCESS
,
170 "Expected ERROR_SUCCESS, got 0x%08x\n",
175 ok( hTheme
== NULL
, "Expected a NULL return, got %p\n", hTheme
);
177 ok( GetLastError() == E_PROP_ID_UNSUPPORTED
,
178 "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08x\n",
182 /* Only do the bare minimum to get a valid hdc */
183 hWnd
= CreateWindowExA(0, "static", "", WS_POPUP
, 0,0,100,100,0, 0, 0, NULL
);
186 SetLastError(0xdeadbeef);
187 hTheme
= OpenThemeData(hWnd
, NULL
);
188 ok( hTheme
== NULL
, "Expected a NULL return, got %p\n", hTheme
);
189 ok( GetLastError() == E_POINTER
,
190 "Expected GLE() to be E_POINTER, got 0x%08x\n",
193 SetLastError(0xdeadbeef);
194 hTheme
= OpenThemeData(hWnd
, szInvalidClassList
);
195 ok( hTheme
== NULL
, "Expected a NULL return, got %p\n", hTheme
);
197 ok( GetLastError() == E_PROP_ID_UNSUPPORTED
,
198 "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08x\n",
201 /* Close invalid handle */
202 hRes
= CloseThemeData((HTHEME
)0xdeadbeef);
203 ok( hRes
== E_HANDLE
, "Expected E_HANDLE, got 0x%08x\n", hRes
);
207 SetLastError(0xdeadbeef);
208 hTheme
= OpenThemeData(hWnd
, szButtonClassList
);
209 ok( hTheme
== NULL
, "Expected a NULL return, got %p\n", hTheme
);
211 ok( GetLastError() == E_PROP_ID_UNSUPPORTED
,
212 "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08x\n",
214 skip("No active theme, skipping rest of OpenThemeData tests\n");
218 /* Only do the next checks if we have an active theme */
220 SetLastError(0xdeadbeef);
221 hTheme
= OpenThemeData(hWnd
, szButtonClassList
);
222 ok( hTheme
!= NULL
, "got NULL, expected a HTHEME handle\n");
224 ok( GetLastError() == ERROR_SUCCESS
,
225 "Expected ERROR_SUCCESS, got 0x%08x\n",
228 /* Test with bUtToN instead of Button */
229 SetLastError(0xdeadbeef);
230 hTheme
= OpenThemeData(hWnd
, szButtonClassList2
);
231 ok( hTheme
!= NULL
, "got NULL, expected a HTHEME handle\n");
233 ok( GetLastError() == ERROR_SUCCESS
,
234 "Expected ERROR_SUCCESS, got 0x%08x\n",
237 SetLastError(0xdeadbeef);
238 hTheme
= OpenThemeData(hWnd
, szClassList
);
239 ok( hTheme
!= NULL
, "got NULL, expected a HTHEME handle\n");
241 ok( GetLastError() == ERROR_SUCCESS
,
242 "Expected ERROR_SUCCESS, got 0x%08x\n",
245 /* GetWindowTheme should return the last handle opened by OpenThemeData */
246 SetLastError(0xdeadbeef);
247 hTheme2
= GetWindowTheme(hWnd
);
248 ok( hTheme
== hTheme2
, "Expected the same HTHEME handle (%p<->%p)\n",
250 ok( GetLastError() == 0xdeadbeef,
251 "Expected 0xdeadbeef, got 0x%08x\n",
254 hRes
= CloseThemeData(hTheme
);
255 ok( hRes
== S_OK
, "Expected S_OK, got 0x%08x\n", hRes
);
257 /* Close a second time */
258 hRes
= CloseThemeData(hTheme
);
259 ok( hRes
== S_OK
, "Expected S_OK, got 0x%08x\n", hRes
);
261 /* See if closing makes a difference for GetWindowTheme */
262 SetLastError(0xdeadbeef);
264 hTheme2
= GetWindowTheme(hWnd
);
265 ok( hTheme
== hTheme2
, "Expected the same HTHEME handle (%p<->%p)\n",
267 ok( GetLastError() == 0xdeadbeef,
268 "Expected 0xdeadbeef, got 0x%08x\n",
271 SetLastError(0xdeadbeef);
272 bTPDefined
= IsThemePartDefined(hTheme
, 0 , 0);
275 ok( bTPDefined
== FALSE
, "Expected FALSE\n");
276 ok( GetLastError() == ERROR_SUCCESS
,
277 "Expected ERROR_SUCCESS, got 0x%08x\n",
281 bDestroyed
= DestroyWindow(hWnd
);
283 trace("Window %p couldn't be destroyed : 0x%08x\n",
284 hWnd
, GetLastError());
287 static void test_OpenThemeDataEx(void)
294 WCHAR szInvalidClassList
[] = {'D','E','A','D','B','E','E','F', 0 };
295 WCHAR szButtonClassList
[] = {'B','u','t','t','o','n', 0 };
296 WCHAR szButtonClassList2
[] = {'b','U','t','T','o','N', 0 };
297 WCHAR szClassList
[] = {'B','u','t','t','o','n',';','L','i','s','t','B','o','x', 0 };
299 if (!pOpenThemeDataEx
)
301 win_skip("OpenThemeDataEx not available\n");
305 bThemeActive
= IsThemeActive();
308 SetLastError(0xdeadbeef);
309 hTheme
= pOpenThemeDataEx(NULL
, NULL
, 0);
310 ok( hTheme
== NULL
, "Expected a NULL return, got %p\n", hTheme
);
311 ok( GetLastError() == E_POINTER
,
312 "Expected GLE() to be E_POINTER, got 0x%08x\n",
315 /* A NULL hWnd and an invalid classlist without flags */
316 SetLastError(0xdeadbeef);
317 hTheme
= pOpenThemeDataEx(NULL
, szInvalidClassList
, 0);
318 ok( hTheme
== NULL
, "Expected a NULL return, got %p\n", hTheme
);
320 ok( GetLastError() == E_PROP_ID_UNSUPPORTED
,
321 "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08x\n",
324 SetLastError(0xdeadbeef);
325 hTheme
= pOpenThemeDataEx(NULL
, szClassList
, 0);
328 ok( hTheme
!= NULL
, "got NULL, expected a HTHEME handle\n");
330 ok( GetLastError() == ERROR_SUCCESS
,
331 "Expected ERROR_SUCCESS, got 0x%08x\n",
336 ok( hTheme
== NULL
, "Expected a NULL return, got %p\n", hTheme
);
338 ok( GetLastError() == E_PROP_ID_UNSUPPORTED
,
339 "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08x\n",
343 /* Only do the bare minimum to get a valid hdc */
344 hWnd
= CreateWindowExA(0, "static", "", WS_POPUP
, 0,0,100,100,0, 0, 0, NULL
);
347 SetLastError(0xdeadbeef);
348 hTheme
= pOpenThemeDataEx(hWnd
, NULL
, 0);
349 ok( hTheme
== NULL
, "Expected a NULL return, got %p\n", hTheme
);
350 ok( GetLastError() == E_POINTER
,
351 "Expected GLE() to be E_POINTER, got 0x%08x\n",
354 SetLastError(0xdeadbeef);
355 hTheme
= pOpenThemeDataEx(hWnd
, szInvalidClassList
, 0);
356 ok( hTheme
== NULL
, "Expected a NULL return, got %p\n", hTheme
);
358 ok( GetLastError() == E_PROP_ID_UNSUPPORTED
,
359 "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08x\n",
364 SetLastError(0xdeadbeef);
365 hTheme
= pOpenThemeDataEx(hWnd
, szButtonClassList
, 0);
366 ok( hTheme
== NULL
, "Expected a NULL return, got %p\n", hTheme
);
368 ok( GetLastError() == E_PROP_ID_UNSUPPORTED
,
369 "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08x\n",
371 skip("No active theme, skipping rest of OpenThemeDataEx tests\n");
375 /* Only do the next checks if we have an active theme */
377 SetLastError(0xdeadbeef);
378 hTheme
= pOpenThemeDataEx(hWnd
, szButtonClassList
, 0);
379 ok( hTheme
!= NULL
, "got NULL, expected a HTHEME handle\n");
381 ok( GetLastError() == ERROR_SUCCESS
,
382 "Expected ERROR_SUCCESS, got 0x%08x\n",
385 SetLastError(0xdeadbeef);
386 hTheme
= pOpenThemeDataEx(hWnd
, szButtonClassList
, OTD_FORCE_RECT_SIZING
);
387 ok( hTheme
!= NULL
, "got NULL, expected a HTHEME handle\n");
389 ok( GetLastError() == ERROR_SUCCESS
,
390 "Expected ERROR_SUCCESS, got 0x%08x\n",
393 SetLastError(0xdeadbeef);
394 hTheme
= pOpenThemeDataEx(hWnd
, szButtonClassList
, OTD_NONCLIENT
);
395 ok( hTheme
!= NULL
, "got NULL, expected a HTHEME handle\n");
397 ok( GetLastError() == ERROR_SUCCESS
,
398 "Expected ERROR_SUCCESS, got 0x%08x\n",
401 SetLastError(0xdeadbeef);
402 hTheme
= pOpenThemeDataEx(hWnd
, szButtonClassList
, 0x3);
403 ok( hTheme
!= NULL
, "got NULL, expected a HTHEME handle\n");
405 ok( GetLastError() == ERROR_SUCCESS
,
406 "Expected ERROR_SUCCESS, got 0x%08x\n",
409 /* Test with bUtToN instead of Button */
410 SetLastError(0xdeadbeef);
411 hTheme
= pOpenThemeDataEx(hWnd
, szButtonClassList2
, 0);
412 ok( hTheme
!= NULL
, "got NULL, expected a HTHEME handle\n");
414 ok( GetLastError() == ERROR_SUCCESS
,
415 "Expected ERROR_SUCCESS, got 0x%08x\n",
418 SetLastError(0xdeadbeef);
419 hTheme
= pOpenThemeDataEx(hWnd
, szClassList
, 0);
420 ok( hTheme
!= NULL
, "got NULL, expected a HTHEME handle\n");
422 ok( GetLastError() == ERROR_SUCCESS
,
423 "Expected ERROR_SUCCESS, got 0x%08x\n",
426 bDestroyed
= DestroyWindow(hWnd
);
428 trace("Window %p couldn't be destroyed : 0x%08x\n",
429 hWnd
, GetLastError());
432 static void test_GetCurrentThemeName(void)
436 WCHAR currentTheme
[MAX_PATH
];
437 WCHAR currentColor
[MAX_PATH
];
438 WCHAR currentSize
[MAX_PATH
];
440 bThemeActive
= IsThemeActive();
443 hRes
= GetCurrentThemeName(NULL
, 0, NULL
, 0, NULL
, 0);
445 ok( hRes
== S_OK
, "Expected S_OK, got 0x%08x\n", hRes
);
447 ok( hRes
== E_PROP_ID_UNSUPPORTED
, "Expected E_PROP_ID_UNSUPPORTED, got 0x%08x\n", hRes
);
449 /* Number of characters given is 0 */
450 hRes
= GetCurrentThemeName(currentTheme
, 0, NULL
, 0, NULL
, 0);
452 ok( hRes
== S_OK
|| broken(hRes
== E_FAIL
/* WinXP SP1 */), "Expected S_OK, got 0x%08x\n", hRes
);
454 ok( hRes
== E_PROP_ID_UNSUPPORTED
, "Expected E_PROP_ID_UNSUPPORTED, got 0x%08x\n", hRes
);
456 hRes
= GetCurrentThemeName(currentTheme
, 2, NULL
, 0, NULL
, 0);
459 ok(hRes
== E_NOT_SUFFICIENT_BUFFER
||
460 broken(hRes
== E_FAIL
/* WinXP SP1 */),
461 "Expected E_NOT_SUFFICIENT_BUFFER, got 0x%08x\n", hRes
);
463 ok( hRes
== E_PROP_ID_UNSUPPORTED
, "Expected E_PROP_ID_UNSUPPORTED, got 0x%08x\n", hRes
);
465 /* The same is true if the number of characters is too small for Color and/or Size */
466 hRes
= GetCurrentThemeName(currentTheme
, sizeof(currentTheme
) / sizeof(WCHAR
),
468 currentSize
, sizeof(currentSize
) / sizeof(WCHAR
));
471 ok(hRes
== E_NOT_SUFFICIENT_BUFFER
||
472 broken(hRes
== E_FAIL
/* WinXP SP1 */),
473 "Expected E_NOT_SUFFICIENT_BUFFER, got 0x%08x\n", hRes
);
475 ok( hRes
== E_PROP_ID_UNSUPPORTED
, "Expected E_PROP_ID_UNSUPPORTED, got 0x%08x\n", hRes
);
477 /* Given number of characters is correct */
478 hRes
= GetCurrentThemeName(currentTheme
, sizeof(currentTheme
) / sizeof(WCHAR
), NULL
, 0, NULL
, 0);
480 ok( hRes
== S_OK
, "Expected S_OK, got 0x%08x\n", hRes
);
482 ok( hRes
== E_PROP_ID_UNSUPPORTED
, "Expected E_PROP_ID_UNSUPPORTED, got 0x%08x\n", hRes
);
484 /* Given number of characters for the theme name is too large */
485 hRes
= GetCurrentThemeName(currentTheme
, sizeof(currentTheme
), NULL
, 0, NULL
, 0);
487 ok( hRes
== E_POINTER
|| hRes
== S_OK
, "Expected E_POINTER or S_OK, got 0x%08x\n", hRes
);
489 ok( hRes
== E_PROP_ID_UNSUPPORTED
||
490 hRes
== E_POINTER
, /* win2k3 */
491 "Expected E_PROP_ID_UNSUPPORTED, got 0x%08x\n", hRes
);
493 /* The too large case is only for the theme name, not for color name or size name */
494 hRes
= GetCurrentThemeName(currentTheme
, sizeof(currentTheme
) / sizeof(WCHAR
),
495 currentColor
, sizeof(currentTheme
),
496 currentSize
, sizeof(currentSize
) / sizeof(WCHAR
));
498 ok( hRes
== S_OK
, "Expected S_OK, got 0x%08x\n", hRes
);
500 ok( hRes
== E_PROP_ID_UNSUPPORTED
, "Expected E_PROP_ID_UNSUPPORTED, got 0x%08x\n", hRes
);
502 hRes
= GetCurrentThemeName(currentTheme
, sizeof(currentTheme
) / sizeof(WCHAR
),
503 currentColor
, sizeof(currentTheme
) / sizeof(WCHAR
),
504 currentSize
, sizeof(currentSize
));
506 ok( hRes
== S_OK
, "Expected S_OK, got 0x%08x\n", hRes
);
508 ok( hRes
== E_PROP_ID_UNSUPPORTED
, "Expected E_PROP_ID_UNSUPPORTED, got 0x%08x\n", hRes
);
511 hRes
= GetCurrentThemeName(currentTheme
, sizeof(currentTheme
) / sizeof(WCHAR
),
512 currentColor
, sizeof(currentColor
) / sizeof(WCHAR
),
513 currentSize
, sizeof(currentSize
) / sizeof(WCHAR
));
515 ok( hRes
== S_OK
, "Expected S_OK, got 0x%08x\n", hRes
);
517 ok( hRes
== E_PROP_ID_UNSUPPORTED
, "Expected E_PROP_ID_UNSUPPORTED, got 0x%08x\n", hRes
);
520 static void test_CloseThemeData(void)
524 hRes
= CloseThemeData(NULL
);
525 ok( hRes
== E_HANDLE
, "Expected E_HANDLE, got 0x%08x\n", hRes
);
526 hRes
= CloseThemeData(INVALID_HANDLE_VALUE
);
527 ok( hRes
== E_HANDLE
, "Expected E_HANDLE, got 0x%08x\n", hRes
);
530 static void test_buffer_dc_props(HDC hdc
, const RECT
*rect
)
532 static const XFORM ident
= { 1.0f
, 0.0f
, 0.0f
, 1.0f
, 0.0f
, 0.0f
};
538 ret
= GetWorldTransform(hdc
, &xform
);
539 ok(ret
, "Failed to get world transform\n");
540 ok(!memcmp(&xform
, &ident
, sizeof(xform
)), "Unexpected world transform\n");
542 ret
= GetViewportOrgEx(hdc
, &org
);
543 ok(ret
, "Failed to get vport origin\n");
544 ok(org
.x
== 0 && org
.y
== 0, "Unexpected vport origin\n");
546 ret
= GetWindowOrgEx(hdc
, &org
);
547 ok(ret
, "Failed to get vport origin\n");
548 ok(org
.x
== rect
->left
&& org
.y
== rect
->top
, "Unexpected window origin\n");
550 ret
= GetClipBox(hdc
, &box
);
551 ok(ret
, "Failed to get clip box\n");
552 ok(box
.left
== rect
->left
&& box
.top
== rect
->top
, "Unexpected clip box\n");
554 ok(GetGraphicsMode(hdc
) == GM_COMPATIBLE
, "wrong graphics mode\n");
557 static void test_buffered_paint(void)
559 HDC target
, src
, hdc
, screen_dc
;
560 BP_PAINTPARAMS params
= { 0 };
561 BP_BUFFERFORMAT format
;
569 if (!pBeginBufferedPaint
)
571 win_skip("Buffered painting API is not supported.\n");
575 buffer
= pBeginBufferedPaint(NULL
, NULL
, BPBF_COMPATIBLEBITMAP
,
577 ok(buffer
== NULL
, "Unexpected buffer %p\n", buffer
);
579 target
= CreateCompatibleDC(0);
580 buffer
= pBeginBufferedPaint(target
, NULL
, BPBF_COMPATIBLEBITMAP
,
582 ok(buffer
== NULL
, "Unexpected buffer %p\n", buffer
);
584 params
.cbSize
= sizeof(params
);
585 buffer
= pBeginBufferedPaint(target
, NULL
, BPBF_COMPATIBLEBITMAP
,
587 ok(buffer
== NULL
, "Unexpected buffer %p\n", buffer
);
589 src
= (void *)0xdeadbeef;
590 buffer
= pBeginBufferedPaint(target
, NULL
, BPBF_COMPATIBLEBITMAP
,
592 ok(buffer
== NULL
, "Unexpected buffer %p\n", buffer
);
593 ok(src
== NULL
, "Unexpected buffered dc %p\n", src
);
595 /* target rect is mandatory */
597 src
= (void *)0xdeadbeef;
598 buffer
= pBeginBufferedPaint(target
, &rect
, BPBF_COMPATIBLEBITMAP
,
600 ok(buffer
== NULL
, "Unexpected buffer %p\n", buffer
);
601 ok(src
== NULL
, "Unexpected buffered dc %p\n", src
);
603 /* inverted rectangle */
604 SetRect(&rect
, 10, 0, 5, 5);
605 src
= (void *)0xdeadbeef;
606 buffer
= pBeginBufferedPaint(target
, &rect
, BPBF_COMPATIBLEBITMAP
,
608 ok(buffer
== NULL
, "Unexpected buffer %p\n", buffer
);
609 ok(src
== NULL
, "Unexpected buffered dc %p\n", src
);
611 SetRect(&rect
, 0, 10, 5, 0);
612 src
= (void *)0xdeadbeef;
613 buffer
= pBeginBufferedPaint(target
, &rect
, BPBF_COMPATIBLEBITMAP
,
615 ok(buffer
== NULL
, "Unexpected buffer %p\n", buffer
);
616 ok(src
== NULL
, "Unexpected buffered dc %p\n", src
);
618 /* valid rectangle, no target dc */
619 SetRect(&rect
, 0, 0, 5, 5);
620 src
= (void *)0xdeadbeef;
621 buffer
= pBeginBufferedPaint(NULL
, &rect
, BPBF_COMPATIBLEBITMAP
,
623 ok(buffer
== NULL
, "Unexpected buffer %p\n", buffer
);
624 ok(src
== NULL
, "Unexpected buffered dc %p\n", src
);
626 SetRect(&rect
, 0, 0, 5, 5);
628 buffer
= pBeginBufferedPaint(target
, &rect
, BPBF_COMPATIBLEBITMAP
,
630 ok(buffer
!= NULL
, "Unexpected buffer %p\n", buffer
);
631 ok(src
!= NULL
, "Expected buffered dc\n");
632 hr
= pEndBufferedPaint(buffer
, FALSE
);
633 ok(hr
== S_OK
, "Unexpected return code %#x\n", hr
);
635 SetRect(&rect
, 0, 0, 5, 5);
636 buffer
= pBeginBufferedPaint(target
, &rect
, BPBF_COMPATIBLEBITMAP
,
638 ok(buffer
!= NULL
, "Unexpected buffer %p\n", buffer
);
641 hr
= pBufferedPaintClear(NULL
, NULL
);
643 ok(hr
== E_FAIL
, "Unexpected return code %#x\n", hr
);
645 hr
= pBufferedPaintClear(buffer
, NULL
);
647 ok(hr
== S_OK
, "Unexpected return code %#x\n", hr
);
649 /* access buffer attributes */
650 hdc
= pGetBufferedPaintDC(buffer
);
651 ok(hdc
== src
, "Unexpected hdc, %p, buffered dc %p\n", hdc
, src
);
653 hdc
= pGetBufferedPaintTargetDC(buffer
);
654 ok(hdc
== target
, "Unexpected target hdc %p, original %p\n", hdc
, target
);
656 hr
= pGetBufferedPaintTargetRect(NULL
, NULL
);
657 ok(hr
== E_POINTER
, "Unexpected return code %#x\n", hr
);
659 hr
= pGetBufferedPaintTargetRect(buffer
, NULL
);
660 ok(hr
== E_POINTER
, "Unexpected return code %#x\n", hr
);
662 hr
= pGetBufferedPaintTargetRect(NULL
, &rect2
);
663 ok(hr
== E_FAIL
, "Unexpected return code %#x\n", hr
);
665 SetRectEmpty(&rect2
);
666 hr
= pGetBufferedPaintTargetRect(buffer
, &rect2
);
667 ok(hr
== S_OK
, "Unexpected return code %#x\n", hr
);
668 ok(EqualRect(&rect
, &rect2
), "Wrong target rect\n");
670 hr
= pEndBufferedPaint(buffer
, FALSE
);
671 ok(hr
== S_OK
, "Unexpected return code %#x\n", hr
);
673 /* invalid buffer handle */
674 hr
= pEndBufferedPaint(NULL
, FALSE
);
675 ok(hr
== E_INVALIDARG
, "Unexpected return code %#x\n", hr
);
677 hdc
= pGetBufferedPaintDC(NULL
);
678 ok(hdc
== NULL
, "Unexpected hdc %p\n", hdc
);
680 hdc
= pGetBufferedPaintTargetDC(NULL
);
681 ok(hdc
== NULL
, "Unexpected target hdc %p\n", hdc
);
683 hr
= pGetBufferedPaintTargetRect(NULL
, &rect2
);
684 ok(hr
== E_FAIL
, "Unexpected return code %#x\n", hr
);
686 hr
= pGetBufferedPaintTargetRect(NULL
, NULL
);
687 ok(hr
== E_POINTER
, "Unexpected return code %#x\n", hr
);
689 bits
= (void *)0xdeadbeef;
691 hr
= pGetBufferedPaintBits(NULL
, &bits
, &row
);
692 ok(hr
== E_FAIL
, "Unexpected return code %#x\n", hr
);
693 ok(row
== 10, "Unexpected row count %d\n", row
);
694 ok(bits
== (void *)0xdeadbeef, "Unepexpected data pointer %p\n", bits
);
696 hr
= pGetBufferedPaintBits(NULL
, NULL
, NULL
);
697 ok(hr
== E_POINTER
, "Unexpected return code %#x\n", hr
);
699 hr
= pGetBufferedPaintBits(NULL
, &bits
, NULL
);
700 ok(hr
== E_POINTER
, "Unexpected return code %#x\n", hr
);
702 hr
= pGetBufferedPaintBits(NULL
, NULL
, &row
);
703 ok(hr
== E_POINTER
, "Unexpected return code %#x\n", hr
);
705 screen_dc
= GetDC(0);
707 hdc
= CreateCompatibleDC(screen_dc
);
708 ok(hdc
!= NULL
, "Failed to create a DC\n");
709 hbm
= CreateCompatibleBitmap(screen_dc
, 64, 64);
710 ok(hbm
!= NULL
, "Failed to create a bitmap\n");
711 SelectObject(hdc
, hbm
);
713 ReleaseDC(0, screen_dc
);
715 SetRect(&rect
, 1, 2, 34, 56);
717 buffer
= pBeginBufferedPaint(hdc
, &rect
, BPBF_COMPATIBLEBITMAP
, NULL
, &src
);
718 test_buffer_dc_props(src
, &rect
);
719 hr
= pEndBufferedPaint(buffer
, FALSE
);
720 ok(hr
== S_OK
, "Unexpected return code %#x\n", hr
);
725 buffer
= pBeginBufferedPaint(target
, &rect
, BPBF_COMPATIBLEBITMAP
, NULL
, &src
);
726 test_buffer_dc_props(src
, &rect
);
727 hr
= pEndBufferedPaint(buffer
, FALSE
);
728 ok(hr
== S_OK
, "Unexpected return code %#x\n", hr
);
730 /* access buffer bits */
731 for (format
= BPBF_COMPATIBLEBITMAP
; format
<= BPBF_TOPDOWNMONODIB
; format
++)
733 buffer
= pBeginBufferedPaint(target
, &rect
, format
, ¶ms
, &src
);
735 /* only works for DIB buffers */
738 hr
= pGetBufferedPaintBits(buffer
, &bits
, &row
);
739 if (format
== BPBF_COMPATIBLEBITMAP
)
740 ok(hr
== E_FAIL
, "Unexpected return code %#x\n", hr
);
743 ok(hr
== S_OK
, "Unexpected return code %#x\n", hr
);
744 ok(bits
!= NULL
, "Bitmap bits %p\n", bits
);
745 ok(row
>= (rect
.right
- rect
.left
), "format %d: bitmap width %d\n", format
, row
);
748 hr
= pEndBufferedPaint(buffer
, FALSE
);
749 ok(hr
== S_OK
, "Unexpected return code %#x\n", hr
);
759 /* No real functional theme API tests will be done (yet). The current tests
760 * only show input/return behaviour
764 test_GetWindowTheme();
765 test_SetWindowTheme();
766 test_OpenThemeData();
767 test_OpenThemeDataEx();
768 test_GetCurrentThemeName();
769 test_CloseThemeData();
770 test_buffered_paint();