Commit c99e0fbc authored by Andrew Nguyen's avatar Andrew Nguyen Committed by Alexandre Julliard

dxdiagn: Simplify the root container initialization.

parent 8c331e33
......@@ -756,70 +756,58 @@ out_show_filters:
}
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_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_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};
IDxDiagContainer* pSubCont = NULL;
TRACE("(%p)\n", pRootCont);
hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pSubCont);
if (FAILED(hr)) { return hr; }
hr = DXDiag_InitDXDiagSystemInfoContainer(pSubCont);
hr = IDxDiagContainerImpl_AddChildContainer(pRootCont, DxDiag_SystemInfo, pSubCont);
hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pSubCont);
if (FAILED(hr)) { return hr; }
hr = DXDiag_InitDXDiagSystemDevicesContainer(pSubCont);
hr = IDxDiagContainerImpl_AddChildContainer(pRootCont, DxDiag_SystemDevices, pSubCont);
hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pSubCont);
if (FAILED(hr)) { return hr; }
hr = DXDiag_InitDXDiagLogicalDisksContainer(pSubCont);
hr = IDxDiagContainerImpl_AddChildContainer(pRootCont, DxDiag_LogicalDisks, pSubCont);
hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pSubCont);
if (FAILED(hr)) { return hr; }
hr = DXDiag_InitDXDiagDirectXFilesContainer(pSubCont);
hr = IDxDiagContainerImpl_AddChildContainer(pRootCont, DxDiag_DirectXFiles, pSubCont);
static const WCHAR DxDiag_LogicalDisks[] = {'D','x','D','i','a','g','_','L','o','g','i','c','a','l','D','i','s','k','s',0};
hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pSubCont);
if (FAILED(hr)) { return hr; }
hr = DXDiag_InitDXDiagDisplayContainer(pSubCont);
hr = IDxDiagContainerImpl_AddChildContainer(pRootCont, DxDiag_DisplayDevices, pSubCont);
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;
hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pSubCont);
if (FAILED(hr)) { return hr; }
hr = DXDiag_InitDXDiagDirectSoundContainer(pSubCont);
hr = IDxDiagContainerImpl_AddChildContainer(pRootCont, DxDiag_DirectSound, pSubCont);
TRACE("(%p)\n", pRootCont);
hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pSubCont);
if (FAILED(hr)) { return hr; }
hr = DXDiag_InitDXDiagDirectMusicContainer(pSubCont);
hr = IDxDiagContainerImpl_AddChildContainer(pRootCont, DxDiag_DirectMusic, pSubCont);
for (index = 0; index < sizeof(containers)/sizeof(containers[0]); index++)
{
IDxDiagContainer* pSubCont;
HRESULT hr;
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_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pSubCont);
if (FAILED(hr)) { return hr; }
hr = DXDiag_InitDXDiagDirectPlayContainer(pSubCont);
hr = IDxDiagContainerImpl_AddChildContainer(pRootCont, DxDiag_DirectPlay, pSubCont);
hr = IDxDiagContainerImpl_AddChildContainer(pRootCont, containers[index].name, pSubCont);
if (FAILED(hr))
{
IDxDiagContainer_Release(pSubCont);
return hr;
}
hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pSubCont);
if (FAILED(hr)) { return hr; }
hr = DXDiag_InitDXDiagDirectShowFiltersContainer(pSubCont);
hr = IDxDiagContainerImpl_AddChildContainer(pRootCont, DxDiag_DirectShowFilters, pSubCont);
/* The return value is ignored for now. */
containers[index].initfunc(pSubCont);
}
return hr;
return S_OK;
}
......@@ -656,6 +656,83 @@ cleanup:
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)
{
CoInitialize(NULL);
......@@ -666,5 +743,7 @@ START_TEST(container)
test_dot_parsing();
test_EnumPropNames();
test_GetProp();
test_root_children();
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