2 * Unit tests for IDxDiagContainer
4 * Copyright 2010 Andrew Nguyen
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #include "wine/test.h"
28 static IDxDiagProvider *pddp;
29 static IDxDiagContainer *pddc;
31 static const WCHAR DxDiag_SystemInfo[] = {'D','x','D','i','a','g','_','S','y','s','t','e','m','I','n','f','o',0};
33 /* Based on debugstr_variant in dlls/jscript/jsutils.c. */
34 static const char *debugstr_variant(const VARIANT *var)
46 sprintf(buf, "{VT_BSTR: %s}", wine_dbgstr_w(V_BSTR(var)));
49 sprintf(buf, "{VT_BOOL: %x}", V_BOOL(var));
52 sprintf(buf, "{VT_UI4: %u}", V_UI4(var));
55 sprintf(buf, "{vt %d}", V_VT(var));
62 static BOOL create_root_IDxDiagContainer(void)
65 DXDIAG_INIT_PARAMS params;
67 hr = CoCreateInstance(&CLSID_DxDiagProvider, NULL, CLSCTX_INPROC_SERVER,
68 &IID_IDxDiagProvider, (LPVOID*)&pddp);
71 params.dwSize = sizeof(params);
72 params.dwDxDiagHeaderVersion = DXDIAG_DX9_SDK_VERSION;
73 params.bAllowWHQLChecks = FALSE;
74 params.pReserved = NULL;
75 hr = IDxDiagProvider_Initialize(pddp, ¶ms);
78 hr = IDxDiagProvider_GetRootContainer(pddp, &pddc);
82 IDxDiagProvider_Release(pddp);
87 static void test_GetNumberOfChildContainers(void)
92 if (!create_root_IDxDiagContainer())
94 skip("Unable to create the root IDxDiagContainer\n");
98 hr = IDxDiagContainer_GetNumberOfChildContainers(pddc, NULL);
99 ok(hr == E_INVALIDARG,
100 "Expected IDxDiagContainer::GetNumberOfChildContainers to return E_INVALIDARG, got 0x%08x\n", hr);
102 hr = IDxDiagContainer_GetNumberOfChildContainers(pddc, &count);
104 "Expected IDxDiagContainer::GetNumberOfChildContainers to return S_OK, got 0x%08x\n", hr);
106 ok(count != 0, "Expected the number of child containers for the root container to be non-zero\n");
108 IDxDiagContainer_Release(pddc);
109 IDxDiagProvider_Release(pddp);
112 static void test_GetNumberOfProps(void)
117 if (!create_root_IDxDiagContainer())
119 skip("Unable to create the root IDxDiagContainer\n");
123 hr = IDxDiagContainer_GetNumberOfProps(pddc, NULL);
124 ok(hr == E_INVALIDARG, "Expected IDxDiagContainer::GetNumberOfProps to return E_INVALIDARG, got 0x%08x\n", hr);
126 hr = IDxDiagContainer_GetNumberOfProps(pddc, &count);
127 ok(hr == S_OK, "Expected IDxDiagContainer::GetNumberOfProps to return S_OK, got 0x%08x\n", hr);
129 ok(count == 0, "Expected the number of properties for the root container to be zero\n");
131 IDxDiagContainer_Release(pddc);
132 IDxDiagProvider_Release(pddp);
135 static void test_EnumChildContainerNames(void)
138 WCHAR container[256];
139 DWORD maxcount, index;
140 static const WCHAR testW[] = {'t','e','s','t',0};
141 static const WCHAR zerotestW[] = {0,'e','s','t',0};
143 if (!create_root_IDxDiagContainer())
145 skip("Unable to create the root IDxDiagContainer\n");
149 /* Test various combinations of invalid parameters. */
150 hr = IDxDiagContainer_EnumChildContainerNames(pddc, 0, NULL, 0);
151 ok(hr == E_INVALIDARG,
152 "Expected IDxDiagContainer::EnumChildContainerNames to return E_INVALIDARG, got 0x%08x\n", hr);
154 hr = IDxDiagContainer_EnumChildContainerNames(pddc, 0, NULL, sizeof(container)/sizeof(WCHAR));
155 ok(hr == E_INVALIDARG,
156 "Expected IDxDiagContainer::EnumChildContainerNames to return E_INVALIDARG, got 0x%08x\n", hr);
158 /* Test the conditions in which the output buffer can be modified. */
159 memcpy(container, testW, sizeof(testW));
160 hr = IDxDiagContainer_EnumChildContainerNames(pddc, 0, container, 0);
161 ok(hr == E_INVALIDARG,
162 "Expected IDxDiagContainer::EnumChildContainerNames to return E_INVALIDARG, got 0x%08x\n", hr);
163 ok(!memcmp(container, testW, sizeof(testW)),
164 "Expected the container buffer to be untouched, got %s\n", wine_dbgstr_w(container));
166 memcpy(container, testW, sizeof(testW));
167 hr = IDxDiagContainer_EnumChildContainerNames(pddc, ~0, container, 0);
168 ok(hr == E_INVALIDARG,
169 "Expected IDxDiagContainer::EnumChildContainerNames to return E_INVALIDARG, got 0x%08x\n", hr);
170 ok(!memcmp(container, testW, sizeof(testW)),
171 "Expected the container buffer to be untouched, got %s\n", wine_dbgstr_w(container));
173 memcpy(container, testW, sizeof(testW));
174 hr = IDxDiagContainer_EnumChildContainerNames(pddc, ~0, container, sizeof(container)/sizeof(WCHAR));
175 ok(hr == E_INVALIDARG,
176 "Expected IDxDiagContainer::EnumChildContainerNames to return E_INVALIDARG, got 0x%08x\n", hr);
177 ok(!memcmp(container, zerotestW, sizeof(zerotestW)),
178 "Expected the container buffer string to be empty, got %s\n", wine_dbgstr_w(container));
180 hr = IDxDiagContainer_GetNumberOfChildContainers(pddc, &maxcount);
181 ok(hr == S_OK, "Expected IDxDiagContainer::GetNumberOfChildContainers to return S_OK, got 0x%08x\n", hr);
184 skip("IDxDiagContainer::GetNumberOfChildContainers failed\n");
188 trace("Starting child container enumeration of the root container:\n");
190 /* We should be able to enumerate as many child containers as the value
191 * that IDxDiagContainer::GetNumberOfChildContainers returns. */
192 for (index = 0; index <= maxcount; index++)
194 /* A buffer size of 1 is unlikely to be valid, as only a null terminator
195 * could be stored, and it is unlikely that a container name could be empty. */
196 DWORD buffersize = 1;
197 memcpy(container, testW, sizeof(testW));
198 hr = IDxDiagContainer_EnumChildContainerNames(pddc, index, container, buffersize);
199 if (hr == E_INVALIDARG)
201 /* We should get here when index is one more than the maximum index value. */
202 ok(maxcount == index,
203 "Expected IDxDiagContainer::EnumChildContainerNames to return E_INVALIDARG "
204 "on the last index %d, got 0x%08x\n", index, hr);
205 ok(container[0] == '\0',
206 "Expected the container buffer string to be empty, got %s\n", wine_dbgstr_w(container));
209 else if (hr == DXDIAG_E_INSUFFICIENT_BUFFER)
213 ok(container[0] == '\0',
214 "Expected the container buffer string to be empty, got %s\n", wine_dbgstr_w(container));
216 /* Get the container name to compare against. */
217 hr = IDxDiagContainer_EnumChildContainerNames(pddc, index, temp, sizeof(temp)/sizeof(WCHAR));
219 "Expected IDxDiagContainer::EnumChildContainerNames to return S_OK, got 0x%08x\n", hr);
221 /* Show that the DirectX SDK's stipulation that the buffer be at
222 * least 256 characters long is a mere suggestion, and smaller sizes
223 * can be acceptable also. IDxDiagContainer::EnumChildContainerNames
224 * doesn't provide a way of getting the exact size required, so the
225 * buffersize value will be iterated to at most 256 characters. */
226 for (buffersize = 2; buffersize <= 256; buffersize++)
228 memcpy(container, testW, sizeof(testW));
229 hr = IDxDiagContainer_EnumChildContainerNames(pddc, index, container, buffersize);
230 if (hr != DXDIAG_E_INSUFFICIENT_BUFFER)
233 ok(!memcmp(temp, container, sizeof(WCHAR)*(buffersize - 1)),
234 "Expected truncated container name string, got %s\n", wine_dbgstr_w(container));
238 "Expected IDxDiagContainer::EnumChildContainerNames to return S_OK, "
239 "got hr = 0x%08x, buffersize = %d\n", hr, buffersize);
241 trace("pddc[%d] = %s, length = %d\n", index, wine_dbgstr_w(container), buffersize);
245 ok(0, "IDxDiagContainer::EnumChildContainerNames unexpectedly returned 0x%08x\n", hr);
251 IDxDiagContainer_Release(pddc);
252 IDxDiagProvider_Release(pddp);
255 static void test_GetChildContainer(void)
258 WCHAR container[256] = {0};
259 IDxDiagContainer *child;
261 if (!create_root_IDxDiagContainer())
263 skip("Unable to create the root IDxDiagContainer\n");
267 /* Test various combinations of invalid parameters. */
268 hr = IDxDiagContainer_GetChildContainer(pddc, NULL, NULL);
269 ok(hr == E_INVALIDARG,
270 "Expected IDxDiagContainer::GetChildContainer to return E_INVALIDARG, got 0x%08x\n", hr);
272 child = (void*)0xdeadbeef;
273 hr = IDxDiagContainer_GetChildContainer(pddc, NULL, &child);
274 ok(hr == E_INVALIDARG,
275 "Expected IDxDiagContainer::GetChildContainer to return E_INVALIDARG, got 0x%08x\n", hr);
276 ok(child == (void*)0xdeadbeef, "Expected output pointer to be unchanged, got %p\n", child);
278 hr = IDxDiagContainer_GetChildContainer(pddc, container, NULL);
279 ok(hr == E_INVALIDARG,
280 "Expected IDxDiagContainer::GetChildContainer to return E_INVALIDARG, got 0x%08x\n", hr);
282 child = (void*)0xdeadbeef;
283 hr = IDxDiagContainer_GetChildContainer(pddc, container, &child);
284 ok(hr == E_INVALIDARG,
285 "Expected IDxDiagContainer::GetChildContainer to return E_INVALIDARG, got 0x%08x\n", hr);
286 ok(child == NULL, "Expected output pointer to be NULL, got %p\n", child);
288 /* Get the name of a suitable child container. */
289 hr = IDxDiagContainer_EnumChildContainerNames(pddc, 0, container, sizeof(container)/sizeof(WCHAR));
291 "Expected IDxDiagContainer::EnumChildContainerNames to return S_OK, got 0x%08x\n", hr);
294 skip("IDxDiagContainer::EnumChildContainerNames failed\n");
298 child = (void*)0xdeadbeef;
299 hr = IDxDiagContainer_GetChildContainer(pddc, container, &child);
301 "Expected IDxDiagContainer::GetChildContainer to return S_OK, got 0x%08x\n", hr);
302 ok(child != NULL && child != (void*)0xdeadbeef, "Expected a valid output pointer, got %p\n", child);
306 IDxDiagContainer *ptr;
308 /* Show that IDxDiagContainer::GetChildContainer returns a different pointer
309 * for multiple calls for the same container name. */
310 hr = IDxDiagContainer_GetChildContainer(pddc, container, &ptr);
312 "Expected IDxDiagContainer::GetChildContainer to return S_OK, got 0x%08x\n", hr);
314 ok(ptr != child, "Expected the two pointers (%p vs. %p) to be unequal\n", child, ptr);
316 IDxDiagContainer_Release(ptr);
317 IDxDiagContainer_Release(child);
321 IDxDiagContainer_Release(pddc);
322 IDxDiagProvider_Release(pddp);
325 static void test_dot_parsing(void)
328 WCHAR containerbufW[256] = {0}, childbufW[256] = {0};
334 const HRESULT expect;
338 { ".%s.%s", E_INVALIDARG },
339 { "%s.%s..", E_INVALIDARG },
340 { ".%s.%s.", E_INVALIDARG },
341 { "..%s.%s", E_INVALIDARG },
344 if (!create_root_IDxDiagContainer())
346 skip("Unable to create the root IDxDiagContainer\n");
350 /* Find a container with a child container of its own. */
351 hr = IDxDiagContainer_GetNumberOfChildContainers(pddc, &count);
352 ok(hr == S_OK, "Expected IDxDiagContainer::GetNumberOfChildContainers to return S_OK, got 0x%08x\n", hr);
355 skip("IDxDiagContainer::GetNumberOfChildContainers failed\n");
359 for (index = 0; index < count; index++)
361 IDxDiagContainer *child;
363 hr = IDxDiagContainer_EnumChildContainerNames(pddc, index, containerbufW, sizeof(containerbufW)/sizeof(WCHAR));
364 ok(hr == S_OK, "Expected IDxDiagContainer_EnumChildContainerNames to return S_OK, got 0x%08x\n", hr);
367 skip("IDxDiagContainer::EnumChildContainerNames failed\n");
371 hr = IDxDiagContainer_GetChildContainer(pddc, containerbufW, &child);
372 ok(hr == S_OK, "Expected IDxDiagContainer::GetChildContainer to return S_OK, got 0x%08x\n", hr);
376 hr = IDxDiagContainer_EnumChildContainerNames(child, 0, childbufW, sizeof(childbufW)/sizeof(WCHAR));
377 ok(hr == S_OK || hr == E_INVALIDARG,
378 "Expected IDxDiagContainer::EnumChildContainerNames to return S_OK or E_INVALIDARG, got 0x%08x\n", hr);
379 IDxDiagContainer_Release(child);
386 if (!*containerbufW || !*childbufW)
388 skip("Unable to find a suitable container\n");
392 trace("Testing IDxDiagContainer::GetChildContainer dot parsing with container %s and child container %s.\n",
393 wine_dbgstr_w(containerbufW), wine_dbgstr_w(childbufW));
395 for (i = 0; i < sizeof(test_strings)/sizeof(test_strings[0]); i++)
397 IDxDiagContainer *child;
398 char containerbufA[256];
400 char dotbufferA[255 + 255 + 3 + 1];
401 WCHAR dotbufferW[255 + 255 + 3 + 1]; /* containerbuf + childbuf + dots + null terminator */
403 WideCharToMultiByte(CP_ACP, 0, containerbufW, -1, containerbufA, sizeof(containerbufA), NULL, NULL);
404 WideCharToMultiByte(CP_ACP, 0, childbufW, -1, childbufA, sizeof(childbufA), NULL, NULL);
405 sprintf(dotbufferA, test_strings[i].format, containerbufA, childbufA);
406 MultiByteToWideChar(CP_ACP, 0, dotbufferA, -1, dotbufferW, sizeof(dotbufferW)/sizeof(WCHAR));
408 trace("Trying container name %s\n", wine_dbgstr_w(dotbufferW));
409 hr = IDxDiagContainer_GetChildContainer(pddc, dotbufferW, &child);
410 ok(hr == test_strings[i].expect,
411 "Expected IDxDiagContainer::GetChildContainer to return 0x%08x for %s, got 0x%08x\n",
412 test_strings[i].expect, wine_dbgstr_w(dotbufferW), hr);
414 IDxDiagContainer_Release(child);
418 IDxDiagContainer_Release(pddc);
419 IDxDiagProvider_Release(pddp);
422 static void test_EnumPropNames(void)
425 WCHAR container[256], property[256];
426 IDxDiagContainer *child = NULL;
427 DWORD count, index, propcount;
428 static const WCHAR testW[] = {'t','e','s','t',0};
430 if (!create_root_IDxDiagContainer())
432 skip("Unable to create the root IDxDiagContainer\n");
436 /* Find a container with a non-zero number of properties. */
437 hr = IDxDiagContainer_GetNumberOfChildContainers(pddc, &count);
438 ok(hr == S_OK, "Expected IDxDiagContainer::GetNumberOfChildContainers to return S_OK, got 0x%08x\n", hr);
441 skip("IDxDiagContainer::GetNumberOfChildContainers failed\n");
445 for (index = 0; index < count; index++)
447 hr = IDxDiagContainer_EnumChildContainerNames(pddc, index, container, sizeof(container)/sizeof(WCHAR));
448 ok(hr == S_OK, "Expected IDxDiagContainer_EnumChildContainerNames to return S_OK, got 0x%08x\n", hr);
451 skip("IDxDiagContainer::EnumChildContainerNames failed\n");
455 hr = IDxDiagContainer_GetChildContainer(pddc, container, &child);
456 ok(hr == S_OK, "Expected IDxDiagContainer::GetChildContainer to return S_OK, got 0x%08x\n", hr);
460 hr = IDxDiagContainer_GetNumberOfProps(child, &propcount);
461 ok(hr == S_OK, "Expected IDxDiagContainer::GetNumberOfProps to return S_OK, got 0x%08x\n", hr);
465 IDxDiagContainer_Release(child);
475 skip("Unable to find a container with non-zero property count\n");
479 hr = IDxDiagContainer_EnumPropNames(child, ~0, NULL, 0);
480 ok(hr == E_INVALIDARG, "Expected IDxDiagContainer::EnumPropNames to return E_INVALIDARG, got 0x%08x\n", hr);
482 memcpy(property, testW, sizeof(testW));
483 hr = IDxDiagContainer_EnumPropNames(child, ~0, property, 0);
484 ok(hr == E_INVALIDARG, "Expected IDxDiagContainer::EnumPropNames to return E_INVALIDARG, got 0x%08x\n", hr);
485 ok(!memcmp(property, testW, sizeof(testW)),
486 "Expected the property buffer to be unchanged, got %s\n", wine_dbgstr_w(property));
488 memcpy(property, testW, sizeof(testW));
489 hr = IDxDiagContainer_EnumPropNames(child, ~0, property, sizeof(property)/sizeof(WCHAR));
490 ok(hr == E_INVALIDARG, "Expected IDxDiagContainer::EnumPropNames to return E_INVALIDARG, got 0x%08x\n", hr);
491 ok(!memcmp(property, testW, sizeof(testW)),
492 "Expected the property buffer to be unchanged, got %s\n", wine_dbgstr_w(property));
494 trace("Starting property enumeration of the %s container:\n", wine_dbgstr_w(container));
496 /* We should be able to enumerate as many properties as the value that
497 * IDxDiagContainer::GetNumberOfProps returns. */
498 for (index = 0; index <= propcount; index++)
500 /* A buffer size of 1 is unlikely to be valid, as only a null terminator
501 * could be stored, and it is unlikely that a property name could be empty. */
502 DWORD buffersize = 1;
504 memcpy(property, testW, sizeof(testW));
505 hr = IDxDiagContainer_EnumPropNames(child, index, property, buffersize);
506 if (hr == E_INVALIDARG)
508 /* We should get here when index is one more than the maximum index value. */
509 ok(propcount == index,
510 "Expected IDxDiagContainer::EnumPropNames to return E_INVALIDARG "
511 "on the last index %d, got 0x%08x\n", index, hr);
512 ok(!memcmp(property, testW, sizeof(testW)),
513 "Expected the property buffer to be unchanged, got %s\n", wine_dbgstr_w(property));
516 else if (hr == DXDIAG_E_INSUFFICIENT_BUFFER)
520 ok(property[0] == '\0',
521 "Expected the property buffer string to be empty, got %s\n", wine_dbgstr_w(property));
522 hr = IDxDiagContainer_EnumPropNames(child, index, temp, sizeof(temp)/sizeof(WCHAR));
524 "Expected IDxDiagContainer::EnumPropNames to return S_OK, got 0x%08x\n", hr);
526 /* Show that the DirectX SDK's stipulation that the buffer be at
527 * least 256 characters long is a mere suggestion, and smaller sizes
528 * can be acceptable also. IDxDiagContainer::EnumPropNames doesn't
529 * provide a way of getting the exact size required, so the buffersize
530 * value will be iterated to at most 256 characters. */
531 for (buffersize = 2; buffersize <= 256; buffersize++)
533 memcpy(property, testW, sizeof(testW));
534 hr = IDxDiagContainer_EnumPropNames(child, index, property, buffersize);
535 if (hr != DXDIAG_E_INSUFFICIENT_BUFFER)
538 ok(!memcmp(temp, property, sizeof(WCHAR)*(buffersize - 1)),
539 "Expected truncated property name string, got %s\n", wine_dbgstr_w(property));
543 "Expected IDxDiagContainer::EnumPropNames to return S_OK, "
544 "got hr = 0x%08x, buffersize = %d\n", hr, buffersize);
546 trace("child[%d] = %s, length = %d\n", index, wine_dbgstr_w(property), buffersize);
550 ok(0, "IDxDiagContainer::EnumPropNames unexpectedly returned 0x%08x\n", hr);
555 IDxDiagContainer_Release(child);
558 IDxDiagContainer_Release(pddc);
559 IDxDiagProvider_Release(pddp);
562 static void test_GetProp(void)
565 WCHAR container[256], property[256];
566 IDxDiagContainer *child = NULL;
570 SAFEARRAYBOUND bound;
571 static const WCHAR emptyW[] = {0};
572 static const WCHAR testW[] = {'t','e','s','t',0};
574 if (!create_root_IDxDiagContainer())
576 skip("Unable to create the root IDxDiagContainer\n");
580 /* Find a container with a property. */
581 hr = IDxDiagContainer_GetNumberOfChildContainers(pddc, &count);
582 ok(hr == S_OK, "Expected IDxDiagContainer::GetNumberOfChildContainers to return S_OK, got 0x%08x\n", hr);
585 skip("IDxDiagContainer::GetNumberOfChildContainers failed\n");
589 for (index = 0; index < count; index++)
591 hr = IDxDiagContainer_EnumChildContainerNames(pddc, index, container, sizeof(container)/sizeof(WCHAR));
592 ok(hr == S_OK, "Expected IDxDiagContainer_EnumChildContainerNames to return S_OK, got 0x%08x\n", hr);
595 skip("IDxDiagContainer::EnumChildContainerNames failed\n");
599 hr = IDxDiagContainer_GetChildContainer(pddc, container, &child);
600 ok(hr == S_OK, "Expected IDxDiagContainer::GetChildContainer to return S_OK, got 0x%08x\n", hr);
604 hr = IDxDiagContainer_EnumPropNames(child, 0, property, sizeof(property)/sizeof(WCHAR));
605 ok(hr == S_OK || hr == E_INVALIDARG,
606 "Expected IDxDiagContainer::EnumPropNames to return S_OK or E_INVALIDARG, got 0x%08x\n", hr);
612 IDxDiagContainer_Release(child);
620 skip("Unable to find a suitable container\n");
624 hr = IDxDiagContainer_GetProp(child, NULL, NULL);
625 ok(hr == E_INVALIDARG, "Expected IDxDiagContainer::GetProp to return E_INVALIDARG, got 0x%08x\n", hr);
628 hr = IDxDiagContainer_GetProp(child, NULL, &var);
629 ok(hr == E_INVALIDARG, "Expected IDxDiagContainer::GetProp to return E_INVALIDARG, got 0x%08x\n", hr);
630 ok(V_VT(&var) == 0xdead, "Expected the variant to be untouched, got %u\n", V_VT(&var));
632 hr = IDxDiagContainer_GetProp(child, emptyW, NULL);
633 ok(hr == E_INVALIDARG, "Expected IDxDiagContainer::GetProp to return E_INVALIDARG, got 0x%08x\n", hr);
636 hr = IDxDiagContainer_GetProp(child, emptyW, &var);
637 ok(hr == E_INVALIDARG, "Expected IDxDiagContainer::GetProp to return E_INVALIDARG, got 0x%08x\n", hr);
638 ok(V_VT(&var) == 0xdead, "Expected the variant to be untouched, got %u\n", V_VT(&var));
640 hr = IDxDiagContainer_GetProp(child, testW, NULL);
641 ok(hr == E_INVALIDARG, "Expected IDxDiagContainer::GetProp to return E_INVALIDARG, got 0x%08x\n", hr);
644 hr = IDxDiagContainer_GetProp(child, testW, &var);
645 ok(hr == E_INVALIDARG, "Expected IDxDiagContainer::GetProp to return E_INVALIDARG, got 0x%08x\n", hr);
646 ok(V_VT(&var) == 0xdead, "Expected the variant to be untouched, got %u\n", V_VT(&var));
649 hr = IDxDiagContainer_GetProp(child, property, &var);
650 ok(hr == S_OK, "Expected IDxDiagContainer::GetProp to return S_OK, got 0x%08x\n", hr);
651 ok(V_VT(&var) != VT_EMPTY, "Expected the variant to be modified, got %d\n", V_VT(&var));
653 /* Since the documentation for IDxDiagContainer::GetProp claims that the
654 * function reports return values from VariantCopy, try to exercise failure
655 * paths in handling the destination variant. */
657 /* Try an invalid variant type. */
659 hr = IDxDiagContainer_GetProp(child, property, &var);
660 ok(hr == S_OK, "Expected IDxDiagContainer::GetProp to return S_OK, got 0x%08x\n", hr);
661 ok(V_VT(&var) != 0xdead, "Expected the variant to be modified, got %d\n", V_VT(&var));
663 /* Try passing a variant with a locked SAFEARRAY. */
666 sa = SafeArrayCreate(VT_UI1, 1, &bound);
667 ok(sa != NULL, "Expected SafeArrayCreate to return a valid pointer\n");
669 V_VT(&var) = (VT_ARRAY | VT_UI1);
672 hr = SafeArrayLock(sa);
673 ok(hr == S_OK, "Expected SafeArrayLock to return S_OK, got 0x%08x\n", hr);
675 hr = IDxDiagContainer_GetProp(child, property, &var);
676 ok(hr == S_OK, "Expected IDxDiagContainer::GetProp to return S_OK, got 0x%08x\n", hr);
677 ok(V_VT(&var) != (VT_ARRAY | VT_UI1), "Expected the variant to be modified\n");
679 hr = SafeArrayUnlock(sa);
680 ok(hr == S_OK, "Expected SafeArrayUnlock to return S_OK, got 0x%08x\n", hr);
681 hr = SafeArrayDestroy(sa);
682 ok(hr == S_OK, "Expected SafeArrayDestroy to return S_OK, got 0x%08x\n", hr);
683 IDxDiagContainer_Release(child);
686 IDxDiagContainer_Release(pddc);
687 IDxDiagProvider_Release(pddp);
690 static void test_root_children(void)
692 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};
693 static const WCHAR DxDiag_DirectSound[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','S','o','u','n','d',0};
694 static const WCHAR DxDiag_DirectMusic[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','M','u','s','i','c',0};
695 static const WCHAR DxDiag_DirectInput[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','I','n','p','u','t',0};
696 static const WCHAR DxDiag_DirectPlay[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','P','l','a','y',0};
697 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};
698 static const WCHAR DxDiag_DirectXFiles[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','X','F','i','l','e','s',0};
699 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};
700 static const WCHAR DxDiag_LogicalDisks[] = {'D','x','D','i','a','g','_','L','o','g','i','c','a','l','D','i','s','k','s',0};
705 static const WCHAR *root_children[] = {
706 DxDiag_SystemInfo, DxDiag_DisplayDevices, DxDiag_DirectSound,
707 DxDiag_DirectMusic, DxDiag_DirectInput, DxDiag_DirectPlay,
708 DxDiag_SystemDevices, DxDiag_DirectXFiles, DxDiag_DirectShowFilters,
712 if (!create_root_IDxDiagContainer())
714 skip("Unable to create the root IDxDiagContainer\n");
718 /* Verify the identity and ordering of the root container's children. */
719 hr = IDxDiagContainer_GetNumberOfChildContainers(pddc, &count);
720 ok(hr == S_OK, "Expected IDxDiagContainer::GetNumberOfChildContainers to return S_OK, got 0x%08x\n", hr);
723 skip("IDxDiagContainer::GetNumberOfChildContainers failed\n");
727 ok(count == sizeof(root_children)/sizeof(root_children[0]),
728 "Got unexpected count %u for the number of child containers\n", count);
730 if (count != sizeof(root_children)/sizeof(root_children[0]))
732 skip("Received unexpected number of child containers\n");
736 for (index = 0; index <= count; index++)
738 WCHAR container[256];
740 hr = IDxDiagContainer_EnumChildContainerNames(pddc, index, container, sizeof(container)/sizeof(WCHAR));
741 if (hr == E_INVALIDARG)
744 "Expected IDxDiagContainer::EnumChildContainerNames to return "
745 "E_INVALIDARG on the last index %u\n", count);
750 ok(!lstrcmpW(container, root_children[index]),
751 "Expected container %s for index %u, got %s\n",
752 wine_dbgstr_w(root_children[index]), index, wine_dbgstr_w(container));
756 ok(0, "IDxDiagContainer::EnumChildContainerNames unexpectedly returned 0x%08x\n", hr);
762 IDxDiagContainer_Release(pddc);
763 IDxDiagProvider_Release(pddp);
766 static void test_DxDiag_SystemInfo(void)
768 static const WCHAR dwOSMajorVersion[] = {'d','w','O','S','M','a','j','o','r','V','e','r','s','i','o','n',0};
769 static const WCHAR dwOSMinorVersion[] = {'d','w','O','S','M','i','n','o','r','V','e','r','s','i','o','n',0};
770 static const WCHAR dwOSBuildNumber[] = {'d','w','O','S','B','u','i','l','d','N','u','m','b','e','r',0};
771 static const WCHAR dwOSPlatformID[] = {'d','w','O','S','P','l','a','t','f','o','r','m','I','D',0};
772 static const WCHAR dwDirectXVersionMajor[] = {'d','w','D','i','r','e','c','t','X','V','e','r','s','i','o','n','M','a','j','o','r',0};
773 static const WCHAR dwDirectXVersionMinor[] = {'d','w','D','i','r','e','c','t','X','V','e','r','s','i','o','n','M','i','n','o','r',0};
774 static const WCHAR szDirectXVersionLetter[] = {'s','z','D','i','r','e','c','t','X','V','e','r','s','i','o','n','L','e','t','t','e','r',0};
775 static const WCHAR bDebug[] = {'b','D','e','b','u','g',0};
776 static const WCHAR bNECPC98[] = {'b','N','E','C','P','C','9','8',0};
777 static const WCHAR ullPhysicalMemory[] = {'u','l','l','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
778 static const WCHAR ullUsedPageFile[] = {'u','l','l','U','s','e','d','P','a','g','e','F','i','l','e',0};
779 static const WCHAR ullAvailPageFile[] = {'u','l','l','A','v','a','i','l','P','a','g','e','F','i','l','e',0};
780 static const WCHAR szWindowsDir[] = {'s','z','W','i','n','d','o','w','s','D','i','r',0};
781 static const WCHAR szCSDVersion[] = {'s','z','C','S','D','V','e','r','s','i','o','n',0};
782 static const WCHAR szDirectXVersionEnglish[] = {'s','z','D','i','r','e','c','t','X','V','e','r','s','i','o','n','E','n','g','l','i','s','h',0};
783 static const WCHAR szDirectXVersionLongEnglish[] = {'s','z','D','i','r','e','c','t','X','V','e','r','s','i','o','n','L','o','n','g','E','n','g','l','i','s','h',0};
784 static const WCHAR bNetMeetingRunning[] = {'b','N','e','t','M','e','e','t','i','n','g','R','u','n','n','i','n','g',0};
785 static const WCHAR szMachineNameLocalized[] = {'s','z','M','a','c','h','i','n','e','N','a','m','e','L','o','c','a','l','i','z','e','d',0};
786 static const WCHAR szMachineNameEnglish[] = {'s','z','M','a','c','h','i','n','e','N','a','m','e','E','n','g','l','i','s','h',0};
787 static const WCHAR szLanguagesLocalized[] = {'s','z','L','a','n','g','u','a','g','e','s','L','o','c','a','l','i','z','e','d',0};
788 static const WCHAR szLanguagesEnglish[] = {'s','z','L','a','n','g','u','a','g','e','s','E','n','g','l','i','s','h',0};
789 static const WCHAR szTimeLocalized[] = {'s','z','T','i','m','e','L','o','c','a','l','i','z','e','d',0};
790 static const WCHAR szTimeEnglish[] = {'s','z','T','i','m','e','E','n','g','l','i','s','h',0};
791 static const WCHAR szPhysicalMemoryEnglish[] = {'s','z','P','h','y','s','i','c','a','l','M','e','m','o','r','y','E','n','g','l','i','s','h',0};
792 static const WCHAR szPageFileLocalized[] = {'s','z','P','a','g','e','F','i','l','e','L','o','c','a','l','i','z','e','d',0};
793 static const WCHAR szPageFileEnglish[] = {'s','z','P','a','g','e','F','i','l','e','E','n','g','l','i','s','h',0};
794 static const WCHAR szOSLocalized[] = {'s','z','O','S','L','o','c','a','l','i','z','e','d',0};
795 static const WCHAR szOSExLocalized[] = {'s','z','O','S','E','x','L','o','c','a','l','i','z','e','d',0};
796 static const WCHAR szOSExLongLocalized[] = {'s','z','O','S','E','x','L','o','n','g','L','o','c','a','l','i','z','e','d',0};
797 static const WCHAR szOSEnglish[] = {'s','z','O','S','E','n','g','l','i','s','h',0};
798 static const WCHAR szOSExEnglish[] = {'s','z','O','S','E','x','E','n','g','l','i','s','h',0};
799 static const WCHAR szOSExLongEnglish[] = {'s','z','O','S','E','x','L','o','n','g','E','n','g','l','i','s','h',0};
807 {dwOSMajorVersion, VT_UI4},
808 {dwOSMinorVersion, VT_UI4},
809 {dwOSBuildNumber, VT_UI4},
810 {dwOSPlatformID, VT_UI4},
811 {dwDirectXVersionMajor, VT_UI4},
812 {dwDirectXVersionMinor, VT_UI4},
813 {szDirectXVersionLetter, VT_BSTR},
816 {ullPhysicalMemory, VT_BSTR},
817 {ullUsedPageFile, VT_BSTR},
818 {ullAvailPageFile, VT_BSTR},
819 {szWindowsDir, VT_BSTR},
820 {szCSDVersion, VT_BSTR},
821 {szDirectXVersionEnglish, VT_BSTR},
822 {szDirectXVersionLongEnglish, VT_BSTR},
823 {bNetMeetingRunning, VT_BOOL},
824 {szMachineNameLocalized, VT_BSTR},
825 {szMachineNameEnglish, VT_BSTR},
826 {szLanguagesLocalized, VT_BSTR},
827 {szLanguagesEnglish, VT_BSTR},
828 {szTimeLocalized, VT_BSTR},
829 {szTimeEnglish, VT_BSTR},
830 {szPhysicalMemoryEnglish, VT_BSTR},
831 {szPageFileLocalized, VT_BSTR},
832 {szPageFileEnglish, VT_BSTR},
833 {szOSLocalized, VT_BSTR},
834 {szOSExLocalized, VT_BSTR},
835 {szOSExLongLocalized, VT_BSTR},
836 {szOSEnglish, VT_BSTR},
837 {szOSExEnglish, VT_BSTR},
838 {szOSExLongEnglish, VT_BSTR},
842 IDxDiagContainer *child = NULL;
845 if (!create_root_IDxDiagContainer())
847 skip("Unable to create the root IDxDiagContainer\n");
851 hr = IDxDiagContainer_GetChildContainer(pddc, DxDiag_SystemInfo, &child);
852 ok(hr == S_OK, "Expected IDxDiagContainer::GetChildContainer to return S_OK, got 0x%08x\n", hr);
858 /* Examine the variant types of obtained property values. */
859 for (i = 0; i < sizeof(property_tests)/sizeof(property_tests[0]); i++)
861 hr = IDxDiagContainer_GetProp(child, property_tests[i].prop, &var);
862 ok(hr == S_OK, "[%d] Expected IDxDiagContainer::GetProp to return S_OK, got 0x%08x\n", i, hr);
866 ok(V_VT(&var) == property_tests[i].vt,
867 "[%d] Expected variant type %d, got %d\n", i, property_tests[i].vt, V_VT(&var));
868 trace("%s = %s\n", wine_dbgstr_w(property_tests[i].prop), debugstr_variant(&var));
874 IDxDiagContainer_Release(child);
875 IDxDiagContainer_Release(pddc);
876 IDxDiagProvider_Release(pddp);
879 START_TEST(container)
882 test_GetNumberOfChildContainers();
883 test_GetNumberOfProps();
884 test_EnumChildContainerNames();
885 test_GetChildContainer();
887 test_EnumPropNames();
890 test_root_children();
891 test_DxDiag_SystemInfo();