=?UTF-8?Q?J=C3=B3zef=20Kucia=20?=: d3d11/tests: Add test for D3D11CreateDevice.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Aug 24 07:37:16 CDT 2015


Module: wine
Branch: master
Commit: 6038e2ab7957b65dd2e13ddd414c206718fb14b7
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=6038e2ab7957b65dd2e13ddd414c206718fb14b7

Author: Józef Kucia <jkucia at codeweavers.com>
Date:   Mon Aug 24 01:04:27 2015 +0200

d3d11/tests: Add test for D3D11CreateDevice.

---

 dlls/d3d11/tests/d3d11.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)

diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c
index 0595ead..f313806 100644
--- a/dlls/d3d11/tests/d3d11.c
+++ b/dlls/d3d11/tests/d3d11.c
@@ -21,6 +21,12 @@
 #include "d3d11.h"
 #include "wine/test.h"
 
+static ULONG get_refcount(IUnknown *iface)
+{
+    IUnknown_AddRef(iface);
+    return IUnknown_Release(iface);
+}
+
 static ID3D11Device *create_device(D3D_FEATURE_LEVEL feature_level)
 {
     ID3D11Device *device;
@@ -38,6 +44,52 @@ static ID3D11Device *create_device(D3D_FEATURE_LEVEL feature_level)
     return NULL;
 }
 
+static void test_create_device(void)
+{
+    D3D_FEATURE_LEVEL feature_level, supported_feature_level;
+    ID3D11DeviceContext *immediate_context = NULL;
+    ID3D11Device *device;
+    ULONG refcount;
+    HRESULT hr;
+
+    hr = D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, NULL, 0, D3D11_SDK_VERSION, &device,
+            NULL, NULL);
+    if (FAILED(hr))
+    {
+        skip("Failed to create HAL device, skipping tests.\n");
+        return;
+    }
+
+    supported_feature_level = ID3D11Device_GetFeatureLevel(device);
+    ID3D11Device_Release(device);
+
+    hr = D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, NULL, 0, D3D11_SDK_VERSION, NULL, NULL, NULL);
+    ok(SUCCEEDED(hr), "D3D11CreateDevice failed %#x.\n", hr);
+
+    hr = D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, NULL, 0, D3D11_SDK_VERSION, NULL,
+            &feature_level, NULL);
+    ok(SUCCEEDED(hr), "D3D11CreateDevice failed %#x.\n", hr);
+    ok(feature_level == supported_feature_level, "Got feature level %#x, expected %#x.\n",
+            feature_level, supported_feature_level);
+
+    hr = D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, NULL, 0, D3D11_SDK_VERSION, NULL, NULL,
+            &immediate_context);
+    ok(SUCCEEDED(hr), "D3D11CreateDevice failed %#x.\n", hr);
+
+    todo_wine ok(!!immediate_context, "Immediate context is NULL.\n");
+    if (!immediate_context) return;
+
+    refcount = get_refcount((IUnknown *)immediate_context);
+    ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
+
+    ID3D11DeviceContext_GetDevice(immediate_context, &device);
+    refcount = ID3D11Device_Release(device);
+    ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
+
+    refcount = ID3D11DeviceContext_Release(immediate_context);
+    ok(!refcount, "ID3D11DeviceContext has %u references left.\n", refcount);
+}
+
 static void test_device_interfaces(void)
 {
     static const D3D_FEATURE_LEVEL feature_levels[] =
@@ -96,5 +148,6 @@ static void test_device_interfaces(void)
 
 START_TEST(d3d11)
 {
+    test_create_device();
     test_device_interfaces();
 }




More information about the wine-cvs mailing list