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)
81 SetLastError(0xdeadbeef);
82 hTheme
= GetWindowTheme(NULL
);
83 ok( hTheme
== NULL
, "Expected a NULL return, got %p\n", hTheme
);
85 ok( GetLastError() == E_HANDLE
,
86 "Expected E_HANDLE, got 0x%08x\n",
89 /* Only do the bare minimum to get a valid hwnd */
90 hWnd
= CreateWindowExA(0, "static", "", WS_POPUP
, 0,0,100,100,0, 0, 0, NULL
);
91 ok(hWnd
!= NULL
, "Failed to create a test window.\n");
93 SetLastError(0xdeadbeef);
94 hTheme
= GetWindowTheme(hWnd
);
95 ok( hTheme
== NULL
, "Expected a NULL return, got %p\n", hTheme
);
96 ok( GetLastError() == 0xdeadbeef,
97 "Expected 0xdeadbeef, got 0x%08x\n",
103 static void test_SetWindowTheme(void)
108 hRes
= SetWindowTheme(NULL
, NULL
, NULL
);
110 ok( hRes
== E_HANDLE
, "Expected E_HANDLE, got 0x%08x\n", hRes
);
112 /* Only do the bare minimum to get a valid hwnd */
113 hWnd
= CreateWindowExA(0, "static", "", WS_POPUP
, 0,0,100,100,0, 0, 0, NULL
);
114 ok(hWnd
!= NULL
, "Failed to create a test window.\n");
116 hRes
= SetWindowTheme(hWnd
, NULL
, NULL
);
117 ok( hRes
== S_OK
, "Expected S_OK, got 0x%08x\n", hRes
);
122 static void test_OpenThemeData(void)
124 HTHEME hTheme
, hTheme2
;
130 const WCHAR szInvalidClassList
[] = L
"DEADBEEF";
131 const WCHAR szButtonClassList
[] = L
"Button";
132 const WCHAR szButtonClassList2
[] = L
"bUtToN";
133 const WCHAR szClassList
[] = L
"Button;ListBox";
135 bThemeActive
= IsThemeActive();
138 SetLastError(0xdeadbeef);
139 hTheme
= OpenThemeData(NULL
, NULL
);
140 ok( hTheme
== NULL
, "Expected a NULL return, got %p\n", hTheme
);
141 ok( GetLastError() == E_POINTER
,
142 "Expected GLE() to be E_POINTER, got 0x%08x\n",
145 /* A NULL hWnd and an invalid classlist */
146 SetLastError(0xdeadbeef);
147 hTheme
= OpenThemeData(NULL
, szInvalidClassList
);
148 ok( hTheme
== NULL
, "Expected a NULL return, got %p\n", hTheme
);
150 ok( GetLastError() == E_PROP_ID_UNSUPPORTED
,
151 "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08x\n",
154 SetLastError(0xdeadbeef);
155 hTheme
= OpenThemeData(NULL
, szClassList
);
158 ok( hTheme
!= NULL
, "got NULL, expected a HTHEME handle\n");
160 ok( GetLastError() == ERROR_SUCCESS
,
161 "Expected ERROR_SUCCESS, got 0x%08x\n",
166 ok( hTheme
== NULL
, "Expected a NULL return, got %p\n", hTheme
);
168 ok( GetLastError() == E_PROP_ID_UNSUPPORTED
,
169 "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08x\n",
173 /* Only do the bare minimum to get a valid hdc */
174 hWnd
= CreateWindowExA(0, "static", "", WS_POPUP
, 0,0,100,100,0, 0, 0, NULL
);
177 SetLastError(0xdeadbeef);
178 hTheme
= OpenThemeData(hWnd
, NULL
);
179 ok( hTheme
== NULL
, "Expected a NULL return, got %p\n", hTheme
);
180 ok( GetLastError() == E_POINTER
,
181 "Expected GLE() to be E_POINTER, got 0x%08x\n",
184 SetLastError(0xdeadbeef);
185 hTheme
= OpenThemeData(hWnd
, szInvalidClassList
);
186 ok( hTheme
== NULL
, "Expected a NULL return, got %p\n", hTheme
);
188 ok( GetLastError() == E_PROP_ID_UNSUPPORTED
,
189 "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08x\n",
194 SetLastError(0xdeadbeef);
195 hTheme
= OpenThemeData(hWnd
, szButtonClassList
);
196 ok( hTheme
== NULL
, "Expected a NULL return, got %p\n", hTheme
);
198 ok( GetLastError() == E_PROP_ID_UNSUPPORTED
,
199 "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08x\n",
201 skip("No active theme, skipping rest of OpenThemeData tests\n");
205 /* Only do the next checks if we have an active theme */
207 SetLastError(0xdeadbeef);
208 hTheme
= OpenThemeData(hWnd
, szButtonClassList
);
209 ok( hTheme
!= NULL
, "got NULL, expected a HTHEME handle\n");
211 ok( GetLastError() == ERROR_SUCCESS
,
212 "Expected ERROR_SUCCESS, got 0x%08x\n",
215 /* Test with bUtToN instead of Button */
216 SetLastError(0xdeadbeef);
217 hTheme
= OpenThemeData(hWnd
, szButtonClassList2
);
218 ok( hTheme
!= NULL
, "got NULL, expected a HTHEME handle\n");
220 ok( GetLastError() == ERROR_SUCCESS
,
221 "Expected ERROR_SUCCESS, got 0x%08x\n",
224 SetLastError(0xdeadbeef);
225 hTheme
= OpenThemeData(hWnd
, szClassList
);
226 ok( hTheme
!= NULL
, "got NULL, expected a HTHEME handle\n");
228 ok( GetLastError() == ERROR_SUCCESS
,
229 "Expected ERROR_SUCCESS, got 0x%08x\n",
232 /* GetWindowTheme should return the last handle opened by OpenThemeData */
233 SetLastError(0xdeadbeef);
234 hTheme2
= GetWindowTheme(hWnd
);
235 ok( hTheme
== hTheme2
, "Expected the same HTHEME handle (%p<->%p)\n",
237 ok( GetLastError() == 0xdeadbeef,
238 "Expected 0xdeadbeef, got 0x%08x\n",
241 hRes
= CloseThemeData(hTheme
);
242 ok( hRes
== S_OK
, "Expected S_OK, got 0x%08x\n", hRes
);
244 /* Close a second time */
245 hRes
= CloseThemeData(hTheme
);
246 ok( hRes
== S_OK
, "Expected S_OK, got 0x%08x\n", hRes
);
248 /* See if closing makes a difference for GetWindowTheme */
249 SetLastError(0xdeadbeef);
251 hTheme2
= GetWindowTheme(hWnd
);
252 ok( hTheme
== hTheme2
, "Expected the same HTHEME handle (%p<->%p)\n",
254 ok( GetLastError() == 0xdeadbeef,
255 "Expected 0xdeadbeef, got 0x%08x\n",
258 SetLastError(0xdeadbeef);
259 bTPDefined
= IsThemePartDefined(hTheme
, 0 , 0);
262 ok( bTPDefined
== FALSE
, "Expected FALSE\n");
263 ok( GetLastError() == ERROR_SUCCESS
,
264 "Expected ERROR_SUCCESS, got 0x%08x\n",
271 static void test_OpenThemeDataEx(void)
277 const WCHAR szInvalidClassList
[] = L
"DEADBEEF";
278 const WCHAR szButtonClassList
[] = L
"Button";
279 const WCHAR szButtonClassList2
[] = L
"bUtToN";
280 const WCHAR szClassList
[] = L
"Button;ListBox";
282 if (!pOpenThemeDataEx
)
284 win_skip("OpenThemeDataEx not available\n");
288 bThemeActive
= IsThemeActive();
291 SetLastError(0xdeadbeef);
292 hTheme
= pOpenThemeDataEx(NULL
, NULL
, 0);
293 ok( hTheme
== NULL
, "Expected a NULL return, got %p\n", hTheme
);
294 ok( GetLastError() == E_POINTER
,
295 "Expected GLE() to be E_POINTER, got 0x%08x\n",
298 /* A NULL hWnd and an invalid classlist without flags */
299 SetLastError(0xdeadbeef);
300 hTheme
= pOpenThemeDataEx(NULL
, szInvalidClassList
, 0);
301 ok( hTheme
== NULL
, "Expected a NULL return, got %p\n", hTheme
);
303 ok( GetLastError() == E_PROP_ID_UNSUPPORTED
,
304 "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08x\n",
307 SetLastError(0xdeadbeef);
308 hTheme
= pOpenThemeDataEx(NULL
, szClassList
, 0);
311 ok( hTheme
!= NULL
, "got NULL, expected a HTHEME handle\n");
313 ok( GetLastError() == ERROR_SUCCESS
,
314 "Expected ERROR_SUCCESS, got 0x%08x\n",
319 ok( hTheme
== NULL
, "Expected a NULL return, got %p\n", hTheme
);
321 ok( GetLastError() == E_PROP_ID_UNSUPPORTED
,
322 "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08x\n",
326 /* Only do the bare minimum to get a valid hdc */
327 hWnd
= CreateWindowExA(0, "static", "", WS_POPUP
, 0,0,100,100,0, 0, 0, NULL
);
330 SetLastError(0xdeadbeef);
331 hTheme
= pOpenThemeDataEx(hWnd
, NULL
, 0);
332 ok( hTheme
== NULL
, "Expected a NULL return, got %p\n", hTheme
);
333 ok( GetLastError() == E_POINTER
,
334 "Expected GLE() to be E_POINTER, got 0x%08x\n",
337 SetLastError(0xdeadbeef);
338 hTheme
= pOpenThemeDataEx(hWnd
, szInvalidClassList
, 0);
339 ok( hTheme
== NULL
, "Expected a NULL return, got %p\n", hTheme
);
341 ok( GetLastError() == E_PROP_ID_UNSUPPORTED
,
342 "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08x\n",
347 SetLastError(0xdeadbeef);
348 hTheme
= pOpenThemeDataEx(hWnd
, szButtonClassList
, 0);
349 ok( hTheme
== NULL
, "Expected a NULL return, got %p\n", hTheme
);
351 ok( GetLastError() == E_PROP_ID_UNSUPPORTED
,
352 "Expected GLE() to be E_PROP_ID_UNSUPPORTED, got 0x%08x\n",
354 skip("No active theme, skipping rest of OpenThemeDataEx tests\n");
358 /* Only do the next checks if we have an active theme */
360 SetLastError(0xdeadbeef);
361 hTheme
= pOpenThemeDataEx(hWnd
, szButtonClassList
, 0);
362 ok( hTheme
!= NULL
, "got NULL, expected a HTHEME handle\n");
364 ok( GetLastError() == ERROR_SUCCESS
,
365 "Expected ERROR_SUCCESS, got 0x%08x\n",
368 SetLastError(0xdeadbeef);
369 hTheme
= pOpenThemeDataEx(hWnd
, szButtonClassList
, OTD_FORCE_RECT_SIZING
);
370 ok( hTheme
!= NULL
, "got NULL, expected a HTHEME handle\n");
372 ok( GetLastError() == ERROR_SUCCESS
,
373 "Expected ERROR_SUCCESS, got 0x%08x\n",
376 SetLastError(0xdeadbeef);
377 hTheme
= pOpenThemeDataEx(hWnd
, szButtonClassList
, OTD_NONCLIENT
);
378 ok( hTheme
!= NULL
, "got NULL, expected a HTHEME handle\n");
380 ok( GetLastError() == ERROR_SUCCESS
,
381 "Expected ERROR_SUCCESS, got 0x%08x\n",
384 SetLastError(0xdeadbeef);
385 hTheme
= pOpenThemeDataEx(hWnd
, szButtonClassList
, 0x3);
386 ok( hTheme
!= NULL
, "got NULL, expected a HTHEME handle\n");
388 ok( GetLastError() == ERROR_SUCCESS
,
389 "Expected ERROR_SUCCESS, got 0x%08x\n",
392 /* Test with bUtToN instead of Button */
393 SetLastError(0xdeadbeef);
394 hTheme
= pOpenThemeDataEx(hWnd
, szButtonClassList2
, 0);
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
, szClassList
, 0);
403 ok( hTheme
!= NULL
, "got NULL, expected a HTHEME handle\n");
405 ok( GetLastError() == ERROR_SUCCESS
,
406 "Expected ERROR_SUCCESS, got 0x%08x\n",
412 static void test_GetCurrentThemeName(void)
416 WCHAR currentTheme
[MAX_PATH
];
417 WCHAR currentColor
[MAX_PATH
];
418 WCHAR currentSize
[MAX_PATH
];
420 bThemeActive
= IsThemeActive();
423 hRes
= GetCurrentThemeName(NULL
, 0, NULL
, 0, NULL
, 0);
425 ok( hRes
== S_OK
, "Expected S_OK, got 0x%08x\n", hRes
);
427 ok( hRes
== E_PROP_ID_UNSUPPORTED
, "Expected E_PROP_ID_UNSUPPORTED, got 0x%08x\n", hRes
);
429 /* Number of characters given is 0 */
430 hRes
= GetCurrentThemeName(currentTheme
, 0, NULL
, 0, NULL
, 0);
432 ok( hRes
== S_OK
|| broken(hRes
== E_FAIL
/* WinXP SP1 */), "Expected S_OK, got 0x%08x\n", hRes
);
434 ok( hRes
== E_PROP_ID_UNSUPPORTED
, "Expected E_PROP_ID_UNSUPPORTED, got 0x%08x\n", hRes
);
436 hRes
= GetCurrentThemeName(currentTheme
, 2, NULL
, 0, NULL
, 0);
439 ok(hRes
== E_NOT_SUFFICIENT_BUFFER
||
440 broken(hRes
== E_FAIL
/* WinXP SP1 */),
441 "Expected E_NOT_SUFFICIENT_BUFFER, got 0x%08x\n", hRes
);
443 ok( hRes
== E_PROP_ID_UNSUPPORTED
, "Expected E_PROP_ID_UNSUPPORTED, got 0x%08x\n", hRes
);
445 /* The same is true if the number of characters is too small for Color and/or Size */
446 hRes
= GetCurrentThemeName(currentTheme
, ARRAY_SIZE(currentTheme
), currentColor
, 2,
447 currentSize
, ARRAY_SIZE(currentSize
));
450 ok(hRes
== E_NOT_SUFFICIENT_BUFFER
||
451 broken(hRes
== E_FAIL
/* WinXP SP1 */),
452 "Expected E_NOT_SUFFICIENT_BUFFER, got 0x%08x\n", hRes
);
454 ok( hRes
== E_PROP_ID_UNSUPPORTED
, "Expected E_PROP_ID_UNSUPPORTED, got 0x%08x\n", hRes
);
456 /* Given number of characters is correct */
457 hRes
= GetCurrentThemeName(currentTheme
, ARRAY_SIZE(currentTheme
), NULL
, 0, NULL
, 0);
459 ok( hRes
== S_OK
, "Expected S_OK, got 0x%08x\n", hRes
);
461 ok( hRes
== E_PROP_ID_UNSUPPORTED
, "Expected E_PROP_ID_UNSUPPORTED, got 0x%08x\n", hRes
);
463 /* Given number of characters for the theme name is too large */
464 hRes
= GetCurrentThemeName(currentTheme
, sizeof(currentTheme
), NULL
, 0, NULL
, 0);
466 ok( hRes
== E_POINTER
|| hRes
== S_OK
, "Expected E_POINTER or S_OK, got 0x%08x\n", hRes
);
468 ok( hRes
== E_PROP_ID_UNSUPPORTED
||
469 hRes
== E_POINTER
, /* win2k3 */
470 "Expected E_PROP_ID_UNSUPPORTED, got 0x%08x\n", hRes
);
472 /* The too large case is only for the theme name, not for color name or size name */
473 hRes
= GetCurrentThemeName(currentTheme
, ARRAY_SIZE(currentTheme
), currentColor
,
474 sizeof(currentTheme
), currentSize
, ARRAY_SIZE(currentSize
));
476 ok( hRes
== S_OK
, "Expected S_OK, got 0x%08x\n", hRes
);
478 ok( hRes
== E_PROP_ID_UNSUPPORTED
, "Expected E_PROP_ID_UNSUPPORTED, got 0x%08x\n", hRes
);
480 hRes
= GetCurrentThemeName(currentTheme
, ARRAY_SIZE(currentTheme
), currentColor
,
481 ARRAY_SIZE(currentTheme
), currentSize
, sizeof(currentSize
));
483 ok( hRes
== S_OK
, "Expected S_OK, got 0x%08x\n", hRes
);
485 ok( hRes
== E_PROP_ID_UNSUPPORTED
, "Expected E_PROP_ID_UNSUPPORTED, got 0x%08x\n", hRes
);
488 hRes
= GetCurrentThemeName(currentTheme
, ARRAY_SIZE(currentTheme
), currentColor
,
489 ARRAY_SIZE(currentColor
), currentSize
, ARRAY_SIZE(currentSize
));
491 ok( hRes
== S_OK
, "Expected S_OK, got 0x%08x\n", hRes
);
493 ok( hRes
== E_PROP_ID_UNSUPPORTED
, "Expected E_PROP_ID_UNSUPPORTED, got 0x%08x\n", hRes
);
496 static void test_CloseThemeData(void)
500 hRes
= CloseThemeData(NULL
);
501 ok( hRes
== E_HANDLE
, "Expected E_HANDLE, got 0x%08x\n", hRes
);
502 hRes
= CloseThemeData(INVALID_HANDLE_VALUE
);
503 ok( hRes
== E_HANDLE
, "Expected E_HANDLE, got 0x%08x\n", hRes
);
506 static void test_buffer_dc_props(HDC hdc
, const RECT
*rect
)
508 static const XFORM ident
= { 1.0f
, 0.0f
, 0.0f
, 1.0f
, 0.0f
, 0.0f
};
514 ret
= GetWorldTransform(hdc
, &xform
);
515 ok(ret
, "Failed to get world transform\n");
516 ok(!memcmp(&xform
, &ident
, sizeof(xform
)), "Unexpected world transform\n");
518 ret
= GetViewportOrgEx(hdc
, &org
);
519 ok(ret
, "Failed to get vport origin\n");
520 ok(org
.x
== 0 && org
.y
== 0, "Unexpected vport origin\n");
522 ret
= GetWindowOrgEx(hdc
, &org
);
523 ok(ret
, "Failed to get vport origin\n");
524 ok(org
.x
== rect
->left
&& org
.y
== rect
->top
, "Unexpected window origin\n");
526 ret
= GetClipBox(hdc
, &box
);
527 ok(ret
, "Failed to get clip box\n");
528 ok(box
.left
== rect
->left
&& box
.top
== rect
->top
, "Unexpected clip box\n");
530 ok(GetGraphicsMode(hdc
) == GM_COMPATIBLE
, "wrong graphics mode\n");
533 static void test_buffered_paint(void)
535 HDC target
, src
, hdc
, screen_dc
;
536 BP_PAINTPARAMS params
= { 0 };
537 BP_BUFFERFORMAT format
;
545 if (!pBeginBufferedPaint
)
547 win_skip("Buffered painting API is not supported.\n");
551 buffer
= pBeginBufferedPaint(NULL
, NULL
, BPBF_COMPATIBLEBITMAP
,
553 ok(buffer
== NULL
, "Unexpected buffer %p\n", buffer
);
555 target
= CreateCompatibleDC(0);
556 buffer
= pBeginBufferedPaint(target
, NULL
, BPBF_COMPATIBLEBITMAP
,
558 ok(buffer
== NULL
, "Unexpected buffer %p\n", buffer
);
560 params
.cbSize
= sizeof(params
);
561 buffer
= pBeginBufferedPaint(target
, NULL
, BPBF_COMPATIBLEBITMAP
,
563 ok(buffer
== NULL
, "Unexpected buffer %p\n", buffer
);
565 src
= (void *)0xdeadbeef;
566 buffer
= pBeginBufferedPaint(target
, NULL
, BPBF_COMPATIBLEBITMAP
,
568 ok(buffer
== NULL
, "Unexpected buffer %p\n", buffer
);
569 ok(src
== NULL
, "Unexpected buffered dc %p\n", src
);
571 /* target rect is mandatory */
573 src
= (void *)0xdeadbeef;
574 buffer
= pBeginBufferedPaint(target
, &rect
, BPBF_COMPATIBLEBITMAP
,
576 ok(buffer
== NULL
, "Unexpected buffer %p\n", buffer
);
577 ok(src
== NULL
, "Unexpected buffered dc %p\n", src
);
579 /* inverted rectangle */
580 SetRect(&rect
, 10, 0, 5, 5);
581 src
= (void *)0xdeadbeef;
582 buffer
= pBeginBufferedPaint(target
, &rect
, BPBF_COMPATIBLEBITMAP
,
584 ok(buffer
== NULL
, "Unexpected buffer %p\n", buffer
);
585 ok(src
== NULL
, "Unexpected buffered dc %p\n", src
);
587 SetRect(&rect
, 0, 10, 5, 0);
588 src
= (void *)0xdeadbeef;
589 buffer
= pBeginBufferedPaint(target
, &rect
, BPBF_COMPATIBLEBITMAP
,
591 ok(buffer
== NULL
, "Unexpected buffer %p\n", buffer
);
592 ok(src
== NULL
, "Unexpected buffered dc %p\n", src
);
594 /* valid rectangle, no target dc */
595 SetRect(&rect
, 0, 0, 5, 5);
596 src
= (void *)0xdeadbeef;
597 buffer
= pBeginBufferedPaint(NULL
, &rect
, BPBF_COMPATIBLEBITMAP
,
599 ok(buffer
== NULL
, "Unexpected buffer %p\n", buffer
);
600 ok(src
== NULL
, "Unexpected buffered dc %p\n", src
);
602 SetRect(&rect
, 0, 0, 5, 5);
604 buffer
= pBeginBufferedPaint(target
, &rect
, BPBF_COMPATIBLEBITMAP
,
606 ok(buffer
!= NULL
, "Unexpected buffer %p\n", buffer
);
607 ok(src
!= NULL
, "Expected buffered dc\n");
608 hr
= pEndBufferedPaint(buffer
, FALSE
);
609 ok(hr
== S_OK
, "Unexpected return code %#x\n", hr
);
611 SetRect(&rect
, 0, 0, 5, 5);
612 buffer
= pBeginBufferedPaint(target
, &rect
, BPBF_COMPATIBLEBITMAP
,
614 ok(buffer
!= NULL
, "Unexpected buffer %p\n", buffer
);
617 hr
= pBufferedPaintClear(NULL
, NULL
);
619 ok(hr
== E_FAIL
, "Unexpected return code %#x\n", hr
);
621 hr
= pBufferedPaintClear(buffer
, NULL
);
623 ok(hr
== S_OK
, "Unexpected return code %#x\n", hr
);
625 /* access buffer attributes */
626 hdc
= pGetBufferedPaintDC(buffer
);
627 ok(hdc
== src
, "Unexpected hdc, %p, buffered dc %p\n", hdc
, src
);
629 hdc
= pGetBufferedPaintTargetDC(buffer
);
630 ok(hdc
== target
, "Unexpected target hdc %p, original %p\n", hdc
, target
);
632 hr
= pGetBufferedPaintTargetRect(NULL
, NULL
);
633 ok(hr
== E_POINTER
, "Unexpected return code %#x\n", hr
);
635 hr
= pGetBufferedPaintTargetRect(buffer
, NULL
);
636 ok(hr
== E_POINTER
, "Unexpected return code %#x\n", hr
);
638 hr
= pGetBufferedPaintTargetRect(NULL
, &rect2
);
639 ok(hr
== E_FAIL
, "Unexpected return code %#x\n", hr
);
641 SetRectEmpty(&rect2
);
642 hr
= pGetBufferedPaintTargetRect(buffer
, &rect2
);
643 ok(hr
== S_OK
, "Unexpected return code %#x\n", hr
);
644 ok(EqualRect(&rect
, &rect2
), "Wrong target rect\n");
646 hr
= pEndBufferedPaint(buffer
, FALSE
);
647 ok(hr
== S_OK
, "Unexpected return code %#x\n", hr
);
649 /* invalid buffer handle */
650 hr
= pEndBufferedPaint(NULL
, FALSE
);
651 ok(hr
== E_INVALIDARG
, "Unexpected return code %#x\n", hr
);
653 hdc
= pGetBufferedPaintDC(NULL
);
654 ok(hdc
== NULL
, "Unexpected hdc %p\n", hdc
);
656 hdc
= pGetBufferedPaintTargetDC(NULL
);
657 ok(hdc
== NULL
, "Unexpected target hdc %p\n", hdc
);
659 hr
= pGetBufferedPaintTargetRect(NULL
, &rect2
);
660 ok(hr
== E_FAIL
, "Unexpected return code %#x\n", hr
);
662 hr
= pGetBufferedPaintTargetRect(NULL
, NULL
);
663 ok(hr
== E_POINTER
, "Unexpected return code %#x\n", hr
);
665 bits
= (void *)0xdeadbeef;
667 hr
= pGetBufferedPaintBits(NULL
, &bits
, &row
);
668 ok(hr
== E_FAIL
, "Unexpected return code %#x\n", hr
);
669 ok(row
== 10, "Unexpected row count %d\n", row
);
670 ok(bits
== (void *)0xdeadbeef, "Unexpected data pointer %p\n", bits
);
672 hr
= pGetBufferedPaintBits(NULL
, NULL
, NULL
);
673 ok(hr
== E_POINTER
, "Unexpected return code %#x\n", hr
);
675 hr
= pGetBufferedPaintBits(NULL
, &bits
, NULL
);
676 ok(hr
== E_POINTER
, "Unexpected return code %#x\n", hr
);
678 hr
= pGetBufferedPaintBits(NULL
, NULL
, &row
);
679 ok(hr
== E_POINTER
, "Unexpected return code %#x\n", hr
);
681 screen_dc
= GetDC(0);
683 hdc
= CreateCompatibleDC(screen_dc
);
684 ok(hdc
!= NULL
, "Failed to create a DC\n");
685 hbm
= CreateCompatibleBitmap(screen_dc
, 64, 64);
686 ok(hbm
!= NULL
, "Failed to create a bitmap\n");
687 SelectObject(hdc
, hbm
);
689 ReleaseDC(0, screen_dc
);
691 SetRect(&rect
, 1, 2, 34, 56);
693 buffer
= pBeginBufferedPaint(hdc
, &rect
, BPBF_COMPATIBLEBITMAP
, NULL
, &src
);
694 test_buffer_dc_props(src
, &rect
);
695 hr
= pEndBufferedPaint(buffer
, FALSE
);
696 ok(hr
== S_OK
, "Unexpected return code %#x\n", hr
);
701 buffer
= pBeginBufferedPaint(target
, &rect
, BPBF_COMPATIBLEBITMAP
, NULL
, &src
);
702 test_buffer_dc_props(src
, &rect
);
703 hr
= pEndBufferedPaint(buffer
, FALSE
);
704 ok(hr
== S_OK
, "Unexpected return code %#x\n", hr
);
706 /* access buffer bits */
707 for (format
= BPBF_COMPATIBLEBITMAP
; format
<= BPBF_TOPDOWNMONODIB
; format
++)
709 buffer
= pBeginBufferedPaint(target
, &rect
, format
, ¶ms
, &src
);
711 /* only works for DIB buffers */
714 hr
= pGetBufferedPaintBits(buffer
, &bits
, &row
);
715 if (format
== BPBF_COMPATIBLEBITMAP
)
716 ok(hr
== E_FAIL
, "Unexpected return code %#x\n", hr
);
719 ok(hr
== S_OK
, "Unexpected return code %#x\n", hr
);
720 ok(bits
!= NULL
, "Bitmap bits %p\n", bits
);
721 ok(row
>= (rect
.right
- rect
.left
), "format %d: bitmap width %d\n", format
, row
);
724 hr
= pEndBufferedPaint(buffer
, FALSE
);
725 ok(hr
== S_OK
, "Unexpected return code %#x\n", hr
);
735 /* No real functional theme API tests will be done (yet). The current tests
736 * only show input/return behaviour
740 test_GetWindowTheme();
741 test_SetWindowTheme();
742 test_OpenThemeData();
743 test_OpenThemeDataEx();
744 test_GetCurrentThemeName();
745 test_CloseThemeData();
746 test_buffered_paint();