dxdiagn: Simplify the root container initialization.

This commit is contained in:
Andrew Nguyen 2011-02-01 04:32:24 -06:00 committed by Alexandre Julliard
parent 8c331e3340
commit c99e0fbc0e
2 changed files with 120 additions and 53 deletions

View File

@ -756,70 +756,58 @@ out_show_filters:
} }
static HRESULT DXDiag_InitRootDXDiagContainer(IDxDiagContainer* pRootCont) { static HRESULT DXDiag_InitRootDXDiagContainer(IDxDiagContainer* pRootCont) {
HRESULT hr = S_OK;
static const WCHAR DxDiag_SystemInfo[] = {'D','x','D','i','a','g','_','S','y','s','t','e','m','I','n','f','o',0}; static const WCHAR DxDiag_SystemInfo[] = {'D','x','D','i','a','g','_','S','y','s','t','e','m','I','n','f','o',0};
static const WCHAR DxDiag_SystemDevices[] = {'D','x','D','i','a','g','_','S','y','s','t','e','m','D','e','v','i','c','e','s',0};
static const WCHAR DxDiag_LogicalDisks[] = {'D','x','D','i','a','g','_','L','o','g','i','c','a','l','D','i','s','k','s',0};
static const WCHAR DxDiag_DirectXFiles[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','X','F','i','l','e','s',0};
static const WCHAR DxDiag_DisplayDevices[] = {'D','x','D','i','a','g','_','D','i','s','p','l','a','y','D','e','v','i','c','e','s',0}; static const WCHAR DxDiag_DisplayDevices[] = {'D','x','D','i','a','g','_','D','i','s','p','l','a','y','D','e','v','i','c','e','s',0};
static const WCHAR DxDiag_DirectSound[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','S','o','u','n','d',0}; static const WCHAR DxDiag_DirectSound[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','S','o','u','n','d',0};
static const WCHAR DxDiag_DirectMusic[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','M','u','s','i','c',0}; static const WCHAR DxDiag_DirectMusic[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','M','u','s','i','c',0};
static const WCHAR DxDiag_DirectInput[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','I','n','p','u','t',0}; static const WCHAR DxDiag_DirectInput[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','I','n','p','u','t',0};
static const WCHAR DxDiag_DirectPlay[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','P','l','a','y',0}; static const WCHAR DxDiag_DirectPlay[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','P','l','a','y',0};
static const WCHAR DxDiag_SystemDevices[] = {'D','x','D','i','a','g','_','S','y','s','t','e','m','D','e','v','i','c','e','s',0};
static const WCHAR DxDiag_DirectXFiles[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','X','F','i','l','e','s',0};
static const WCHAR DxDiag_DirectShowFilters[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','S','h','o','w','F','i','l','t','e','r','s',0}; static const WCHAR DxDiag_DirectShowFilters[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','S','h','o','w','F','i','l','t','e','r','s',0};
IDxDiagContainer* pSubCont = NULL; static const WCHAR DxDiag_LogicalDisks[] = {'D','x','D','i','a','g','_','L','o','g','i','c','a','l','D','i','s','k','s',0};
static const struct
{
const WCHAR *name;
HRESULT (*initfunc)(IDxDiagContainer*);
} containers[] =
{
{DxDiag_SystemInfo, DXDiag_InitDXDiagSystemInfoContainer},
{DxDiag_DisplayDevices, DXDiag_InitDXDiagDisplayContainer},
{DxDiag_DirectSound, DXDiag_InitDXDiagDirectSoundContainer},
{DxDiag_DirectMusic, DXDiag_InitDXDiagDirectMusicContainer},
{DxDiag_DirectInput, DXDiag_InitDXDiagDirectInputContainer},
{DxDiag_DirectPlay, DXDiag_InitDXDiagDirectPlayContainer},
{DxDiag_SystemDevices, DXDiag_InitDXDiagSystemDevicesContainer},
{DxDiag_DirectXFiles, DXDiag_InitDXDiagDirectXFilesContainer},
{DxDiag_DirectShowFilters, DXDiag_InitDXDiagDirectShowFiltersContainer},
{DxDiag_LogicalDisks, DXDiag_InitDXDiagLogicalDisksContainer},
};
size_t index;
TRACE("(%p)\n", pRootCont); TRACE("(%p)\n", pRootCont);
hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pSubCont); for (index = 0; index < sizeof(containers)/sizeof(containers[0]); index++)
if (FAILED(hr)) { return hr; } {
hr = DXDiag_InitDXDiagSystemInfoContainer(pSubCont); IDxDiagContainer* pSubCont;
hr = IDxDiagContainerImpl_AddChildContainer(pRootCont, DxDiag_SystemInfo, pSubCont); HRESULT hr;
hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pSubCont); hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pSubCont);
if (FAILED(hr)) { return hr; } if (FAILED(hr))
hr = DXDiag_InitDXDiagSystemDevicesContainer(pSubCont); return hr;
hr = IDxDiagContainerImpl_AddChildContainer(pRootCont, DxDiag_SystemDevices, pSubCont);
hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pSubCont); hr = IDxDiagContainerImpl_AddChildContainer(pRootCont, containers[index].name, pSubCont);
if (FAILED(hr)) { return hr; } if (FAILED(hr))
hr = DXDiag_InitDXDiagLogicalDisksContainer(pSubCont); {
hr = IDxDiagContainerImpl_AddChildContainer(pRootCont, DxDiag_LogicalDisks, pSubCont); IDxDiagContainer_Release(pSubCont);
return hr;
}
hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pSubCont); /* The return value is ignored for now. */
if (FAILED(hr)) { return hr; } containers[index].initfunc(pSubCont);
hr = DXDiag_InitDXDiagDirectXFilesContainer(pSubCont); }
hr = IDxDiagContainerImpl_AddChildContainer(pRootCont, DxDiag_DirectXFiles, pSubCont);
hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pSubCont); return S_OK;
if (FAILED(hr)) { return hr; }
hr = DXDiag_InitDXDiagDisplayContainer(pSubCont);
hr = IDxDiagContainerImpl_AddChildContainer(pRootCont, DxDiag_DisplayDevices, pSubCont);
hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pSubCont);
if (FAILED(hr)) { return hr; }
hr = DXDiag_InitDXDiagDirectSoundContainer(pSubCont);
hr = IDxDiagContainerImpl_AddChildContainer(pRootCont, DxDiag_DirectSound, pSubCont);
hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pSubCont);
if (FAILED(hr)) { return hr; }
hr = DXDiag_InitDXDiagDirectMusicContainer(pSubCont);
hr = IDxDiagContainerImpl_AddChildContainer(pRootCont, DxDiag_DirectMusic, pSubCont);
hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pSubCont);
if (FAILED(hr)) { return hr; }
hr = DXDiag_InitDXDiagDirectInputContainer(pSubCont);
hr = IDxDiagContainerImpl_AddChildContainer(pRootCont, DxDiag_DirectInput, pSubCont);
hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pSubCont);
if (FAILED(hr)) { return hr; }
hr = DXDiag_InitDXDiagDirectPlayContainer(pSubCont);
hr = IDxDiagContainerImpl_AddChildContainer(pRootCont, DxDiag_DirectPlay, pSubCont);
hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pSubCont);
if (FAILED(hr)) { return hr; }
hr = DXDiag_InitDXDiagDirectShowFiltersContainer(pSubCont);
hr = IDxDiagContainerImpl_AddChildContainer(pRootCont, DxDiag_DirectShowFilters, pSubCont);
return hr;
} }

View File

@ -656,6 +656,83 @@ cleanup:
IDxDiagProvider_Release(pddp); IDxDiagProvider_Release(pddp);
} }
static void test_root_children(void)
{
static const WCHAR DxDiag_SystemInfo[] = {'D','x','D','i','a','g','_','S','y','s','t','e','m','I','n','f','o',0};
static const WCHAR DxDiag_DisplayDevices[] = {'D','x','D','i','a','g','_','D','i','s','p','l','a','y','D','e','v','i','c','e','s',0};
static const WCHAR DxDiag_DirectSound[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','S','o','u','n','d',0};
static const WCHAR DxDiag_DirectMusic[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','M','u','s','i','c',0};
static const WCHAR DxDiag_DirectInput[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','I','n','p','u','t',0};
static const WCHAR DxDiag_DirectPlay[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','P','l','a','y',0};
static const WCHAR DxDiag_SystemDevices[] = {'D','x','D','i','a','g','_','S','y','s','t','e','m','D','e','v','i','c','e','s',0};
static const WCHAR DxDiag_DirectXFiles[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','X','F','i','l','e','s',0};
static const WCHAR DxDiag_DirectShowFilters[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','S','h','o','w','F','i','l','t','e','r','s',0};
static const WCHAR DxDiag_LogicalDisks[] = {'D','x','D','i','a','g','_','L','o','g','i','c','a','l','D','i','s','k','s',0};
HRESULT hr;
DWORD count, index;
static const WCHAR *root_children[] = {
DxDiag_SystemInfo, DxDiag_DisplayDevices, DxDiag_DirectSound,
DxDiag_DirectMusic, DxDiag_DirectInput, DxDiag_DirectPlay,
DxDiag_SystemDevices, DxDiag_DirectXFiles, DxDiag_DirectShowFilters,
DxDiag_LogicalDisks
};
if (!create_root_IDxDiagContainer())
{
skip("Unable to create the root IDxDiagContainer\n");
return;
}
/* Verify the identity and ordering of the root container's children. */
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;
}
ok(count == sizeof(root_children)/sizeof(root_children[0]),
"Got unexpected count %u for the number of child containers\n", count);
if (count != sizeof(root_children)/sizeof(root_children[0]))
{
skip("Received unexpected number of child containers\n");
goto cleanup;
}
for (index = 0; index <= count; index++)
{
WCHAR container[256];
hr = IDxDiagContainer_EnumChildContainerNames(pddc, index, container, sizeof(container)/sizeof(WCHAR));
if (hr == E_INVALIDARG)
{
ok(index == count,
"Expected IDxDiagContainer::EnumChildContainerNames to return "
"E_INVALIDARG on the last index %u\n", count);
break;
}
else if (hr == S_OK)
{
ok(!lstrcmpW(container, root_children[index]),
"Expected container %s for index %u, got %s\n",
wine_dbgstr_w(root_children[index]), index, wine_dbgstr_w(container));
}
else
{
ok(0, "IDxDiagContainer::EnumChildContainerNames unexpectedly returned 0x%08x\n", hr);
break;
}
}
cleanup:
IDxDiagContainer_Release(pddc);
IDxDiagProvider_Release(pddp);
}
START_TEST(container) START_TEST(container)
{ {
CoInitialize(NULL); CoInitialize(NULL);
@ -666,5 +743,7 @@ START_TEST(container)
test_dot_parsing(); test_dot_parsing();
test_EnumPropNames(); test_EnumPropNames();
test_GetProp(); test_GetProp();
test_root_children();
CoUninitialize(); CoUninitialize();
} }