Skip to content

Commit

Permalink
tests: Some edge cases with NULL Create/QueryInterface calls.
Browse files Browse the repository at this point in the history
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
  • Loading branch information
HansKristian-Work committed Jun 30, 2023
1 parent f49d9f9 commit c8acc68
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tests/d3d12_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -1098,6 +1098,44 @@ void test_reset_command_allocator(void)
ok(!refcount, "ID3D12Device has %u references left.\n", (unsigned int)refcount);
}

void test_object_interface_null_cases(void)
{
ID3D12Device *device;
ID3D12Fence *fence;
HRESULT hr;
UINT ref;

if (!(device = create_device()))
{
skip("Failed to create device.\n");
return;
}

hr = ID3D12Device_CreateFence(device, 0, D3D12_FENCE_FLAG_NONE, &IID_ID3D12Fence, (void **)&fence);
ok(SUCCEEDED(hr), "Failed to create fence, hr #%x.\n", hr);

hr = ID3D12Device_CreateFence(device, 0, D3D12_FENCE_FLAG_NONE, &IID_ID3D12Fence, NULL);
ok(hr == S_FALSE, "Unexpected hr #%x.\n", hr);

/* S_FALSE is returned even for bogus requested interfaces. */
hr = ID3D12Device_CreateFence(device, 0, D3D12_FENCE_FLAG_NONE, &IID_ID3D12Heap, NULL);
ok(hr == S_FALSE, "Unexpected hr #%x.\n", hr);

/* E_POINTER is always returned if QueryInterface ppOutput is NULL. */
hr = ID3D12Fence_QueryInterface(fence, &IID_IUnknown, NULL);
ok(hr == E_POINTER, "Unexpected hr #%x.\n", hr);

hr = ID3D12Fence_QueryInterface(fence, &IID_ID3D12Fence, NULL);
ok(hr == E_POINTER, "Unexpected hr #%x.\n", hr);

hr = ID3D12Fence_QueryInterface(fence, &IID_ID3D12Heap, NULL);
ok(hr == E_POINTER, "Unexpected hr #%x.\n", hr);

ID3D12Fence_Release(fence);
ref = ID3D12Device_Release(device);
ok(ref == 0, "Unexpected ref-count %u\n", ref);
}

void test_object_interface(void)
{
D3D12_DESCRIPTOR_HEAP_DESC descriptor_heap_desc;
Expand Down
1 change: 1 addition & 0 deletions tests/d3d12_tests.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ decl_test(test_create_graphics_pipeline_state);
decl_test(test_create_pipeline_state);
decl_test(test_create_fence);
decl_test(test_object_interface);
decl_test(test_object_interface_null_cases);
decl_test(test_multithread_private_data);
decl_test(test_reset_command_allocator);
decl_test(test_cpu_signal_fence);
Expand Down

0 comments on commit c8acc68

Please sign in to comment.