d3d10core/tests: Add test for ID3D10Device_CreateQuery().

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2016-04-05 10:22:08 +02:00 committed by Alexandre Julliard
parent 94ec23b8cd
commit f0766c49ef
1 changed files with 51 additions and 21 deletions

View File

@ -2267,25 +2267,34 @@ static void test_create_rasterizer_state(void)
ok(!refcount, "Device has %u references left.\n", refcount);
}
static void test_create_predicate(void)
static void test_create_query(void)
{
static const D3D10_QUERY other_queries[] =
static const struct
{
D3D10_QUERY_EVENT,
D3D10_QUERY_OCCLUSION,
D3D10_QUERY_TIMESTAMP,
D3D10_QUERY_TIMESTAMP_DISJOINT,
D3D10_QUERY_PIPELINE_STATISTICS,
D3D10_QUERY_SO_STATISTICS,
D3D10_QUERY query;
BOOL is_predicate;
BOOL todo;
}
tests[] =
{
{D3D10_QUERY_EVENT, FALSE, FALSE},
{D3D10_QUERY_OCCLUSION, FALSE, FALSE},
{D3D10_QUERY_TIMESTAMP, FALSE, FALSE},
{D3D10_QUERY_TIMESTAMP_DISJOINT, FALSE, FALSE},
{D3D10_QUERY_PIPELINE_STATISTICS, FALSE, TRUE},
{D3D10_QUERY_OCCLUSION_PREDICATE, TRUE, FALSE},
{D3D10_QUERY_SO_STATISTICS, FALSE, TRUE},
{D3D10_QUERY_SO_OVERFLOW_PREDICATE, TRUE, TRUE},
};
ULONG refcount, expected_refcount;
D3D10_QUERY_DESC query_desc;
ID3D10Predicate *predicate;
ID3D10Device *device, *tmp;
HRESULT hr, expected_hr;
ID3D10Query *query;
IUnknown *iface;
unsigned int i;
HRESULT hr;
if (!(device = create_device()))
{
@ -2293,16 +2302,43 @@ static void test_create_predicate(void)
return;
}
hr = ID3D10Device_CreateQuery(device, NULL, &query);
ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
hr = ID3D10Device_CreatePredicate(device, NULL, &predicate);
ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
query_desc.MiscFlags = 0;
for (i = 0; i < sizeof(other_queries) / sizeof(*other_queries); ++i)
for (i = 0; i < sizeof(tests) / sizeof(*tests); ++i)
{
query_desc.Query = other_queries[i];
query_desc.Query = tests[i].query;
query_desc.MiscFlags = 0;
hr = ID3D10Device_CreateQuery(device, &query_desc, NULL);
todo_wine_if(tests[i].todo)
ok(hr == S_FALSE, "Got unexpected hr %#x for query type %u.\n", hr, query_desc.Query);
query_desc.Query = tests[i].query;
hr = ID3D10Device_CreateQuery(device, &query_desc, &query);
todo_wine_if(tests[i].todo)
ok(hr == S_OK, "Got unexpected hr %#x for query type %u.\n", hr, query_desc.Query);
if (FAILED(hr))
continue;
expected_hr = tests[i].is_predicate ? S_OK : E_NOINTERFACE;
hr = ID3D10Query_QueryInterface(query, &IID_ID3D10Predicate, (void **)&predicate);
ID3D10Query_Release(query);
ok(hr == expected_hr, "Got unexpected hr %#x for query type %u.\n", hr, query_desc.Query);
if (SUCCEEDED(hr))
ID3D10Predicate_Release(predicate);
expected_hr = tests[i].is_predicate ? S_FALSE : E_INVALIDARG;
hr = ID3D10Device_CreatePredicate(device, &query_desc, NULL);
ok(hr == expected_hr, "Got unexpected hr %#x for query type %u.\n", hr, query_desc.Query);
expected_hr = tests[i].is_predicate ? S_OK : E_INVALIDARG;
hr = ID3D10Device_CreatePredicate(device, &query_desc, &predicate);
ok(hr == E_INVALIDARG, "Got unexpected hr %#x for query type %u.\n", hr, other_queries[i]);
ok(hr == expected_hr, "Got unexpected hr %#x for query type %u.\n", hr, query_desc.Query);
if (SUCCEEDED(hr))
ID3D10Predicate_Release(predicate);
}
query_desc.Query = D3D10_QUERY_OCCLUSION_PREDICATE;
@ -2324,12 +2360,6 @@ static void test_create_predicate(void)
if (SUCCEEDED(hr)) IUnknown_Release(iface);
ID3D10Predicate_Release(predicate);
query_desc.Query = D3D10_QUERY_SO_OVERFLOW_PREDICATE;
hr = ID3D10Device_CreatePredicate(device, &query_desc, &predicate);
todo_wine ok(SUCCEEDED(hr), "Failed to create predicate, hr %#x.\n", hr);
if (SUCCEEDED(hr))
ID3D10Predicate_Release(predicate);
refcount = ID3D10Device_Release(device);
ok(!refcount, "Device has %u references left.\n", refcount);
}
@ -6248,7 +6278,7 @@ START_TEST(device)
test_create_blend_state();
test_create_depthstencil_state();
test_create_rasterizer_state();
test_create_predicate();
test_create_query();
test_device_removed_reason();
test_scissor();
test_clear_state();