Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/d2d1/tests/d2d1.c | 125 +++++++++++------------------------------ 1 file changed, 34 insertions(+), 91 deletions(-)
diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index 617d246485b..bc9d7f83c8d 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -45,6 +45,7 @@ size_t mt_tests_size, mt_test_count; struct d2d1_test_context { ID3D10Device1 *device; + HWND window; };
struct resource_readback @@ -787,6 +788,7 @@ static ID2D1RenderTarget *create_render_target(IDXGISurface *surface) #define release_test_context(ctx) release_test_context_(__LINE__, ctx) static void release_test_context_(unsigned int line, struct d2d1_test_context *ctx) { + if (ctx->window) DestroyWindow(ctx->window); ID3D10Device1_Release(ctx->device); }
@@ -801,6 +803,14 @@ static BOOL init_test_context_(unsigned int line, struct d2d1_test_context *ctx) return FALSE; }
+ ctx->window = create_window(); + ok_(__FILE__, line)(ctx->window != NULL, "Failed to create test window.\n"); + if (!ctx->window) + { + release_test_context(ctx); + return FALSE; + } + return TRUE; }
@@ -1123,7 +1133,6 @@ static void test_clip(void) float dpi_x, dpi_y; D2D1_RECT_F rect; D2D1_SIZE_F size; - HWND window; HRESULT hr; BOOL match; static const D2D1_MATRIX_3X2_F identity = @@ -1136,8 +1145,7 @@ static void test_clip(void) if (!init_test_context(&ctx)) return;
- window = create_window(); - swapchain = create_swapchain(ctx.device, window, TRUE); + swapchain = create_swapchain(ctx.device, ctx.window, TRUE); hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface); ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr); rt = create_render_target(surface); @@ -1312,7 +1320,6 @@ static void test_clip(void) IDXGISurface_Release(surface); IDXGISwapChain_Release(swapchain); release_test_context(&ctx); - DestroyWindow(window); }
static void test_state_block(void) @@ -1328,7 +1335,6 @@ static void test_state_block(void) IDXGISurface *surface; ID2D1Factory *factory; ULONG refcount; - HWND window; HRESULT hr; static const D2D1_MATRIX_3X2_F identity = {{{ @@ -1352,8 +1358,7 @@ static void test_state_block(void) if (!init_test_context(&ctx)) return;
- window = create_window(); - swapchain = create_swapchain(ctx.device, window, TRUE); + swapchain = create_swapchain(ctx.device, ctx.window, TRUE); hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface); ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr); rt = create_render_target(surface); @@ -1584,7 +1589,6 @@ static void test_state_block(void) IDXGISurface_Release(surface); IDXGISwapChain_Release(swapchain); release_test_context(&ctx); - DestroyWindow(window); }
static void test_color_brush(void) @@ -1599,15 +1603,13 @@ static void test_color_brush(void) IDXGISurface *surface; D2D1_RECT_F rect; float opacity; - HWND window; HRESULT hr; BOOL match;
if (!init_test_context(&ctx)) return;
- window = create_window(); - swapchain = create_swapchain(ctx.device, window, TRUE); + swapchain = create_swapchain(ctx.device, ctx.window, TRUE); hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface); ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr); rt = create_render_target(surface); @@ -1682,7 +1684,6 @@ static void test_color_brush(void) IDXGISurface_Release(surface); IDXGISwapChain_Release(swapchain); release_test_context(&ctx); - DestroyWindow(window); }
static void test_bitmap_brush(void) @@ -1708,7 +1709,6 @@ static void test_bitmap_brush(void) unsigned int i; ULONG refcount; float opacity; - HWND window; HRESULT hr; BOOL match;
@@ -1743,8 +1743,7 @@ static void test_bitmap_brush(void) if (!init_test_context(&ctx)) return;
- window = create_window(); - swapchain = create_swapchain(ctx.device, window, TRUE); + swapchain = create_swapchain(ctx.device, ctx.window, TRUE); hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface); ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr); rt = create_render_target(surface); @@ -1979,7 +1978,6 @@ static void test_bitmap_brush(void) IDXGISurface_Release(surface); IDXGISwapChain_Release(swapchain); release_test_context(&ctx); - DestroyWindow(window); }
static void test_linear_brush(void) @@ -2002,7 +2000,6 @@ static void test_linear_brush(void) ULONG refcount; D2D1_RECT_F r; float opacity; - HWND window; HRESULT hr;
static const D2D1_GRADIENT_STOP stops[] = @@ -2045,8 +2042,7 @@ static void test_linear_brush(void) if (!init_test_context(&ctx)) return;
- window = create_window(); - swapchain = create_swapchain(ctx.device, window, TRUE); + swapchain = create_swapchain(ctx.device, ctx.window, TRUE); hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface); ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr); rt = create_render_target(surface); @@ -2183,7 +2179,6 @@ static void test_linear_brush(void) IDXGISurface_Release(surface); IDXGISwapChain_Release(swapchain); release_test_context(&ctx); - DestroyWindow(window); }
static void test_radial_brush(void) @@ -2205,7 +2200,6 @@ static void test_radial_brush(void) unsigned int i; ULONG refcount; D2D1_RECT_F r; - HWND window; HRESULT hr; float f;
@@ -2249,8 +2243,7 @@ static void test_radial_brush(void) if (!init_test_context(&ctx)) return;
- window = create_window(); - swapchain = create_swapchain(ctx.device, window, TRUE); + swapchain = create_swapchain(ctx.device, ctx.window, TRUE); hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface); ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr); rt = create_render_target(surface); @@ -2395,7 +2388,6 @@ static void test_radial_brush(void) IDXGISurface_Release(surface); IDXGISwapChain_Release(swapchain); release_test_context(&ctx); - DestroyWindow(window); }
static void fill_geometry_sink(ID2D1GeometrySink *sink, unsigned int hollow_count) @@ -2533,7 +2525,6 @@ static void test_path_geometry(void) D2D1_RECT_F rect; ULONG refcount; UINT32 count; - HWND window; HRESULT hr;
static const struct geometry_segment expected_segments[] = @@ -2853,8 +2844,7 @@ static void test_path_geometry(void) if (!init_test_context(&ctx)) return;
- window = create_window(); - swapchain = create_swapchain(ctx.device, window, TRUE); + swapchain = create_swapchain(ctx.device, ctx.window, TRUE); hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface); ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr); rt = create_render_target(surface); @@ -3583,7 +3573,6 @@ static void test_path_geometry(void) IDXGISurface_Release(surface); IDXGISwapChain_Release(swapchain); release_test_context(&ctx); - DestroyWindow(window); }
static void test_rectangle_geometry(void) @@ -3923,7 +3912,6 @@ static void test_bitmap_formats(void) IDXGISurface *surface; ID2D1Bitmap *bitmap; unsigned int i, j; - HWND window; HRESULT hr;
static const struct @@ -3952,8 +3940,7 @@ static void test_bitmap_formats(void) if (!init_test_context(&ctx)) return;
- window = create_window(); - swapchain = create_swapchain(ctx.device, window, TRUE); + swapchain = create_swapchain(ctx.device, ctx.window, TRUE); hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface); ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr); rt = create_render_target(surface); @@ -3986,7 +3973,6 @@ static void test_bitmap_formats(void) IDXGISurface_Release(surface); IDXGISwapChain_Release(swapchain); release_test_context(&ctx); - DestroyWindow(window); }
static void test_alpha_mode(void) @@ -4004,7 +3990,6 @@ static void test_alpha_mode(void) D2D1_RECT_F rect; D2D1_SIZE_U size; ULONG refcount; - HWND window; HRESULT hr; BOOL match;
@@ -4019,8 +4004,7 @@ static void test_alpha_mode(void) if (!init_test_context(&ctx)) return;
- window = create_window(); - swapchain = create_swapchain(ctx.device, window, TRUE); + swapchain = create_swapchain(ctx.device, ctx.window, TRUE); hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface); ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr); rt = create_render_target(surface); @@ -4213,7 +4197,6 @@ static void test_alpha_mode(void) IDXGISurface_Release(surface); IDXGISwapChain_Release(swapchain); release_test_context(&ctx); - DestroyWindow(window); }
static void test_shared_bitmap(void) @@ -4234,15 +4217,14 @@ static void test_shared_bitmap(void) D2D1_PIXEL_FORMAT pixel_format; D2D1_SIZE_U size = {4, 4}; IDXGISurface1 *surface3; - HWND window1, window2; + HWND window2; HRESULT hr;
if (!init_test_context(&ctx)) return;
- window1 = create_window(); window2 = create_window(); - swapchain1 = create_swapchain(ctx.device, window1, TRUE); + swapchain1 = create_swapchain(ctx.device, ctx.window, TRUE); swapchain2 = create_swapchain(ctx.device, window2, TRUE); hr = IDXGISwapChain_GetBuffer(swapchain1, 0, &IID_IDXGISurface, (void **)&surface1); ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr); @@ -4466,7 +4448,6 @@ static void test_shared_bitmap(void) ID3D10Device1_Release(device2); release_test_context(&ctx); DestroyWindow(window2); - DestroyWindow(window1); CoUninitialize(); }
@@ -4482,7 +4463,6 @@ static void test_bitmap_updates(void) D2D1_COLOR_F color; D2D1_RECT_F rect; D2D1_SIZE_U size; - HWND window; HRESULT hr; BOOL match;
@@ -4497,8 +4477,7 @@ static void test_bitmap_updates(void) if (!init_test_context(&ctx)) return;
- window = create_window(); - swapchain = create_swapchain(ctx.device, window, TRUE); + swapchain = create_swapchain(ctx.device, ctx.window, TRUE); hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface); ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr); rt = create_render_target(surface); @@ -4568,7 +4547,6 @@ static void test_bitmap_updates(void) IDXGISurface_Release(surface); IDXGISwapChain_Release(swapchain); release_test_context(&ctx); - DestroyWindow(window); }
static void test_opacity_brush(void) @@ -4588,7 +4566,6 @@ static void test_opacity_brush(void) D2D1_RECT_F rect; D2D1_SIZE_U size; ULONG refcount; - HWND window; HRESULT hr; BOOL match;
@@ -4603,8 +4580,7 @@ static void test_opacity_brush(void) if (!init_test_context(&ctx)) return;
- window = create_window(); - swapchain = create_swapchain(ctx.device, window, TRUE); + swapchain = create_swapchain(ctx.device, ctx.window, TRUE); hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface); ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr); rt = create_render_target(surface); @@ -4747,7 +4723,6 @@ static void test_opacity_brush(void) IDXGISurface_Release(surface); IDXGISwapChain_Release(swapchain); release_test_context(&ctx); - DestroyWindow(window); }
static void test_create_target(void) @@ -4757,7 +4732,6 @@ static void test_create_target(void) ID2D1Factory *factory; ID2D1RenderTarget *rt; IDXGISurface *surface; - HWND window; HRESULT hr; static const struct { @@ -4779,8 +4753,7 @@ static void test_create_target(void) if (!init_test_context(&ctx)) return;
- window = create_window(); - swapchain = create_swapchain(ctx.device, window, TRUE); + swapchain = create_swapchain(ctx.device, ctx.window, TRUE); hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface); ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr);
@@ -4836,7 +4809,6 @@ static void test_create_target(void) IDXGISurface_Release(surface); IDXGISwapChain_Release(swapchain); release_test_context(&ctx); - DestroyWindow(window); }
static void test_draw_text_layout(void) @@ -4878,7 +4850,6 @@ static void test_draw_text_layout(void) ID2D1Factory *factory, *factory2; ID2D1RenderTarget *rt, *rt2; IDXGISurface *surface; - HWND window; HRESULT hr; IDWriteFactory *dwrite_factory; IDWriteTextFormat *text_format; @@ -4894,8 +4865,7 @@ static void test_draw_text_layout(void) if (!init_test_context(&ctx)) return;
- window = create_window(); - swapchain = create_swapchain(ctx.device, window, TRUE); + swapchain = create_swapchain(ctx.device, ctx.window, TRUE); hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface); ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr);
@@ -5004,7 +4974,6 @@ todo_wine IDXGISurface_Release(surface); IDXGISwapChain_Release(swapchain); release_test_context(&ctx); - DestroyWindow(window); }
static void create_target_dibsection(HDC hdc, UINT32 width, UINT32 height) @@ -5772,14 +5741,12 @@ static void test_gradient(void) D2D1_COLOR_F color; unsigned int i; UINT32 count; - HWND window; HRESULT hr;
if (!init_test_context(&ctx)) return;
- window = create_window(); - swapchain = create_swapchain(ctx.device, window, TRUE); + swapchain = create_swapchain(ctx.device, ctx.window, TRUE); hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface); ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr); rt = create_render_target(surface); @@ -5814,7 +5781,6 @@ static void test_gradient(void) IDXGISurface_Release(surface); IDXGISwapChain_Release(swapchain); release_test_context(&ctx); - DestroyWindow(window); }
static void test_draw_geometry(void) @@ -5837,15 +5803,13 @@ static void test_draw_geometry(void) D2D1_COLOR_F color; D2D1_RECT_F rect; ULONG refcount; - HWND window; HRESULT hr; BOOL match;
if (!init_test_context(&ctx)) return;
- window = create_window(); - swapchain = create_swapchain(ctx.device, window, TRUE); + swapchain = create_swapchain(ctx.device, ctx.window, TRUE); hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface); ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr); rt = create_render_target(surface); @@ -6740,7 +6704,6 @@ static void test_draw_geometry(void) IDXGISurface_Release(surface); IDXGISwapChain_Release(swapchain); release_test_context(&ctx); - DestroyWindow(window); }
static void test_fill_geometry(void) @@ -6762,15 +6725,13 @@ static void test_fill_geometry(void) D2D1_COLOR_F color; D2D1_RECT_F rect; ULONG refcount; - HWND window; HRESULT hr; BOOL match;
if (!init_test_context(&ctx)) return;
- window = create_window(); - swapchain = create_swapchain(ctx.device, window, TRUE); + swapchain = create_swapchain(ctx.device, ctx.window, TRUE); hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface); ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr); rt = create_render_target(surface); @@ -7552,7 +7513,6 @@ static void test_fill_geometry(void) IDXGISurface_Release(surface); IDXGISwapChain_Release(swapchain); release_test_context(&ctx); - DestroyWindow(window); }
static void test_gdi_interop(void) @@ -7696,14 +7656,12 @@ static void test_layer(void) ID2D1Layer *layer; D2D1_SIZE_F size; ULONG refcount; - HWND window; HRESULT hr;
if (!init_test_context(&ctx)) return;
- window = create_window(); - swapchain = create_swapchain(ctx.device, window, TRUE); + swapchain = create_swapchain(ctx.device, ctx.window, TRUE); hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface); ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr); rt = create_render_target(surface); @@ -7737,7 +7695,6 @@ static void test_layer(void) IDXGISurface_Release(surface); IDXGISwapChain_Release(swapchain); release_test_context(&ctx); - DestroyWindow(window); }
static void test_bezier_intersect(void) @@ -7753,15 +7710,13 @@ static void test_bezier_intersect(void) ID2D1Factory *factory; D2D1_COLOR_F color; ULONG refcount; - HWND window; HRESULT hr; BOOL match;
if (!init_test_context(&ctx)) return;
- window = create_window(); - swapchain = create_swapchain(ctx.device, window, TRUE); + swapchain = create_swapchain(ctx.device, ctx.window, TRUE); hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface); ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr); rt = create_render_target(surface); @@ -7885,7 +7840,6 @@ static void test_bezier_intersect(void) IDXGISurface_Release(surface); IDXGISwapChain_Release(swapchain); release_test_context(&ctx); - DestroyWindow(window); }
static void test_create_device(void) @@ -8172,7 +8126,6 @@ static void test_bitmap_surface(void) D2D1_SIZE_U size; D2D1_TAG t1, t2; unsigned int i; - HWND window; HRESULT hr;
IWICBitmap *wic_bitmap; @@ -8189,8 +8142,7 @@ static void test_bitmap_surface(void) }
/* DXGI target */ - window = create_window(); - swapchain = create_swapchain(ctx.device, window, TRUE); + swapchain = create_swapchain(ctx.device, ctx.window, TRUE); hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface); ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr); rt = create_render_target(surface); @@ -8401,7 +8353,6 @@ static void test_device_context(void) ID2D1RenderTarget *rt; ID2D1Bitmap1 *bitmap; ID2D1Image *target; - HWND window; HRESULT hr; RECT rect; HDC hdc; @@ -8443,8 +8394,7 @@ static void test_device_context(void) ID2D1DeviceContext_Release(device_context);
/* DXGI target */ - window = create_window(); - swapchain = create_swapchain(ctx.device, window, TRUE); + swapchain = create_swapchain(ctx.device, ctx.window, TRUE); hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface); ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr); rt = create_render_target(surface); @@ -8476,7 +8426,6 @@ static void test_device_context(void) ID2D1DeviceContext_Release(device_context); ID2D1RenderTarget_Release(rt); IDXGISurface_Release(surface); - DestroyWindow(window);
/* WIC target */ CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); @@ -9108,7 +9057,6 @@ static void test_dpi(void) IDXGISurface *surface; ID2D1Bitmap1 *bitmap; float dpi_x, dpi_y; - HWND window; HRESULT hr;
static const struct @@ -9141,8 +9089,7 @@ static void test_dpi(void) return; }
- window = create_window(); - swapchain = create_swapchain(ctx.device, window, TRUE); + swapchain = create_swapchain(ctx.device, ctx.window, TRUE); hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface); ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
@@ -9316,7 +9263,6 @@ static void test_dpi(void) IDXGISwapChain_Release(swapchain); ID2D1Factory1_Release(factory); release_test_context(&ctx); - DestroyWindow(window); }
static void test_wic_bitmap_format(void) @@ -9330,7 +9276,6 @@ static void test_wic_bitmap_format(void) IDXGISurface *surface; ID2D1Bitmap *bitmap; unsigned int i; - HWND window; HRESULT hr;
static const struct @@ -9348,8 +9293,7 @@ static void test_wic_bitmap_format(void) if (!init_test_context(&ctx)) return;
- window = create_window(); - swapchain = create_swapchain(ctx.device, window, TRUE); + swapchain = create_swapchain(ctx.device, ctx.window, TRUE); hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface); ok(hr == S_OK, "Failed to get buffer, hr %#x.\n", hr); rt = create_render_target(surface); @@ -9385,7 +9329,6 @@ static void test_wic_bitmap_format(void) IDXGISurface_Release(surface); IDXGISwapChain_Release(swapchain); release_test_context(&ctx); - DestroyWindow(window); }
static void test_math(void)