diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index f8332946b95..8299ceb7d4d 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -19,7 +19,7 @@ #define COBJMACROS #include #include -#include "d2d1.h" +#include "d2d1_1.h" #include "wincrypt.h" #include "wine/test.h" #include "initguid.h" @@ -6426,6 +6426,47 @@ static void test_bezier_intersect(void) DestroyWindow(window); } +static void test_create_device(void) +{ + ID3D10Device1 *d3d_device; + IDXGIDevice *dxgi_device; + ID2D1Factory1 *factory; + ID2D1Factory *factory2; + ID2D1Device *device; + ULONG refcount; + HRESULT hr; + + if (!(d3d_device = create_device())) + { + skip("Failed to create device, skipping tests.\n"); + return; + } + + if (FAILED(D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &IID_ID2D1Factory1, NULL, (void **)&factory))) + { + win_skip("ID2D1Factory1 is not supported.\n"); + ID3D10Device1_Release(d3d_device); + return; + } + + hr = ID3D10Device1_QueryInterface(d3d_device, &IID_IDXGIDevice, (void **)&dxgi_device); + ok(SUCCEEDED(hr), "Failed to get IDXGIDevice interface, hr %#x.\n", hr); + + hr = ID2D1Factory1_CreateDevice(factory, dxgi_device, &device); + ok(SUCCEEDED(hr), "Failed to get ID2D1Device, hr %#x.\n", hr); + + ID2D1Device_GetFactory(device, &factory2); + ok(factory2 == (ID2D1Factory *)factory, "Got unexpected factory %p, expected %p.\n", factory2, factory); + ID2D1Factory_Release(factory2); + ID2D1Device_Release(device); + + IDXGIDevice_Release(dxgi_device); + ID3D10Device1_Release(d3d_device); + + refcount = ID2D1Factory1_Release(factory); + ok(!refcount, "Factory has %u references left.\n", refcount); +} + START_TEST(d2d1) { test_clip(); @@ -6454,4 +6495,5 @@ START_TEST(d2d1) test_gdi_interop(); test_layer(); test_bezier_intersect(); + test_create_device(); }