Andrew Nguyen : dxdiagn: Fix return and output behavior of IDxDiagContainer ::EnumPropNames.
Alexandre Julliard
julliard at winehq.org
Mon Mar 15 12:19:40 CDT 2010
Module: wine
Branch: master
Commit: f1e005410f968a1e0b3d97dcf320759b6385fc85
URL: http://source.winehq.org/git/wine.git/?a=commit;h=f1e005410f968a1e0b3d97dcf320759b6385fc85
Author: Andrew Nguyen <arethusa26 at gmail.com>
Date: Sun Mar 14 11:04:20 2010 -0600
dxdiagn: Fix return and output behavior of IDxDiagContainer::EnumPropNames.
---
dlls/dxdiagn/container.c | 13 ++----
dlls/dxdiagn/tests/container.c | 81 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 86 insertions(+), 8 deletions(-)
diff --git a/dlls/dxdiagn/container.c b/dlls/dxdiagn/container.c
index c684e97..3829bb8 100644
--- a/dlls/dxdiagn/container.c
+++ b/dlls/dxdiagn/container.c
@@ -187,16 +187,13 @@ static HRESULT WINAPI IDxDiagContainerImpl_EnumPropNames(PDXDIAGCONTAINER iface,
IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface;
IDxDiagContainerImpl_Property* p = NULL;
DWORD i = 0;
-
- TRACE("(%p, %u, %s, %u)\n", iface, dwIndex, debugstr_w(pwszPropName), cchPropName);
- if (NULL == pwszPropName) {
+ TRACE("(%p, %u, %p, %u)\n", iface, dwIndex, pwszPropName, cchPropName);
+
+ if (NULL == pwszPropName || 0 == cchPropName) {
return E_INVALIDARG;
}
- if (256 > cchPropName) {
- return DXDIAG_E_INSUFFICIENT_BUFFER;
- }
-
+
p = This->properties;
while (NULL != p) {
if (dwIndex == i) {
@@ -208,7 +205,7 @@ static HRESULT WINAPI IDxDiagContainerImpl_EnumPropNames(PDXDIAGCONTAINER iface,
}
p = p->next;
++i;
- }
+ }
return E_INVALIDARG;
}
diff --git a/dlls/dxdiagn/tests/container.c b/dlls/dxdiagn/tests/container.c
index d2ed43f..d1541e3 100644
--- a/dlls/dxdiagn/tests/container.c
+++ b/dlls/dxdiagn/tests/container.c
@@ -387,6 +387,86 @@ cleanup:
IDxDiagProvider_Release(pddp);
}
+static void test_EnumPropNames(void)
+{
+ HRESULT hr;
+ WCHAR container[256], property[256];
+ IDxDiagContainer *child = NULL;
+ DWORD count, index, propcount;
+ static const WCHAR testW[] = {'t','e','s','t',0};
+ static const WCHAR zerotestW[] = {0,'e','s','t',0};
+
+ if (!create_root_IDxDiagContainer())
+ {
+ skip("Unable to create the root IDxDiagContainer\n");
+ return;
+ }
+
+ /* Find a container with a non-zero number of properties. */
+ hr = IDxDiagContainer_GetNumberOfChildContainers(pddc, &count);
+ ok(hr == S_OK, "Expected IDxDiagContainer::GetNumberOfChildContainers to return S_OK, got 0x%08x\n", hr);
+ if (FAILED(hr))
+ {
+ skip("IDxDiagContainer::GetNumberOfChildContainers failed\n");
+ goto cleanup;
+ }
+
+ for (index = 0; index < count; index++)
+ {
+ hr = IDxDiagContainer_EnumChildContainerNames(pddc, index, container, sizeof(container)/sizeof(WCHAR));
+ ok(hr == S_OK, "Expected IDxDiagContainer_EnumChildContainerNames to return S_OK, got 0x%08x\n", hr);
+ if (FAILED(hr))
+ {
+ skip("IDxDiagContainer::EnumChildContainerNames failed\n");
+ goto cleanup;
+ }
+
+ hr = IDxDiagContainer_GetChildContainer(pddc, container, &child);
+ ok(hr == S_OK, "Expected IDxDiagContainer::GetChildContainer to return S_OK, got 0x%08x\n", hr);
+
+ if (SUCCEEDED(hr))
+ {
+ hr = IDxDiagContainer_GetNumberOfProps(child, &propcount);
+ ok(hr == S_OK, "Expected IDxDiagContainer::GetNumberOfProps to return S_OK, got 0x%08x\n", hr);
+
+ if (!propcount)
+ {
+ IDxDiagContainer_Release(child);
+ child = NULL;
+ }
+ else
+ break;
+ }
+ }
+
+ if (!child)
+ {
+ skip("Unable to find a container with non-zero property count\n");
+ goto cleanup;
+ }
+
+ hr = IDxDiagContainer_EnumPropNames(child, ~0, NULL, 0);
+ ok(hr == E_INVALIDARG, "Expected IDxDiagContainer::EnumPropNames to return E_INVALIDARG, got 0x%08x\n", hr);
+
+ memcpy(property, testW, sizeof(testW));
+ hr = IDxDiagContainer_EnumPropNames(child, ~0, property, 0);
+ ok(hr == E_INVALIDARG, "Expected IDxDiagContainer::EnumPropNames to return E_INVALIDARG, got 0x%08x\n", hr);
+ ok(!memcmp(property, testW, sizeof(testW)),
+ "Expected the property buffer to be unchanged, got %s\n", wine_dbgstr_w(property));
+
+ memcpy(property, testW, sizeof(testW));
+ hr = IDxDiagContainer_EnumPropNames(child, ~0, property, sizeof(property)/sizeof(WCHAR));
+ ok(hr == E_INVALIDARG, "Expected IDxDiagContainer::EnumPropNames to return E_INVALIDARG, got 0x%08x\n", hr);
+ ok(!memcmp(property, testW, sizeof(testW)),
+ "Expected the property buffer to be unchanged, got %s\n", wine_dbgstr_w(property));
+
+ IDxDiagContainer_Release(child);
+
+cleanup:
+ IDxDiagContainer_Release(pddc);
+ IDxDiagProvider_Release(pddp);
+}
+
START_TEST(container)
{
CoInitialize(NULL);
@@ -395,5 +475,6 @@ START_TEST(container)
test_EnumChildContainerNames();
test_GetChildContainer();
test_dot_parsing();
+ test_EnumPropNames();
CoUninitialize();
}
More information about the wine-cvs
mailing list