uxtheme/tests: Some tests for buffered painting API.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
72a431e0ef
commit
e41747a784
|
@ -1,5 +1,5 @@
|
|||
TESTDLL = uxtheme.dll
|
||||
IMPORTS = user32 uxtheme
|
||||
IMPORTS = user32 gdi32 uxtheme
|
||||
|
||||
C_SRCS = \
|
||||
system.c
|
||||
|
|
|
@ -27,13 +27,30 @@
|
|||
#include "wine/test.h"
|
||||
|
||||
static HTHEME (WINAPI * pOpenThemeDataEx)(HWND, LPCWSTR, DWORD);
|
||||
|
||||
#define UXTHEME_GET_PROC(func) p ## func = (void*)GetProcAddress(hUxtheme, #func);
|
||||
static HPAINTBUFFER (WINAPI *pBeginBufferedPaint)(HDC, const RECT *, BP_BUFFERFORMAT, BP_PAINTPARAMS *, HDC *);
|
||||
static HRESULT (WINAPI *pBufferedPaintClear)(HPAINTBUFFER, const RECT *);
|
||||
static HRESULT (WINAPI *pEndBufferedPaint)(HPAINTBUFFER, BOOL);
|
||||
static HRESULT (WINAPI *pGetBufferedPaintBits)(HPAINTBUFFER, RGBQUAD **, int *);
|
||||
static HDC (WINAPI *pGetBufferedPaintDC)(HPAINTBUFFER);
|
||||
static HDC (WINAPI *pGetBufferedPaintTargetDC)(HPAINTBUFFER);
|
||||
static HRESULT (WINAPI *pGetBufferedPaintTargetRect)(HPAINTBUFFER, RECT *);
|
||||
|
||||
static void init_funcs(void)
|
||||
{
|
||||
HMODULE hUxtheme = GetModuleHandleA("uxtheme.dll");
|
||||
UXTHEME_GET_PROC(OpenThemeDataEx)
|
||||
|
||||
#define UXTHEME_GET_PROC(func) p ## func = (void*)GetProcAddress(hUxtheme, #func)
|
||||
UXTHEME_GET_PROC(BeginBufferedPaint);
|
||||
UXTHEME_GET_PROC(BufferedPaintClear);
|
||||
UXTHEME_GET_PROC(EndBufferedPaint);
|
||||
UXTHEME_GET_PROC(GetBufferedPaintBits);
|
||||
UXTHEME_GET_PROC(GetBufferedPaintDC);
|
||||
UXTHEME_GET_PROC(GetBufferedPaintTargetDC);
|
||||
UXTHEME_GET_PROC(GetBufferedPaintTargetRect);
|
||||
UXTHEME_GET_PROC(BufferedPaintClear);
|
||||
|
||||
UXTHEME_GET_PROC(OpenThemeDataEx);
|
||||
#undef UXTHEME_GET_PROC
|
||||
}
|
||||
|
||||
static void test_IsThemed(void)
|
||||
|
@ -506,6 +523,122 @@ static void test_CloseThemeData(void)
|
|||
ok( hRes == E_HANDLE, "Expected E_HANDLE, got 0x%08x\n", hRes);
|
||||
}
|
||||
|
||||
static void test_buffered_paint(void)
|
||||
{
|
||||
BP_PAINTPARAMS params = { 0 };
|
||||
BP_BUFFERFORMAT format;
|
||||
HDC target, src, hdc;
|
||||
HPAINTBUFFER buffer;
|
||||
RECT rect, rect2;
|
||||
HRESULT hr;
|
||||
|
||||
if (!pBeginBufferedPaint)
|
||||
{
|
||||
win_skip("Buffered painting API is not supported.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
buffer = pBeginBufferedPaint(NULL, NULL, BPBF_COMPATIBLEBITMAP,
|
||||
NULL, NULL);
|
||||
ok(buffer == NULL, "Unexpected buffer %p\n", buffer);
|
||||
|
||||
target = CreateCompatibleDC(0);
|
||||
buffer = pBeginBufferedPaint(target, NULL, BPBF_COMPATIBLEBITMAP,
|
||||
NULL, NULL);
|
||||
ok(buffer == NULL, "Unexpected buffer %p\n", buffer);
|
||||
|
||||
params.cbSize = sizeof(params);
|
||||
buffer = pBeginBufferedPaint(target, NULL, BPBF_COMPATIBLEBITMAP,
|
||||
¶ms, NULL);
|
||||
ok(buffer == NULL, "Unexpected buffer %p\n", buffer);
|
||||
|
||||
buffer = pBeginBufferedPaint(target, NULL, BPBF_COMPATIBLEBITMAP,
|
||||
¶ms, &src);
|
||||
ok(buffer == NULL, "Unexpected buffer %p\n", buffer);
|
||||
|
||||
/* target rect is mandatory */
|
||||
rect.left = rect.top = 0;
|
||||
rect.right = rect.bottom = 0;
|
||||
buffer = pBeginBufferedPaint(target, &rect, BPBF_COMPATIBLEBITMAP,
|
||||
¶ms, &src);
|
||||
ok(buffer == NULL, "Unexpected buffer %p\n", buffer);
|
||||
|
||||
rect.left = rect.top = 0;
|
||||
rect.right = rect.bottom = 5;
|
||||
buffer = pBeginBufferedPaint(target, &rect, BPBF_COMPATIBLEBITMAP,
|
||||
¶ms, &src);
|
||||
todo_wine
|
||||
ok(buffer != NULL, "Unexpected buffer %p\n", buffer);
|
||||
hr = pEndBufferedPaint(buffer, FALSE);
|
||||
ok(hr == S_OK, "Unexpected return code %#x\n", hr);
|
||||
|
||||
rect.left = rect.top = 0;
|
||||
rect.right = rect.bottom = 5;
|
||||
buffer = pBeginBufferedPaint(target, &rect, BPBF_COMPATIBLEBITMAP,
|
||||
¶ms, &src);
|
||||
todo_wine
|
||||
ok(buffer != NULL, "Unexpected buffer %p\n", buffer);
|
||||
|
||||
/* clearing */
|
||||
hr = pBufferedPaintClear(NULL, NULL);
|
||||
todo_wine
|
||||
ok(hr == E_FAIL, "Unexpected return code %#x\n", hr);
|
||||
|
||||
hr = pBufferedPaintClear(buffer, NULL);
|
||||
todo_wine
|
||||
ok(hr == S_OK, "Unexpected return code %#x\n", hr);
|
||||
|
||||
/* access buffer attributes */
|
||||
hdc = pGetBufferedPaintDC(buffer);
|
||||
todo_wine
|
||||
ok(hdc == src, "Unexpected hdc, %p, buffered dc %p\n", hdc, src);
|
||||
|
||||
hdc = pGetBufferedPaintTargetDC(buffer);
|
||||
todo_wine
|
||||
ok(hdc == target, "Unexpected target hdc %p, original %p\n", hdc, target);
|
||||
|
||||
hr = pGetBufferedPaintTargetRect(buffer, NULL);
|
||||
todo_wine
|
||||
ok(hr == E_POINTER, "Unexpected return code %#x\n", hr);
|
||||
|
||||
SetRectEmpty(&rect2);
|
||||
hr = pGetBufferedPaintTargetRect(buffer, &rect2);
|
||||
todo_wine {
|
||||
ok(hr == S_OK, "Unexpected return code %#x\n", hr);
|
||||
ok(EqualRect(&rect, &rect2), "Wrong target rect\n");
|
||||
}
|
||||
hr = pEndBufferedPaint(buffer, FALSE);
|
||||
ok(hr == S_OK, "Unexpected return code %#x\n", hr);
|
||||
|
||||
/* access buffer bits */
|
||||
for (format = BPBF_COMPATIBLEBITMAP; format <= BPBF_TOPDOWNMONODIB; format++)
|
||||
{
|
||||
RGBQUAD *bits;
|
||||
int row;
|
||||
|
||||
buffer = pBeginBufferedPaint(target, &rect, format, ¶ms, &src);
|
||||
|
||||
/* only works for DIB buffers */
|
||||
bits = NULL;
|
||||
row = 0;
|
||||
hr = pGetBufferedPaintBits(buffer, &bits, &row);
|
||||
todo_wine {
|
||||
if (format == BPBF_COMPATIBLEBITMAP)
|
||||
ok(hr == E_FAIL, "Unexpected return code %#x\n", hr);
|
||||
else
|
||||
{
|
||||
ok(hr == S_OK, "Unexpected return code %#x\n", hr);
|
||||
ok(bits != NULL, "Bitmap bits %p\n", bits);
|
||||
ok(row > 0, "Bitmap width %d\n", row);
|
||||
}
|
||||
}
|
||||
hr = pEndBufferedPaint(buffer, FALSE);
|
||||
ok(hr == S_OK, "Unexpected return code %#x\n", hr);
|
||||
}
|
||||
|
||||
DeleteDC(target);
|
||||
}
|
||||
|
||||
START_TEST(system)
|
||||
{
|
||||
init_funcs();
|
||||
|
@ -541,4 +674,6 @@ START_TEST(system)
|
|||
/* CloseThemeData */
|
||||
trace("Starting test_CloseThemeData()\n");
|
||||
test_CloseThemeData();
|
||||
|
||||
test_buffered_paint();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue