Commit 2c9a5900 authored by Andrew Nguyen's avatar Andrew Nguyen Committed by Alexandre Julliard

dxdiagn: Fix return and output behavior of IDxDiagContainer::EnumChildContainerNames.

parent 5801d60a
......@@ -88,16 +88,13 @@ static HRESULT WINAPI IDxDiagContainerImpl_EnumChildContainerNames(PDXDIAGCONTAI
IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface;
IDxDiagContainerImpl_SubContainer* p = NULL;
DWORD i = 0;
TRACE("(%p, %u, %s, %u)\n", iface, dwIndex, debugstr_w(pwszContainer), cchContainer);
if (NULL == pwszContainer) {
TRACE("(%p, %u, %p, %u)\n", iface, dwIndex, pwszContainer, cchContainer);
if (NULL == pwszContainer || 0 == cchContainer) {
return E_INVALIDARG;
}
if (256 > cchContainer) {
return DXDIAG_E_INSUFFICIENT_BUFFER;
}
p = This->subContainers;
while (NULL != p) {
if (dwIndex == i) {
......@@ -109,7 +106,9 @@ static HRESULT WINAPI IDxDiagContainerImpl_EnumChildContainerNames(PDXDIAGCONTAI
}
p = p->next;
++i;
}
}
*pwszContainer = '\0';
return E_INVALIDARG;
}
......
......@@ -99,10 +99,59 @@ static void test_GetNumberOfProps(void)
IDxDiagProvider_Release(pddp);
}
static void test_EnumChildContainerNames(void)
{
HRESULT hr;
WCHAR container[256];
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;
}
/* Test various combinations of invalid parameters. */
hr = IDxDiagContainer_EnumChildContainerNames(pddc, 0, NULL, 0);
ok(hr == E_INVALIDARG,
"Expected IDxDiagContainer::EnumChildContainerNames to return E_INVALIDARG, got 0x%08x\n", hr);
hr = IDxDiagContainer_EnumChildContainerNames(pddc, 0, NULL, sizeof(container)/sizeof(WCHAR));
ok(hr == E_INVALIDARG,
"Expected IDxDiagContainer::EnumChildContainerNames to return E_INVALIDARG, got 0x%08x\n", hr);
/* Test the conditions in which the output buffer can be modified. */
memcpy(container, testW, sizeof(testW));
hr = IDxDiagContainer_EnumChildContainerNames(pddc, 0, container, 0);
ok(hr == E_INVALIDARG,
"Expected IDxDiagContainer::EnumChildContainerNames to return E_INVALIDARG, got 0x%08x\n", hr);
ok(!memcmp(container, testW, sizeof(testW)),
"Expected the container buffer to be untouched, got %s\n", wine_dbgstr_w(container));
memcpy(container, testW, sizeof(testW));
hr = IDxDiagContainer_EnumChildContainerNames(pddc, ~0, container, 0);
ok(hr == E_INVALIDARG,
"Expected IDxDiagContainer::EnumChildContainerNames to return E_INVALIDARG, got 0x%08x\n", hr);
ok(!memcmp(container, testW, sizeof(testW)),
"Expected the container buffer to be untouched, got %s\n", wine_dbgstr_w(container));
memcpy(container, testW, sizeof(testW));
hr = IDxDiagContainer_EnumChildContainerNames(pddc, ~0, container, sizeof(container)/sizeof(WCHAR));
ok(hr == E_INVALIDARG,
"Expected IDxDiagContainer::EnumChildContainerNames to return E_INVALIDARG, got 0x%08x\n", hr);
ok(!memcmp(container, zerotestW, sizeof(zerotestW)),
"Expected the container buffer string to be empty, got %s\n", wine_dbgstr_w(container));
IDxDiagContainer_Release(pddc);
IDxDiagProvider_Release(pddp);
}
START_TEST(container)
{
CoInitialize(NULL);
test_GetNumberOfChildContainers();
test_GetNumberOfProps();
test_EnumChildContainerNames();
CoUninitialize();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment