Jactry Zeng : mfplat: Implement IMFAttributes::GetCount().
Alexandre Julliard
julliard at winehq.org
Thu Mar 14 18:33:20 CDT 2019
Module: wine
Branch: master
Commit: e8a9cd2e06910eee8af494c746dad6ae47e0c0ee
URL: https://source.winehq.org/git/wine.git/?a=commit;h=e8a9cd2e06910eee8af494c746dad6ae47e0c0ee
Author: Jactry Zeng <jzeng at codeweavers.com>
Date: Thu Mar 14 11:03:12 2019 +0300
mfplat: Implement IMFAttributes::GetCount().
Signed-off-by: Jactry Zeng <jzeng at codeweavers.com>
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/mfplat/main.c | 11 ++++++-----
dlls/mfplat/tests/mfplat.c | 27 +++++++++++++++++----------
2 files changed, 23 insertions(+), 15 deletions(-)
diff --git a/dlls/mfplat/main.c b/dlls/mfplat/main.c
index 4b4f262..7bb09d6 100644
--- a/dlls/mfplat/main.c
+++ b/dlls/mfplat/main.c
@@ -993,14 +993,15 @@ static HRESULT WINAPI mfattributes_UnlockStore(IMFAttributes *iface)
static HRESULT WINAPI mfattributes_GetCount(IMFAttributes *iface, UINT32 *items)
{
- mfattributes *This = impl_from_IMFAttributes(iface);
+ struct attributes *attributes = impl_from_IMFAttributes(iface);
- FIXME("%p, %p\n", This, items);
+ TRACE("%p, %p.\n", iface, items);
- if(items)
- *items = 0;
+ EnterCriticalSection(&attributes->cs);
+ *items = attributes->count;
+ LeaveCriticalSection(&attributes->cs);
- return E_NOTIMPL;
+ 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 b51e5e2..361584f 100644
--- a/dlls/mfplat/tests/mfplat.c
+++ b/dlls/mfplat/tests/mfplat.c
@@ -494,29 +494,31 @@ static void test_MFCreateMediaEvent(void)
IMFMediaEvent_Release(mediaevent);
}
+#define CHECK_ATTR_COUNT(obj, expected) check_attr_count(obj, expected, __LINE__)
+static void check_attr_count(IMFAttributes* obj, UINT32 expected, int line)
+{
+ UINT32 count = expected + 1;
+ HRESULT hr = IMFAttributes_GetCount(obj, &count);
+ ok_(__FILE__, line)(hr == S_OK, "Failed to get attributes count, hr %#x.\n", hr);
+ ok_(__FILE__, line)(count == expected, "Unexpected count %u, expected %u.\n", count, expected);
+}
+
static void test_MFCreateAttributes(void)
{
PROPVARIANT propvar, ret_propvar;
IMFAttributes *attributes;
- UINT32 count, value;
UINT64 value64;
+ UINT32 value;
HRESULT hr;
GUID key;
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_ATTR_COUNT(attributes, 0);
hr = IMFAttributes_SetUINT32(attributes, &MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, 123);
ok(hr == S_OK, "Failed to set UINT32 value, hr %#x.\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_ATTR_COUNT(attributes, 1);
value = 0xdeadbeef;
hr = IMFAttributes_GetUINT32(attributes, &MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, &value);
@@ -530,6 +532,7 @@ static void test_MFCreateAttributes(void)
hr = IMFAttributes_SetUINT64(attributes, &MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, 65536);
ok(hr == S_OK, "Failed to set UINT64 value, hr %#x.\n", hr);
+ CHECK_ATTR_COUNT(attributes, 1);
hr = IMFAttributes_GetUINT64(attributes, &MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, &value64);
ok(hr == S_OK, "Failed to get UINT64 value, hr %#x.\n", hr);
@@ -557,6 +560,7 @@ static void test_MFCreateAttributes(void)
ok(hr == S_OK, "Failed to get item, hr %#x.\n", hr);
ok(!PropVariantCompareEx(&propvar, &ret_propvar, 0, 0), "Unexpected item value.\n");
PropVariantClear(&ret_propvar);
+ CHECK_ATTR_COUNT(attributes, 1);
PropVariantInit(&ret_propvar);
ret_propvar.vt = MF_ATTRIBUTE_STRING;
@@ -581,6 +585,7 @@ static void test_MFCreateAttributes(void)
ok(!PropVariantCompareEx(&propvar, &ret_propvar, 0, 0), "Unexpected item value.\n");
PropVariantClear(&ret_propvar);
PropVariantClear(&propvar);
+ CHECK_ATTR_COUNT(attributes, 1);
PropVariantInit(&propvar);
propvar.vt = VT_I4;
@@ -604,9 +609,11 @@ static void test_MFCreateAttributes(void)
hr = IMFAttributes_DeleteItem(attributes, &DUMMY_GUID2);
ok(hr == S_OK, "Failed to delete item, hr %#x.\n", hr);
+ CHECK_ATTR_COUNT(attributes, 2);
hr = IMFAttributes_DeleteItem(attributes, &DUMMY_GUID2);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+ CHECK_ATTR_COUNT(attributes, 2);
hr = IMFAttributes_GetItem(attributes, &DUMMY_GUID3, &ret_propvar);
ok(hr == S_OK, "Failed to get item, hr %#x.\n", hr);
More information about the wine-cvs
mailing list