[v2 PATCH 2/2] d2d1/tests: Add a simple test creating d2d device.

Nikolay Sivov nsivov at codeweavers.com
Tue May 15 15:14:37 CDT 2018


Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
 dlls/d2d1/tests/d2d1.c | 45 +++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 44 insertions(+), 1 deletion(-)

diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c
index 9bd9e2b19d..1bb1a38c9c 100644
--- a/dlls/d2d1/tests/d2d1.c
+++ b/dlls/d2d1/tests/d2d1.c
@@ -19,7 +19,7 @@
 #define COBJMACROS
 #include <limits.h>
 #include <math.h>
-#include "d2d1.h"
+#include "d2d1_1.h"
 #include "wincrypt.h"
 #include "wine/test.h"
 #include "initguid.h"
@@ -6426,6 +6426,48 @@ 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;
+    }
+
+    hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &IID_ID2D1Factory1, NULL, (void **)&factory);
+    if (FAILED(hr))
+    {
+        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.\n");
+
+    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, "Unexpected factory pointer.\n");
+    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 +6496,5 @@ START_TEST(d2d1)
     test_gdi_interop();
     test_layer();
     test_bezier_intersect();
+    test_create_device();
 }
-- 
2.17.0




More information about the wine-devel mailing list