d3d11/tests: Add test for D3D11CreateDevice.

This commit is contained in:
Józef Kucia 2015-08-24 01:04:27 +02:00 committed by Alexandre Julliard
parent 4cf1bb929f
commit 6038e2ab79

View file

@ -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();
}