mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-01 17:43:38 +00:00
dxgi/tests: Add private data tests.
This commit is contained in:
parent
24187d5397
commit
7983d9974b
|
@ -23,6 +23,12 @@
|
|||
|
||||
static HRESULT (WINAPI *pCreateDXGIFactory1)(REFIID iid, void **factory);
|
||||
|
||||
static ULONG get_refcount(IUnknown *iface)
|
||||
{
|
||||
IUnknown_AddRef(iface);
|
||||
return IUnknown_Release(iface);
|
||||
}
|
||||
|
||||
static IDXGIDevice *create_device(void)
|
||||
{
|
||||
IDXGIDevice *dxgi_device;
|
||||
|
@ -578,6 +584,142 @@ static void test_create_factory(void)
|
|||
IUnknown_Release(iface);
|
||||
}
|
||||
|
||||
static void test_private_data(void)
|
||||
{
|
||||
ULONG refcount, expected_refcount;
|
||||
IDXGIDevice *device;
|
||||
HRESULT hr;
|
||||
IDXGIDevice *test_object;
|
||||
IUnknown *ptr;
|
||||
static const DWORD data[] = {1, 2, 3, 4};
|
||||
UINT size;
|
||||
static const GUID dxgi_private_data_test_guid =
|
||||
{
|
||||
0xfdb37466,
|
||||
0x428f,
|
||||
0x4edf,
|
||||
{0xa3, 0x7f, 0x9b, 0x1d, 0xf4, 0x88, 0xc5, 0xfc}
|
||||
};
|
||||
static const GUID dxgi_private_data_test_guid2 =
|
||||
{
|
||||
0x2e5afac2,
|
||||
0x87b5,
|
||||
0x4c10,
|
||||
{0x9b, 0x4b, 0x89, 0xd7, 0xd1, 0x12, 0xe7, 0x2b}
|
||||
};
|
||||
|
||||
if (!(device = create_device()))
|
||||
{
|
||||
skip("Failed to create device, skipping tests.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
test_object = create_device();
|
||||
|
||||
/* SetPrivateData with a pointer of NULL has the purpose of FreePrivateData in previous
|
||||
* d3d versions. A successful clear returns S_OK. A redundant clear S_FALSE. Setting a
|
||||
* NULL interface is not considered a clear but as setting an interface pointer that
|
||||
* happens to be NULL. */
|
||||
hr = IDXGIDevice_SetPrivateData(device, &dxgi_private_data_test_guid, 0, NULL);
|
||||
todo_wine ok(hr == S_FALSE, "Got unexpected hr %#x.\n", hr);
|
||||
hr = IDXGIDevice_SetPrivateDataInterface(device, &dxgi_private_data_test_guid, NULL);
|
||||
todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
hr = IDXGIDevice_SetPrivateData(device, &dxgi_private_data_test_guid, ~0U, NULL);
|
||||
todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
hr = IDXGIDevice_SetPrivateData(device, &dxgi_private_data_test_guid, ~0U, NULL);
|
||||
todo_wine ok(hr == S_FALSE, "Got unexpected hr %#x.\n", hr);
|
||||
|
||||
hr = IDXGIDevice_SetPrivateDataInterface(device, &dxgi_private_data_test_guid, NULL);
|
||||
todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
size = sizeof(ptr) * 2;
|
||||
ptr = (IUnknown *)0xdeadbeef;
|
||||
hr = IDXGIDevice_GetPrivateData(device, &dxgi_private_data_test_guid, &size, &ptr);
|
||||
todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
todo_wine ok(!ptr, "Got unexpected pointer %p.\n", ptr);
|
||||
todo_wine ok(size == sizeof(IUnknown *), "Got unexpected size %u.\n", size);
|
||||
|
||||
refcount = get_refcount((IUnknown *)test_object);
|
||||
hr = IDXGIDevice_SetPrivateDataInterface(device, &dxgi_private_data_test_guid,
|
||||
(IUnknown *)test_object);
|
||||
todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
expected_refcount = refcount + 1;
|
||||
refcount = get_refcount((IUnknown *)test_object);
|
||||
todo_wine ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount);
|
||||
hr = IDXGIDevice_SetPrivateDataInterface(device, &dxgi_private_data_test_guid,
|
||||
(IUnknown *)test_object);
|
||||
todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
refcount = get_refcount((IUnknown *)test_object);
|
||||
todo_wine ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount);
|
||||
|
||||
hr = IDXGIDevice_SetPrivateDataInterface(device, &dxgi_private_data_test_guid, NULL);
|
||||
todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
expected_refcount--;
|
||||
refcount = get_refcount((IUnknown *)test_object);
|
||||
ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount);
|
||||
|
||||
hr = IDXGIDevice_SetPrivateDataInterface(device, &dxgi_private_data_test_guid,
|
||||
(IUnknown *)test_object);
|
||||
todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
size = sizeof(data);
|
||||
hr = IDXGIDevice_SetPrivateData(device, &dxgi_private_data_test_guid, size, data);
|
||||
todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
refcount = get_refcount((IUnknown *)test_object);
|
||||
ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount);
|
||||
hr = IDXGIDevice_SetPrivateData(device, &dxgi_private_data_test_guid, 42, NULL);
|
||||
todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
hr = IDXGIDevice_SetPrivateData(device, &dxgi_private_data_test_guid, 42, NULL);
|
||||
todo_wine ok(hr == S_FALSE, "Got unexpected hr %#x.\n", hr);
|
||||
|
||||
hr = IDXGIDevice_SetPrivateDataInterface(device, &dxgi_private_data_test_guid,
|
||||
(IUnknown *)test_object);
|
||||
todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
expected_refcount++;
|
||||
size = 2 * sizeof(ptr);
|
||||
ptr = NULL;
|
||||
hr = IDXGIDevice_GetPrivateData(device, &dxgi_private_data_test_guid, &size, &ptr);
|
||||
todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
todo_wine ok(size == sizeof(test_object), "Got unexpected size %u.\n", size);
|
||||
expected_refcount++;
|
||||
refcount = get_refcount((IUnknown *)test_object);
|
||||
todo_wine ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount);
|
||||
if (ptr)
|
||||
IUnknown_Release(ptr);
|
||||
expected_refcount--;
|
||||
|
||||
ptr = (IUnknown *)0xdeadbeef;
|
||||
size = 1;
|
||||
hr = IDXGIDevice_GetPrivateData(device, &dxgi_private_data_test_guid, &size, NULL);
|
||||
todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
todo_wine ok(size == sizeof(device), "Got unexpected size %u.\n", size);
|
||||
size = 2 * sizeof(ptr);
|
||||
hr = IDXGIDevice_GetPrivateData(device, &dxgi_private_data_test_guid, &size, NULL);
|
||||
todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
todo_wine ok(size == sizeof(device), "Got unexpected size %u.\n", size);
|
||||
refcount = get_refcount((IUnknown *)test_object);
|
||||
todo_wine ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount);
|
||||
|
||||
size = 1;
|
||||
hr = IDXGIDevice_GetPrivateData(device, &dxgi_private_data_test_guid, &size, &ptr);
|
||||
todo_wine ok(hr == DXGI_ERROR_MORE_DATA, "Got unexpected hr %#x.\n", hr);
|
||||
todo_wine ok(size == sizeof(device), "Got unexpected size %u.\n", size);
|
||||
ok(ptr == (IUnknown *)0xdeadbeef, "Got unexpected pointer %p.\n", ptr);
|
||||
hr = IDXGIDevice_GetPrivateData(device, &dxgi_private_data_test_guid2, NULL, NULL);
|
||||
todo_wine ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
|
||||
size = 0xdeadbabe;
|
||||
hr = IDXGIDevice_GetPrivateData(device, &dxgi_private_data_test_guid2, &size, &ptr);
|
||||
todo_wine ok(hr == DXGI_ERROR_NOT_FOUND, "Got unexpected hr %#x.\n", hr);
|
||||
todo_wine ok(size == 0, "Got unexpected size %u.\n", size);
|
||||
ok(ptr == (IUnknown *)0xdeadbeef, "Got unexpected pointer %p.\n", ptr);
|
||||
hr = IDXGIDevice_GetPrivateData(device, &dxgi_private_data_test_guid, NULL, &ptr);
|
||||
todo_wine ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
|
||||
ok(ptr == (IUnknown *)0xdeadbeef, "Got unexpected pointer %p.\n", ptr);
|
||||
|
||||
refcount = IDXGIDevice_Release(device);
|
||||
ok(!refcount, "Device has %u references left.\n", refcount);
|
||||
refcount = IDXGIDevice_Release(test_object);
|
||||
ok(!refcount, "Test object has %u references left.\n", refcount);
|
||||
}
|
||||
|
||||
START_TEST(device)
|
||||
{
|
||||
pCreateDXGIFactory1 = (void *)GetProcAddress(GetModuleHandleA("dxgi.dll"), "CreateDXGIFactory1");
|
||||
|
@ -589,4 +731,5 @@ START_TEST(device)
|
|||
test_output();
|
||||
test_createswapchain();
|
||||
test_create_factory();
|
||||
test_private_data();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue