dxdiagn: Fix dot parsing in IDxDiagContainer::GetChildContainer for the case of a lone dot terminator.
This commit is contained in:
parent
c245c6ed09
commit
af1bcf7768
|
@ -151,6 +151,8 @@ static HRESULT WINAPI IDxDiagContainerImpl_GetChildContainer(PDXDIAGCONTAINER if
|
||||||
cur = strchrW(tmp, '.');
|
cur = strchrW(tmp, '.');
|
||||||
while (NULL != cur) {
|
while (NULL != cur) {
|
||||||
*cur = '\0'; /* cut tmp string to '.' */
|
*cur = '\0'; /* cut tmp string to '.' */
|
||||||
|
if (!*(cur + 1)) break; /* Account for a lone terminating period, as in "cont1.cont2.". */
|
||||||
|
TRACE("Trying to get parent container %s\n", debugstr_w(tmp));
|
||||||
hr = IDxDiagContainerImpl_GetChildContainerInternal(pContainer, tmp, &pContainer);
|
hr = IDxDiagContainerImpl_GetChildContainerInternal(pContainer, tmp, &pContainer);
|
||||||
if (FAILED(hr) || NULL == pContainer)
|
if (FAILED(hr) || NULL == pContainer)
|
||||||
goto on_error;
|
goto on_error;
|
||||||
|
@ -159,8 +161,10 @@ static HRESULT WINAPI IDxDiagContainerImpl_GetChildContainer(PDXDIAGCONTAINER if
|
||||||
cur = strchrW(tmp, '.');
|
cur = strchrW(tmp, '.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TRACE("Trying to get container %s\n", debugstr_w(tmp));
|
||||||
hr = IDxDiagContainerImpl_GetChildContainerInternal(pContainer, tmp, ppInstance);
|
hr = IDxDiagContainerImpl_GetChildContainerInternal(pContainer, tmp, ppInstance);
|
||||||
if (SUCCEEDED(hr)) {
|
if (SUCCEEDED(hr)) {
|
||||||
|
TRACE("Succeeded in getting the container instance\n");
|
||||||
IDxDiagContainerImpl_AddRef(*ppInstance);
|
IDxDiagContainerImpl_AddRef(*ppInstance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
#define COBJMACROS
|
#define COBJMACROS
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
#include "dxdiag.h"
|
#include "dxdiag.h"
|
||||||
#include "wine/test.h"
|
#include "wine/test.h"
|
||||||
|
|
||||||
|
@ -289,6 +290,103 @@ cleanup:
|
||||||
IDxDiagProvider_Release(pddp);
|
IDxDiagProvider_Release(pddp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_dot_parsing(void)
|
||||||
|
{
|
||||||
|
HRESULT hr;
|
||||||
|
WCHAR containerbufW[256] = {0}, childbufW[256] = {0};
|
||||||
|
DWORD count, index;
|
||||||
|
size_t i;
|
||||||
|
static const struct
|
||||||
|
{
|
||||||
|
const char *format;
|
||||||
|
const HRESULT expect;
|
||||||
|
} test_strings[] = {
|
||||||
|
{ "%s.%s", S_OK },
|
||||||
|
{ "%s.%s.", S_OK },
|
||||||
|
{ ".%s.%s", E_INVALIDARG },
|
||||||
|
{ "%s.%s..", E_INVALIDARG },
|
||||||
|
{ ".%s.%s.", E_INVALIDARG },
|
||||||
|
{ "..%s.%s", E_INVALIDARG },
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!create_root_IDxDiagContainer())
|
||||||
|
{
|
||||||
|
skip("Unable to create the root IDxDiagContainer\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Find a container with a child container of its own. */
|
||||||
|
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++)
|
||||||
|
{
|
||||||
|
IDxDiagContainer *child;
|
||||||
|
|
||||||
|
hr = IDxDiagContainer_EnumChildContainerNames(pddc, index, containerbufW, sizeof(containerbufW)/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, containerbufW, &child);
|
||||||
|
ok(hr == S_OK, "Expected IDxDiagContainer::GetChildContainer to return S_OK, got 0x%08x\n", hr);
|
||||||
|
|
||||||
|
if (SUCCEEDED(hr))
|
||||||
|
{
|
||||||
|
hr = IDxDiagContainer_EnumChildContainerNames(child, 0, childbufW, sizeof(childbufW)/sizeof(WCHAR));
|
||||||
|
ok(hr == S_OK || hr == E_INVALIDARG,
|
||||||
|
"Expected IDxDiagContainer::EnumChildContainerNames to return S_OK or E_INVALIDARG, got 0x%08x\n", hr);
|
||||||
|
IDxDiagContainer_Release(child);
|
||||||
|
|
||||||
|
if (SUCCEEDED(hr))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!*containerbufW || !*childbufW)
|
||||||
|
{
|
||||||
|
skip("Unable to find a suitable container\n");
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
trace("Testing IDxDiagContainer::GetChildContainer dot parsing with container %s and child container %s.\n",
|
||||||
|
wine_dbgstr_w(containerbufW), wine_dbgstr_w(childbufW));
|
||||||
|
|
||||||
|
for (i = 0; i < sizeof(test_strings)/sizeof(test_strings[0]); i++)
|
||||||
|
{
|
||||||
|
IDxDiagContainer *child;
|
||||||
|
char containerbufA[256];
|
||||||
|
char childbufA[256];
|
||||||
|
char dotbufferA[255 + 255 + 3 + 1];
|
||||||
|
WCHAR dotbufferW[255 + 255 + 3 + 1]; /* containerbuf + childbuf + dots + null terminator */
|
||||||
|
|
||||||
|
WideCharToMultiByte(CP_ACP, 0, containerbufW, -1, containerbufA, sizeof(containerbufA), NULL, NULL);
|
||||||
|
WideCharToMultiByte(CP_ACP, 0, childbufW, -1, childbufA, sizeof(childbufA), NULL, NULL);
|
||||||
|
sprintf(dotbufferA, test_strings[i].format, containerbufA, childbufA);
|
||||||
|
MultiByteToWideChar(CP_ACP, 0, dotbufferA, -1, dotbufferW, sizeof(dotbufferW)/sizeof(WCHAR));
|
||||||
|
|
||||||
|
trace("Trying container name %s\n", wine_dbgstr_w(dotbufferW));
|
||||||
|
hr = IDxDiagContainer_GetChildContainer(pddc, dotbufferW, &child);
|
||||||
|
ok(hr == test_strings[i].expect,
|
||||||
|
"Expected IDxDiagContainer::GetChildContainer to return 0x%08x for %s, got 0x%08x\n",
|
||||||
|
test_strings[i].expect, wine_dbgstr_w(dotbufferW), hr);
|
||||||
|
if (SUCCEEDED(hr))
|
||||||
|
IDxDiagContainer_Release(child);
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
IDxDiagContainer_Release(pddc);
|
||||||
|
IDxDiagProvider_Release(pddp);
|
||||||
|
}
|
||||||
|
|
||||||
START_TEST(container)
|
START_TEST(container)
|
||||||
{
|
{
|
||||||
CoInitialize(NULL);
|
CoInitialize(NULL);
|
||||||
|
@ -296,5 +394,6 @@ START_TEST(container)
|
||||||
test_GetNumberOfProps();
|
test_GetNumberOfProps();
|
||||||
test_EnumChildContainerNames();
|
test_EnumChildContainerNames();
|
||||||
test_GetChildContainer();
|
test_GetChildContainer();
|
||||||
|
test_dot_parsing();
|
||||||
CoUninitialize();
|
CoUninitialize();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue