mfplat/tests: Add a helper to check for supported interfaces.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2020-11-16 17:50:17 +03:00 committed by Alexandre Julliard
parent 564d5804b1
commit bf7e6d1773
1 changed files with 36 additions and 54 deletions

View File

@ -70,6 +70,21 @@ static void _expect_ref(IUnknown *obj, ULONG ref, int line)
ok_(__FILE__,line)(rc == ref, "Unexpected refcount %d, expected %d.\n", rc, ref); ok_(__FILE__,line)(rc == ref, "Unexpected refcount %d, expected %d.\n", rc, ref);
} }
#define check_interface(a, b, c) check_interface_(__LINE__, a, b, c)
static void check_interface_(unsigned int line, void *iface_ptr, REFIID iid, BOOL supported)
{
IUnknown *iface = iface_ptr;
HRESULT hr, expected_hr;
IUnknown *unk;
expected_hr = supported ? S_OK : E_NOINTERFACE;
hr = IUnknown_QueryInterface(iface, iid, (void **)&unk);
ok_(__FILE__, line)(hr == expected_hr, "Got hr %#x, expected %#x.\n", hr, expected_hr);
if (SUCCEEDED(hr))
IUnknown_Release(unk);
}
static HRESULT (WINAPI *pD3D11CreateDevice)(IDXGIAdapter *adapter, D3D_DRIVER_TYPE driver_type, HMODULE swrast, UINT flags, static HRESULT (WINAPI *pD3D11CreateDevice)(IDXGIAdapter *adapter, D3D_DRIVER_TYPE driver_type, HMODULE swrast, UINT flags,
const D3D_FEATURE_LEVEL *feature_levels, UINT levels, UINT sdk_version, ID3D11Device **device_out, const D3D_FEATURE_LEVEL *feature_levels, UINT levels, UINT sdk_version, ID3D11Device **device_out,
D3D_FEATURE_LEVEL *obtained_feature_level, ID3D11DeviceContext **immediate_context); D3D_FEATURE_LEVEL *obtained_feature_level, ID3D11DeviceContext **immediate_context);
@ -867,8 +882,8 @@ if(0)
hr = MFCreateMediaType(&mediatype); hr = MFCreateMediaType(&mediatype);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr); ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = IMFMediaType_QueryInterface(mediatype, &IID_IMFVideoMediaType, (void **)&unk); check_interface(mediatype, &IID_IMFVideoMediaType, FALSE);
ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr);
hr = IMFMediaType_QueryInterface(mediatype, &IID_IUnknown, (void **)&unk); hr = IMFMediaType_QueryInterface(mediatype, &IID_IUnknown, (void **)&unk);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr); ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ok(unk == (IUnknown *)mediatype, "Unexpected pointer.\n"); ok(unk == (IUnknown *)mediatype, "Unexpected pointer.\n");
@ -899,13 +914,9 @@ if(0)
hr = MFCreateVideoMediaTypeFromSubtype(&MFVideoFormat_RGB555, &video_type); hr = MFCreateVideoMediaTypeFromSubtype(&MFVideoFormat_RGB555, &video_type);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr); ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = IMFVideoMediaType_QueryInterface(video_type, &IID_IMFMediaType, (void **)&unk);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
IUnknown_Release(unk);
hr = IMFVideoMediaType_QueryInterface(video_type, &IID_IMFVideoMediaType, (void **)&unk); check_interface(video_type, &IID_IMFMediaType, TRUE);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr); check_interface(video_type, &IID_IMFVideoMediaType, TRUE);
IUnknown_Release(unk);
/* Major and subtype are set on creation. */ /* Major and subtype are set on creation. */
hr = IMFVideoMediaType_GetCount(video_type, &count); hr = IMFVideoMediaType_GetCount(video_type, &count);
@ -917,8 +928,7 @@ if(0)
hr = IMFVideoMediaType_GetCount(video_type, &count); hr = IMFVideoMediaType_GetCount(video_type, &count);
ok(!count, "Unexpected attribute count %#x.\n", hr); ok(!count, "Unexpected attribute count %#x.\n", hr);
hr = IMFVideoMediaType_QueryInterface(video_type, &IID_IMFVideoMediaType, (void **)&unk); check_interface(video_type, &IID_IMFVideoMediaType, FALSE);
ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr);
IMFVideoMediaType_Release(video_type); IMFVideoMediaType_Release(video_type);
@ -928,8 +938,8 @@ if(0)
hr = MFCreateMediaType(&mediatype); hr = MFCreateMediaType(&mediatype);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr); ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = IMFMediaType_QueryInterface(mediatype, &IID_IMFAudioMediaType, (void **)&unk); check_interface(mediatype, &IID_IMFAudioMediaType, FALSE);
ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr);
hr = IMFMediaType_QueryInterface(mediatype, &IID_IUnknown, (void **)&unk); hr = IMFMediaType_QueryInterface(mediatype, &IID_IUnknown, (void **)&unk);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr); ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ok(unk == (IUnknown *)mediatype, "Unexpected pointer.\n"); ok(unk == (IUnknown *)mediatype, "Unexpected pointer.\n");
@ -1620,17 +1630,10 @@ static void test_MFCreateMFByteStreamOnStream(void)
ref = IMFByteStream_Release(bytestream2); ref = IMFByteStream_Release(bytestream2);
ok(ref == 2, "got %u\n", ref); ok(ref == 2, "got %u\n", ref);
hr = IMFByteStream_QueryInterface(bytestream, &IID_IMFByteStreamBuffering, (void **)&unknown); check_interface(bytestream, &IID_IMFByteStreamBuffering, FALSE);
ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr); check_interface(bytestream, &IID_IMFByteStreamCacheControl, FALSE);
check_interface(bytestream, &IID_IMFMediaEventGenerator, FALSE);
hr = IMFByteStream_QueryInterface(bytestream, &IID_IMFByteStreamCacheControl, (void **)&unknown); check_interface(bytestream, &IID_IMFGetService, FALSE);
ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr);
hr = IMFByteStream_QueryInterface(bytestream, &IID_IMFMediaEventGenerator, (void **)&unknown);
ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr);
hr = IMFByteStream_QueryInterface(bytestream, &IID_IMFGetService, (void **)&unknown);
ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr);
hr = IMFByteStream_GetCapabilities(bytestream, &caps); hr = IMFByteStream_GetCapabilities(bytestream, &caps);
ok(hr == S_OK, "Failed to get stream capabilities, hr %#x.\n", hr); ok(hr == S_OK, "Failed to get stream capabilities, hr %#x.\n", hr);
@ -1666,7 +1669,6 @@ static void test_file_stream(void)
WCHAR pathW[MAX_PATH]; WCHAR pathW[MAX_PATH];
DWORD caps, count; DWORD caps, count;
WCHAR *filename; WCHAR *filename;
IUnknown *unk;
HRESULT hr; HRESULT hr;
WCHAR *str; WCHAR *str;
BOOL eos; BOOL eos;
@ -1680,18 +1682,10 @@ static void test_file_stream(void)
MF_FILEFLAGS_NONE, filename, &bytestream); MF_FILEFLAGS_NONE, filename, &bytestream);
ok(hr == S_OK, "got 0x%08x\n", hr); ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IMFByteStream_QueryInterface(bytestream, &IID_IMFByteStreamBuffering, (void **)&unk); check_interface(bytestream, &IID_IMFByteStreamBuffering, FALSE);
ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr); check_interface(bytestream, &IID_IMFByteStreamCacheControl, FALSE);
check_interface(bytestream, &IID_IMFMediaEventGenerator, FALSE);
hr = IMFByteStream_QueryInterface(bytestream, &IID_IMFByteStreamCacheControl, (void **)&unk); check_interface(bytestream, &IID_IMFGetService, TRUE);
ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr);
hr = IMFByteStream_QueryInterface(bytestream, &IID_IMFMediaEventGenerator, (void **)&unk);
ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr);
hr = IMFByteStream_QueryInterface(bytestream, &IID_IMFGetService, (void **)&unk);
ok(hr == S_OK, "Failed to get interface pointer, hr %#x.\n", hr);
IUnknown_Release(unk);
hr = IMFByteStream_GetCapabilities(bytestream, &caps); hr = IMFByteStream_GetCapabilities(bytestream, &caps);
ok(hr == S_OK, "Failed to get stream capabilities, hr %#x.\n", hr); ok(hr == S_OK, "Failed to get stream capabilities, hr %#x.\n", hr);
@ -1818,7 +1812,6 @@ static void test_system_memory_buffer(void)
HRESULT hr; HRESULT hr;
DWORD length, max; DWORD length, max;
BYTE *data, *data2; BYTE *data, *data2;
IUnknown *unk;
hr = MFCreateMemoryBuffer(1024, NULL); hr = MFCreateMemoryBuffer(1024, NULL);
ok(hr == E_INVALIDARG || hr == E_POINTER, "got 0x%08x\n", hr); ok(hr == E_INVALIDARG || hr == E_POINTER, "got 0x%08x\n", hr);
@ -1837,8 +1830,7 @@ static void test_system_memory_buffer(void)
hr = MFCreateMemoryBuffer(1024, &buffer); hr = MFCreateMemoryBuffer(1024, &buffer);
ok(hr == S_OK, "got 0x%08x\n", hr); ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IMFMediaBuffer_QueryInterface(buffer, &IID_IMFGetService, (void **)&unk); check_interface(buffer, &IID_IMFGetService, FALSE);
ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr);
hr = IMFMediaBuffer_GetMaxLength(buffer, NULL); hr = IMFMediaBuffer_GetMaxLength(buffer, NULL);
ok(hr == E_INVALIDARG || hr == E_POINTER, "got 0x%08x\n", hr); ok(hr == E_INVALIDARG || hr == E_POINTER, "got 0x%08x\n", hr);
@ -4443,7 +4435,6 @@ static void test_create_property_store(void)
PROPVARIANT value = {0}; PROPVARIANT value = {0};
PROPERTYKEY key; PROPERTYKEY key;
ULONG refcount; ULONG refcount;
IUnknown *unk;
DWORD count; DWORD count;
HRESULT hr; HRESULT hr;
@ -4458,10 +4449,8 @@ static void test_create_property_store(void)
ok(store2 != store, "Expected different store objects.\n"); ok(store2 != store, "Expected different store objects.\n");
IPropertyStore_Release(store2); IPropertyStore_Release(store2);
hr = IPropertyStore_QueryInterface(store, &IID_IPropertyStoreCache, (void **)&unk); check_interface(store, &IID_IPropertyStoreCache, FALSE);
ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr); check_interface(store, &IID_IPersistSerializedPropStorage, FALSE);
hr = IPropertyStore_QueryInterface(store, &IID_IPersistSerializedPropStorage, (void **)&unk);
ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr);
hr = IPropertyStore_GetCount(store, NULL); hr = IPropertyStore_GetCount(store, NULL);
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
@ -5195,7 +5184,6 @@ static void test_MFCreate2DMediaBuffer(void)
IMF2DBuffer *_2dbuffer; IMF2DBuffer *_2dbuffer;
IMFMediaBuffer *buffer; IMFMediaBuffer *buffer;
int i, pitch, pitch2; int i, pitch, pitch2;
IUnknown *unk;
HRESULT hr; HRESULT hr;
BOOL ret; BOOL ret;
@ -5218,9 +5206,7 @@ static void test_MFCreate2DMediaBuffer(void)
hr = pMFCreate2DMediaBuffer(2, 3, MAKEFOURCC('N','V','1','2'), FALSE, &buffer); hr = pMFCreate2DMediaBuffer(2, 3, MAKEFOURCC('N','V','1','2'), FALSE, &buffer);
ok(hr == S_OK, "Failed to create a buffer, hr %#x.\n", hr); ok(hr == S_OK, "Failed to create a buffer, hr %#x.\n", hr);
hr = IMFMediaBuffer_QueryInterface(buffer, &IID_IMFGetService, (void **)&unk); check_interface(buffer, &IID_IMFGetService, TRUE);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
IUnknown_Release(unk);
/* Full backing buffer size, with 64 bytes per row alignment. */ /* Full backing buffer size, with 64 bytes per row alignment. */
hr = IMFMediaBuffer_GetMaxLength(buffer, &max_length); hr = IMFMediaBuffer_GetMaxLength(buffer, &max_length);
@ -5450,7 +5436,6 @@ static void test_MFCreateMediaBufferFromMediaType(void)
HRESULT hr; HRESULT hr;
IMFMediaType *media_type; IMFMediaType *media_type;
unsigned int i; unsigned int i;
IUnknown *unk;
if (!pMFCreateMediaBufferFromMediaType) if (!pMFCreateMediaBufferFromMediaType)
{ {
@ -5483,8 +5468,7 @@ static void test_MFCreateMediaBufferFromMediaType(void)
if (FAILED(hr)) if (FAILED(hr))
break; break;
hr = IMFMediaBuffer_QueryInterface(buffer, &IID_IMFGetService, (void **)&unk); check_interface(buffer, &IID_IMFGetService, FALSE);
ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr);
hr = IMFMediaBuffer_GetMaxLength(buffer, &length); hr = IMFMediaBuffer_GetMaxLength(buffer, &length);
ok(hr == S_OK, "Failed to get length, hr %#x.\n", hr); ok(hr == S_OK, "Failed to get length, hr %#x.\n", hr);
@ -5827,7 +5811,6 @@ done:
static void test_MFCreateTrackedSample(void) static void test_MFCreateTrackedSample(void)
{ {
IMFTrackedSample *tracked_sample; IMFTrackedSample *tracked_sample;
IMFDesiredSample *desired_sample;
IMFSample *sample; IMFSample *sample;
IUnknown *unk; IUnknown *unk;
HRESULT hr; HRESULT hr;
@ -5852,8 +5835,7 @@ static void test_MFCreateTrackedSample(void)
IMFSample_Release(sample); IMFSample_Release(sample);
hr = IMFTrackedSample_QueryInterface(tracked_sample, &IID_IMFDesiredSample, (void **)&desired_sample); check_interface(tracked_sample, &IID_IMFDesiredSample, FALSE);
ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr);
IMFTrackedSample_Release(tracked_sample); IMFTrackedSample_Release(tracked_sample);
} }