Signed-off-by: Jactry Zeng jzeng@codeweavers.com --- dlls/mfplat/main.c | 10 +++++++--- dlls/mfplat/tests/mfplat.c | 27 +++++++++++++++++---------- 2 files changed, 24 insertions(+), 13 deletions(-)
diff --git a/dlls/mfplat/main.c b/dlls/mfplat/main.c index 1749bd6929..3918d25f83 100644 --- a/dlls/mfplat/main.c +++ b/dlls/mfplat/main.c @@ -981,12 +981,16 @@ static HRESULT WINAPI mfattributes_GetCount(IMFAttributes *iface, UINT32 *items) { mfattributes *This = impl_from_IMFAttributes(iface);
- FIXME("%p, %p\n", This, items); + TRACE("(%p, %p)\n", This, items); + + EnterCriticalSection(&This->lock);
if(items) - *items = 0; + *items = This->count;
- return E_NOTIMPL; + LeaveCriticalSection(&This->lock); + + return S_OK; }
static HRESULT WINAPI mfattributes_GetItemByIndex(IMFAttributes *iface, UINT32 index, GUID *key, PROPVARIANT *value) diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index 55c9f516c3..732e098a3a 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -416,11 +416,20 @@ static void test_MFCreateMediaEvent(void) IMFMediaEvent_Release(mediaevent); }
+#define CHECK_COUNT(obj,expected) _check_count(obj, expected, __LINE__) +static void _check_count(IMFAttributes* obj, ULONG expected, int line) +{ + UINT32 count = 9999; + HRESULT hr; + hr = IMFAttributes_GetCount(obj, &count); + ok_(__FILE__,line)(hr == S_OK, "IMFAttributes_GetCount failed: 0x%08x.\n", hr); + ok_(__FILE__,line)(count == expected, "got %d, expected %d.\n", count, expected); +} + static void test_MFCreateAttributes(void) { IMFAttributes *attributes; HRESULT hr; - UINT32 count; PROPVARIANT propvar, ret_propvar; GUID key; UINT32 uint32_value; @@ -428,18 +437,11 @@ static void test_MFCreateAttributes(void)
hr = MFCreateAttributes( &attributes, 3 ); ok(hr == S_OK, "got 0x%08x\n", hr); - - count = 88; - hr = IMFAttributes_GetCount(attributes, &count); - todo_wine ok(hr == S_OK, "got 0x%08x\n", hr); - ok(count == 0, "got %d\n", count); + CHECK_COUNT(attributes, 0);
hr = IMFAttributes_SetUINT32(attributes, &MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, 123); ok(hr == S_OK, "got 0x%08x\n", hr); - - hr = IMFAttributes_GetCount(attributes, &count); - todo_wine ok(hr == S_OK, "got 0x%08x\n", hr); - todo_wine ok(count == 1, "got %d\n", count); + CHECK_COUNT(attributes, 1);
uint32_value = 0xdeadbeef; hr = IMFAttributes_GetUINT32(attributes, &MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, &uint32_value); @@ -453,6 +455,7 @@ static void test_MFCreateAttributes(void)
hr = IMFAttributes_SetUINT64(attributes, &MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, 65536); ok(hr == S_OK, "IMFAttributes_SetUINT64 failed: 0x%08x.\n", hr); + CHECK_COUNT(attributes, 1);
hr = IMFAttributes_GetUINT64(attributes, &MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, &uint64_value); ok(hr == S_OK, "IMFAttributes_GetUINT64 failed: 0x%08x.\n", hr); @@ -525,9 +528,11 @@ static void test_MFCreateAttributes(void) hr = IMFAttributes_SetItem(attributes, &DUMMY_GUID3, &propvar); ok(hr == S_OK, "IMFAttributes_SetItem failed: 0x%08x.\n", hr);
+ CHECK_COUNT(attributes, 3); hr = IMFAttributes_DeleteItem(attributes, &DUMMY_GUID2); ok(hr == S_OK, "IMFAttributes_DeleteItem failed: 0x%08x.\n", hr); key = GUID_NULL; + CHECK_COUNT(attributes, 2); if (is_win8_plus) hr = IMFAttributes_GetItemByIndex(attributes, 0, &key, &ret_propvar); else @@ -551,8 +556,10 @@ static void test_MFCreateAttributes(void) hr = IMFAttributes_GetItemByIndex(attributes, 999, &key, &ret_propvar); ok(hr == E_INVALIDARG, "IMFAttributes_GetItemByIndex returned: 0x%08x.\n", hr);
+ CHECK_COUNT(attributes, 2); hr = IMFAttributes_DeleteItem(attributes, &DUMMY_GUID2); ok(hr == S_OK, "IMFAttributes_DeleteItem failed: 0x%08x.\n", hr); + CHECK_COUNT(attributes, 2);
IMFAttributes_Release(attributes); }