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"
34 static IDxDiagProvider
*pddp
;
35 static IDxDiagContainer
*pddc
;
37 static const WCHAR DxDiag_SystemInfo
[] = {'D','x','D','i','a','g','_','S','y','s','t','e','m','I','n','f','o',0};
38 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};
40 /* Based on debugstr_variant in dlls/jscript/jsutils.c. */
41 static const char *debugstr_variant(const VARIANT
*var
)
53 sprintf(buf
, "{VT_BSTR: %s}", wine_dbgstr_w(V_BSTR(var
)));
56 sprintf(buf
, "{VT_BOOL: %x}", V_BOOL(var
));
59 sprintf(buf
, "{VT_UI4: %u}", V_UI4(var
));
62 sprintf(buf
, "{vt %d}", V_VT(var
));
69 static BOOL
create_root_IDxDiagContainer(void)
72 DXDIAG_INIT_PARAMS params
;
74 hr
= CoCreateInstance(&CLSID_DxDiagProvider
, NULL
, CLSCTX_INPROC_SERVER
,
75 &IID_IDxDiagProvider
, (LPVOID
*)&pddp
);
78 params
.dwSize
= sizeof(params
);
79 params
.dwDxDiagHeaderVersion
= DXDIAG_DX9_SDK_VERSION
;
80 params
.bAllowWHQLChecks
= FALSE
;
81 params
.pReserved
= NULL
;
82 hr
= IDxDiagProvider_Initialize(pddp
, ¶ms
);
85 hr
= IDxDiagProvider_GetRootContainer(pddp
, &pddc
);
89 IDxDiagProvider_Release(pddp
);
94 static void test_GetNumberOfChildContainers(void)
99 if (!create_root_IDxDiagContainer())
101 skip("Unable to create the root IDxDiagContainer\n");
105 hr
= IDxDiagContainer_GetNumberOfChildContainers(pddc
, NULL
);
106 ok(hr
== E_INVALIDARG
,
107 "Expected IDxDiagContainer::GetNumberOfChildContainers to return E_INVALIDARG, got 0x%08x\n", hr
);
109 hr
= IDxDiagContainer_GetNumberOfChildContainers(pddc
, &count
);
111 "Expected IDxDiagContainer::GetNumberOfChildContainers to return S_OK, got 0x%08x\n", hr
);
113 ok(count
!= 0, "Expected the number of child containers for the root container to be non-zero\n");
115 IDxDiagContainer_Release(pddc
);
116 IDxDiagProvider_Release(pddp
);
119 static void test_GetNumberOfProps(void)
124 if (!create_root_IDxDiagContainer())
126 skip("Unable to create the root IDxDiagContainer\n");
130 hr
= IDxDiagContainer_GetNumberOfProps(pddc
, NULL
);
131 ok(hr
== E_INVALIDARG
, "Expected IDxDiagContainer::GetNumberOfProps to return E_INVALIDARG, got 0x%08x\n", hr
);
133 hr
= IDxDiagContainer_GetNumberOfProps(pddc
, &count
);
134 ok(hr
== S_OK
, "Expected IDxDiagContainer::GetNumberOfProps to return S_OK, got 0x%08x\n", hr
);
136 ok(count
== 0, "Expected the number of properties for the root container to be zero\n");
138 IDxDiagContainer_Release(pddc
);
139 IDxDiagProvider_Release(pddp
);
142 static void test_EnumChildContainerNames(void)
145 WCHAR container
[256];
146 DWORD maxcount
, index
;
147 static const WCHAR testW
[] = {'t','e','s','t',0};
148 static const WCHAR zerotestW
[] = {0,'e','s','t',0};
150 if (!create_root_IDxDiagContainer())
152 skip("Unable to create the root IDxDiagContainer\n");
156 /* Test various combinations of invalid parameters. */
157 hr
= IDxDiagContainer_EnumChildContainerNames(pddc
, 0, NULL
, 0);
158 ok(hr
== E_INVALIDARG
,
159 "Expected IDxDiagContainer::EnumChildContainerNames to return E_INVALIDARG, got 0x%08x\n", hr
);
161 hr
= IDxDiagContainer_EnumChildContainerNames(pddc
, 0, NULL
, sizeof(container
)/sizeof(WCHAR
));
162 ok(hr
== E_INVALIDARG
,
163 "Expected IDxDiagContainer::EnumChildContainerNames to return E_INVALIDARG, got 0x%08x\n", hr
);
165 /* Test the conditions in which the output buffer can be modified. */
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
, 0);
175 ok(hr
== E_INVALIDARG
,
176 "Expected IDxDiagContainer::EnumChildContainerNames to return E_INVALIDARG, got 0x%08x\n", hr
);
177 ok(!memcmp(container
, testW
, sizeof(testW
)),
178 "Expected the container buffer to be untouched, got %s\n", wine_dbgstr_w(container
));
180 memcpy(container
, testW
, sizeof(testW
));
181 hr
= IDxDiagContainer_EnumChildContainerNames(pddc
, ~0, container
, sizeof(container
)/sizeof(WCHAR
));
182 ok(hr
== E_INVALIDARG
,
183 "Expected IDxDiagContainer::EnumChildContainerNames to return E_INVALIDARG, got 0x%08x\n", hr
);
184 ok(!memcmp(container
, zerotestW
, sizeof(zerotestW
)),
185 "Expected the container buffer string to be empty, got %s\n", wine_dbgstr_w(container
));
187 hr
= IDxDiagContainer_GetNumberOfChildContainers(pddc
, &maxcount
);
188 ok(hr
== S_OK
, "Expected IDxDiagContainer::GetNumberOfChildContainers to return S_OK, got 0x%08x\n", hr
);
191 skip("IDxDiagContainer::GetNumberOfChildContainers failed\n");
195 trace("Starting child container enumeration of the root container:\n");
197 /* We should be able to enumerate as many child containers as the value
198 * that IDxDiagContainer::GetNumberOfChildContainers returns. */
199 for (index
= 0; index
<= maxcount
; index
++)
201 /* A buffer size of 1 is unlikely to be valid, as only a null terminator
202 * could be stored, and it is unlikely that a container name could be empty. */
203 DWORD buffersize
= 1;
204 memcpy(container
, testW
, sizeof(testW
));
205 hr
= IDxDiagContainer_EnumChildContainerNames(pddc
, index
, container
, buffersize
);
206 if (hr
== E_INVALIDARG
)
208 /* We should get here when index is one more than the maximum index value. */
209 ok(maxcount
== index
,
210 "Expected IDxDiagContainer::EnumChildContainerNames to return E_INVALIDARG "
211 "on the last index %d, got 0x%08x\n", index
, hr
);
212 ok(container
[0] == '\0',
213 "Expected the container buffer string to be empty, got %s\n", wine_dbgstr_w(container
));
216 else if (hr
== DXDIAG_E_INSUFFICIENT_BUFFER
)
220 ok(container
[0] == '\0',
221 "Expected the container buffer string to be empty, got %s\n", wine_dbgstr_w(container
));
223 /* Get the container name to compare against. */
224 hr
= IDxDiagContainer_EnumChildContainerNames(pddc
, index
, temp
, sizeof(temp
)/sizeof(WCHAR
));
226 "Expected IDxDiagContainer::EnumChildContainerNames to return S_OK, got 0x%08x\n", hr
);
228 /* Show that the DirectX SDK's stipulation that the buffer be at
229 * least 256 characters long is a mere suggestion, and smaller sizes
230 * can be acceptable also. IDxDiagContainer::EnumChildContainerNames
231 * doesn't provide a way of getting the exact size required, so the
232 * buffersize value will be iterated to at most 256 characters. */
233 for (buffersize
= 2; buffersize
<= 256; buffersize
++)
235 memcpy(container
, testW
, sizeof(testW
));
236 hr
= IDxDiagContainer_EnumChildContainerNames(pddc
, index
, container
, buffersize
);
237 if (hr
!= DXDIAG_E_INSUFFICIENT_BUFFER
)
240 ok(!memcmp(temp
, container
, sizeof(WCHAR
)*(buffersize
- 1)),
241 "Expected truncated container name string, got %s\n", wine_dbgstr_w(container
));
245 "Expected IDxDiagContainer::EnumChildContainerNames to return S_OK, "
246 "got hr = 0x%08x, buffersize = %d\n", hr
, buffersize
);
248 trace("pddc[%d] = %s, length = %d\n", index
, wine_dbgstr_w(container
), buffersize
);
252 ok(0, "IDxDiagContainer::EnumChildContainerNames unexpectedly returned 0x%08x\n", hr
);
258 IDxDiagContainer_Release(pddc
);
259 IDxDiagProvider_Release(pddp
);
262 static void test_GetChildContainer(void)
265 WCHAR container
[256] = {0};
266 IDxDiagContainer
*child
;
268 if (!create_root_IDxDiagContainer())
270 skip("Unable to create the root IDxDiagContainer\n");
274 /* Test various combinations of invalid parameters. */
275 hr
= IDxDiagContainer_GetChildContainer(pddc
, NULL
, NULL
);
276 ok(hr
== E_INVALIDARG
,
277 "Expected IDxDiagContainer::GetChildContainer to return E_INVALIDARG, got 0x%08x\n", hr
);
279 child
= (void*)0xdeadbeef;
280 hr
= IDxDiagContainer_GetChildContainer(pddc
, NULL
, &child
);
281 ok(hr
== E_INVALIDARG
,
282 "Expected IDxDiagContainer::GetChildContainer to return E_INVALIDARG, got 0x%08x\n", hr
);
283 ok(child
== (void*)0xdeadbeef, "Expected output pointer to be unchanged, got %p\n", child
);
285 hr
= IDxDiagContainer_GetChildContainer(pddc
, container
, NULL
);
286 ok(hr
== E_INVALIDARG
,
287 "Expected IDxDiagContainer::GetChildContainer to return E_INVALIDARG, got 0x%08x\n", hr
);
289 child
= (void*)0xdeadbeef;
290 hr
= IDxDiagContainer_GetChildContainer(pddc
, container
, &child
);
291 ok(hr
== E_INVALIDARG
,
292 "Expected IDxDiagContainer::GetChildContainer to return E_INVALIDARG, got 0x%08x\n", hr
);
293 ok(child
== NULL
, "Expected output pointer to be NULL, got %p\n", child
);
295 /* Get the name of a suitable child container. */
296 hr
= IDxDiagContainer_EnumChildContainerNames(pddc
, 0, container
, sizeof(container
)/sizeof(WCHAR
));
298 "Expected IDxDiagContainer::EnumChildContainerNames to return S_OK, got 0x%08x\n", hr
);
301 skip("IDxDiagContainer::EnumChildContainerNames failed\n");
305 child
= (void*)0xdeadbeef;
306 hr
= IDxDiagContainer_GetChildContainer(pddc
, container
, &child
);
308 "Expected IDxDiagContainer::GetChildContainer to return S_OK, got 0x%08x\n", hr
);
309 ok(child
!= NULL
&& child
!= (void*)0xdeadbeef, "Expected a valid output pointer, got %p\n", child
);
313 IDxDiagContainer
*ptr
;
315 /* Show that IDxDiagContainer::GetChildContainer returns a different pointer
316 * for multiple calls for the same container name. */
317 hr
= IDxDiagContainer_GetChildContainer(pddc
, container
, &ptr
);
319 "Expected IDxDiagContainer::GetChildContainer to return S_OK, got 0x%08x\n", hr
);
321 ok(ptr
!= child
, "Expected the two pointers (%p vs. %p) to be unequal\n", child
, ptr
);
323 IDxDiagContainer_Release(ptr
);
324 IDxDiagContainer_Release(child
);
328 IDxDiagContainer_Release(pddc
);
329 IDxDiagProvider_Release(pddp
);
332 static void test_dot_parsing(void)
335 WCHAR containerbufW
[256] = {0}, childbufW
[256] = {0};
341 const HRESULT expect
;
345 { ".%s.%s", E_INVALIDARG
},
346 { "%s.%s..", E_INVALIDARG
},
347 { ".%s.%s.", E_INVALIDARG
},
348 { "..%s.%s", E_INVALIDARG
},
351 if (!create_root_IDxDiagContainer())
353 skip("Unable to create the root IDxDiagContainer\n");
357 /* Find a container with a child container of its own. */
358 hr
= IDxDiagContainer_GetNumberOfChildContainers(pddc
, &count
);
359 ok(hr
== S_OK
, "Expected IDxDiagContainer::GetNumberOfChildContainers to return S_OK, got 0x%08x\n", hr
);
362 skip("IDxDiagContainer::GetNumberOfChildContainers failed\n");
366 for (index
= 0; index
< count
; index
++)
368 IDxDiagContainer
*child
;
370 hr
= IDxDiagContainer_EnumChildContainerNames(pddc
, index
, containerbufW
, sizeof(containerbufW
)/sizeof(WCHAR
));
371 ok(hr
== S_OK
, "Expected IDxDiagContainer_EnumChildContainerNames to return S_OK, got 0x%08x\n", hr
);
374 skip("IDxDiagContainer::EnumChildContainerNames failed\n");
378 hr
= IDxDiagContainer_GetChildContainer(pddc
, containerbufW
, &child
);
379 ok(hr
== S_OK
, "Expected IDxDiagContainer::GetChildContainer to return S_OK, got 0x%08x\n", hr
);
383 hr
= IDxDiagContainer_EnumChildContainerNames(child
, 0, childbufW
, sizeof(childbufW
)/sizeof(WCHAR
));
384 ok(hr
== S_OK
|| hr
== E_INVALIDARG
,
385 "Expected IDxDiagContainer::EnumChildContainerNames to return S_OK or E_INVALIDARG, got 0x%08x\n", hr
);
386 IDxDiagContainer_Release(child
);
393 if (!*containerbufW
|| !*childbufW
)
395 skip("Unable to find a suitable container\n");
399 trace("Testing IDxDiagContainer::GetChildContainer dot parsing with container %s and child container %s.\n",
400 wine_dbgstr_w(containerbufW
), wine_dbgstr_w(childbufW
));
402 for (i
= 0; i
< sizeof(test_strings
)/sizeof(test_strings
[0]); i
++)
404 IDxDiagContainer
*child
;
405 char containerbufA
[256];
407 char dotbufferA
[255 + 255 + 3 + 1];
408 WCHAR dotbufferW
[255 + 255 + 3 + 1]; /* containerbuf + childbuf + dots + null terminator */
410 WideCharToMultiByte(CP_ACP
, 0, containerbufW
, -1, containerbufA
, sizeof(containerbufA
), NULL
, NULL
);
411 WideCharToMultiByte(CP_ACP
, 0, childbufW
, -1, childbufA
, sizeof(childbufA
), NULL
, NULL
);
412 sprintf(dotbufferA
, test_strings
[i
].format
, containerbufA
, childbufA
);
413 MultiByteToWideChar(CP_ACP
, 0, dotbufferA
, -1, dotbufferW
, sizeof(dotbufferW
)/sizeof(WCHAR
));
415 trace("Trying container name %s\n", wine_dbgstr_w(dotbufferW
));
416 hr
= IDxDiagContainer_GetChildContainer(pddc
, dotbufferW
, &child
);
417 ok(hr
== test_strings
[i
].expect
,
418 "Expected IDxDiagContainer::GetChildContainer to return 0x%08x for %s, got 0x%08x\n",
419 test_strings
[i
].expect
, wine_dbgstr_w(dotbufferW
), hr
);
421 IDxDiagContainer_Release(child
);
425 IDxDiagContainer_Release(pddc
);
426 IDxDiagProvider_Release(pddp
);
429 static void test_EnumPropNames(void)
432 WCHAR container
[256], property
[256];
433 IDxDiagContainer
*child
= NULL
;
434 DWORD count
, index
, propcount
;
435 static const WCHAR testW
[] = {'t','e','s','t',0};
437 if (!create_root_IDxDiagContainer())
439 skip("Unable to create the root IDxDiagContainer\n");
443 /* Find a container with a non-zero number of properties. */
444 hr
= IDxDiagContainer_GetNumberOfChildContainers(pddc
, &count
);
445 ok(hr
== S_OK
, "Expected IDxDiagContainer::GetNumberOfChildContainers to return S_OK, got 0x%08x\n", hr
);
448 skip("IDxDiagContainer::GetNumberOfChildContainers failed\n");
452 for (index
= 0; index
< count
; index
++)
454 hr
= IDxDiagContainer_EnumChildContainerNames(pddc
, index
, container
, sizeof(container
)/sizeof(WCHAR
));
455 ok(hr
== S_OK
, "Expected IDxDiagContainer_EnumChildContainerNames to return S_OK, got 0x%08x\n", hr
);
458 skip("IDxDiagContainer::EnumChildContainerNames failed\n");
462 hr
= IDxDiagContainer_GetChildContainer(pddc
, container
, &child
);
463 ok(hr
== S_OK
, "Expected IDxDiagContainer::GetChildContainer to return S_OK, got 0x%08x\n", hr
);
467 hr
= IDxDiagContainer_GetNumberOfProps(child
, &propcount
);
468 ok(hr
== S_OK
, "Expected IDxDiagContainer::GetNumberOfProps to return S_OK, got 0x%08x\n", hr
);
472 IDxDiagContainer_Release(child
);
482 skip("Unable to find a container with non-zero property count\n");
486 hr
= IDxDiagContainer_EnumPropNames(child
, ~0, NULL
, 0);
487 ok(hr
== E_INVALIDARG
, "Expected IDxDiagContainer::EnumPropNames to return E_INVALIDARG, got 0x%08x\n", hr
);
489 memcpy(property
, testW
, sizeof(testW
));
490 hr
= IDxDiagContainer_EnumPropNames(child
, ~0, property
, 0);
491 ok(hr
== E_INVALIDARG
, "Expected IDxDiagContainer::EnumPropNames to return E_INVALIDARG, got 0x%08x\n", hr
);
492 ok(!memcmp(property
, testW
, sizeof(testW
)),
493 "Expected the property buffer to be unchanged, got %s\n", wine_dbgstr_w(property
));
495 memcpy(property
, testW
, sizeof(testW
));
496 hr
= IDxDiagContainer_EnumPropNames(child
, ~0, property
, sizeof(property
)/sizeof(WCHAR
));
497 ok(hr
== E_INVALIDARG
, "Expected IDxDiagContainer::EnumPropNames to return E_INVALIDARG, got 0x%08x\n", hr
);
498 ok(!memcmp(property
, testW
, sizeof(testW
)),
499 "Expected the property buffer to be unchanged, got %s\n", wine_dbgstr_w(property
));
501 trace("Starting property enumeration of the %s container:\n", wine_dbgstr_w(container
));
503 /* We should be able to enumerate as many properties as the value that
504 * IDxDiagContainer::GetNumberOfProps returns. */
505 for (index
= 0; index
<= propcount
; index
++)
507 /* A buffer size of 1 is unlikely to be valid, as only a null terminator
508 * could be stored, and it is unlikely that a property name could be empty. */
509 DWORD buffersize
= 1;
511 memcpy(property
, testW
, sizeof(testW
));
512 hr
= IDxDiagContainer_EnumPropNames(child
, index
, property
, buffersize
);
513 if (hr
== E_INVALIDARG
)
515 /* We should get here when index is one more than the maximum index value. */
516 ok(propcount
== index
,
517 "Expected IDxDiagContainer::EnumPropNames to return E_INVALIDARG "
518 "on the last index %d, got 0x%08x\n", index
, hr
);
519 ok(!memcmp(property
, testW
, sizeof(testW
)),
520 "Expected the property buffer to be unchanged, got %s\n", wine_dbgstr_w(property
));
523 else if (hr
== DXDIAG_E_INSUFFICIENT_BUFFER
)
527 ok(property
[0] == '\0',
528 "Expected the property buffer string to be empty, got %s\n", wine_dbgstr_w(property
));
529 hr
= IDxDiagContainer_EnumPropNames(child
, index
, temp
, sizeof(temp
)/sizeof(WCHAR
));
531 "Expected IDxDiagContainer::EnumPropNames to return S_OK, got 0x%08x\n", hr
);
533 /* Show that the DirectX SDK's stipulation that the buffer be at
534 * least 256 characters long is a mere suggestion, and smaller sizes
535 * can be acceptable also. IDxDiagContainer::EnumPropNames doesn't
536 * provide a way of getting the exact size required, so the buffersize
537 * value will be iterated to at most 256 characters. */
538 for (buffersize
= 2; buffersize
<= 256; buffersize
++)
540 memcpy(property
, testW
, sizeof(testW
));
541 hr
= IDxDiagContainer_EnumPropNames(child
, index
, property
, buffersize
);
542 if (hr
!= DXDIAG_E_INSUFFICIENT_BUFFER
)
545 ok(!memcmp(temp
, property
, sizeof(WCHAR
)*(buffersize
- 1)),
546 "Expected truncated property name string, got %s\n", wine_dbgstr_w(property
));
550 "Expected IDxDiagContainer::EnumPropNames to return S_OK, "
551 "got hr = 0x%08x, buffersize = %d\n", hr
, buffersize
);
553 trace("child[%d] = %s, length = %d\n", index
, wine_dbgstr_w(property
), buffersize
);
557 ok(0, "IDxDiagContainer::EnumPropNames unexpectedly returned 0x%08x\n", hr
);
562 IDxDiagContainer_Release(child
);
565 IDxDiagContainer_Release(pddc
);
566 IDxDiagProvider_Release(pddp
);
569 static void test_GetProp(void)
572 WCHAR container
[256], property
[256];
573 IDxDiagContainer
*child
= NULL
;
577 SAFEARRAYBOUND bound
;
579 static const WCHAR emptyW
[] = {0};
580 static const WCHAR testW
[] = {'t','e','s','t',0};
582 if (!create_root_IDxDiagContainer())
584 skip("Unable to create the root IDxDiagContainer\n");
588 /* Find a container with a property. */
589 hr
= IDxDiagContainer_GetNumberOfChildContainers(pddc
, &count
);
590 ok(hr
== S_OK
, "Expected IDxDiagContainer::GetNumberOfChildContainers to return S_OK, got 0x%08x\n", hr
);
593 skip("IDxDiagContainer::GetNumberOfChildContainers failed\n");
597 for (index
= 0; index
< count
; index
++)
599 hr
= IDxDiagContainer_EnumChildContainerNames(pddc
, index
, container
, sizeof(container
)/sizeof(WCHAR
));
600 ok(hr
== S_OK
, "Expected IDxDiagContainer_EnumChildContainerNames to return S_OK, got 0x%08x\n", hr
);
603 skip("IDxDiagContainer::EnumChildContainerNames failed\n");
607 hr
= IDxDiagContainer_GetChildContainer(pddc
, container
, &child
);
608 ok(hr
== S_OK
, "Expected IDxDiagContainer::GetChildContainer to return S_OK, got 0x%08x\n", hr
);
612 hr
= IDxDiagContainer_EnumPropNames(child
, 0, property
, sizeof(property
)/sizeof(WCHAR
));
613 ok(hr
== S_OK
|| hr
== E_INVALIDARG
,
614 "Expected IDxDiagContainer::EnumPropNames to return S_OK or E_INVALIDARG, got 0x%08x\n", hr
);
620 IDxDiagContainer_Release(child
);
628 skip("Unable to find a suitable container\n");
632 hr
= IDxDiagContainer_GetProp(child
, NULL
, NULL
);
633 ok(hr
== E_INVALIDARG
, "Expected IDxDiagContainer::GetProp to return E_INVALIDARG, got 0x%08x\n", hr
);
636 hr
= IDxDiagContainer_GetProp(child
, NULL
, &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
, emptyW
, NULL
);
641 ok(hr
== E_INVALIDARG
, "Expected IDxDiagContainer::GetProp to return E_INVALIDARG, got 0x%08x\n", hr
);
644 hr
= IDxDiagContainer_GetProp(child
, emptyW
, &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
));
648 hr
= IDxDiagContainer_GetProp(child
, testW
, NULL
);
649 ok(hr
== E_INVALIDARG
, "Expected IDxDiagContainer::GetProp to return E_INVALIDARG, got 0x%08x\n", hr
);
652 hr
= IDxDiagContainer_GetProp(child
, testW
, &var
);
653 ok(hr
== E_INVALIDARG
, "Expected IDxDiagContainer::GetProp to return E_INVALIDARG, got 0x%08x\n", hr
);
654 ok(V_VT(&var
) == 0xdead, "Expected the variant to be untouched, got %u\n", V_VT(&var
));
657 hr
= IDxDiagContainer_GetProp(child
, property
, &var
);
658 ok(hr
== S_OK
, "Expected IDxDiagContainer::GetProp to return S_OK, got 0x%08x\n", hr
);
659 ok(V_VT(&var
) != VT_EMPTY
, "Expected the variant to be modified, got %d\n", V_VT(&var
));
661 /* Since the documentation for IDxDiagContainer::GetProp claims that the
662 * function reports return values from VariantCopy, try to exercise failure
663 * paths in handling the destination variant. */
665 /* Try an invalid variant type. */
667 hr
= IDxDiagContainer_GetProp(child
, property
, &var
);
668 ok(hr
== S_OK
, "Expected IDxDiagContainer::GetProp to return S_OK, got 0x%08x\n", hr
);
669 ok(V_VT(&var
) != 0xdead, "Expected the variant to be modified, got %d\n", V_VT(&var
));
671 /* Try passing a variant with a locked SAFEARRAY. */
674 sa
= SafeArrayCreate(VT_UI1
, 1, &bound
);
675 ok(sa
!= NULL
, "Expected SafeArrayCreate to return a valid pointer\n");
677 V_VT(&var
) = (VT_ARRAY
| VT_UI1
);
680 hr
= SafeArrayLock(sa
);
681 ok(hr
== S_OK
, "Expected SafeArrayLock to return S_OK, got 0x%08x\n", hr
);
683 hr
= IDxDiagContainer_GetProp(child
, property
, &var
);
684 ok(hr
== S_OK
, "Expected IDxDiagContainer::GetProp to return S_OK, got 0x%08x\n", hr
);
685 ok(V_VT(&var
) != (VT_ARRAY
| VT_UI1
), "Expected the variant to be modified\n");
687 hr
= SafeArrayUnlock(sa
);
688 ok(hr
== S_OK
, "Expected SafeArrayUnlock to return S_OK, got 0x%08x\n", hr
);
689 hr
= SafeArrayDestroy(sa
);
690 ok(hr
== S_OK
, "Expected SafeArrayDestroy to return S_OK, got 0x%08x\n", hr
);
692 /* Determine whether GetProp calls VariantClear on the passed variant. */
693 V_VT(&var
) = VT_UNKNOWN
;
694 V_UNKNOWN(&var
) = (IUnknown
*)child
;
695 IDxDiagContainer_AddRef(child
);
697 hr
= IDxDiagContainer_GetProp(child
, property
, &var
);
698 ok(hr
== S_OK
, "Expected IDxDiagContainer::GetProp to return S_OK, got 0x%08x\n", hr
);
699 ok(V_VT(&var
) != VT_UNKNOWN
, "Expected the variant to be modified\n");
701 IDxDiagContainer_AddRef(child
);
702 ref
= IDxDiagContainer_Release(child
);
703 ok(ref
== 2, "Expected reference count to be 2, got %u\n", ref
);
705 IDxDiagContainer_Release(child
);
707 IDxDiagContainer_Release(pddc
);
708 IDxDiagProvider_Release(pddp
);
711 static void test_root_children(void)
713 static const WCHAR DxDiag_DirectSound
[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','S','o','u','n','d',0};
714 static const WCHAR DxDiag_DirectMusic
[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','M','u','s','i','c',0};
715 static const WCHAR DxDiag_DirectInput
[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','I','n','p','u','t',0};
716 static const WCHAR DxDiag_DirectPlay
[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','P','l','a','y',0};
717 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};
718 static const WCHAR DxDiag_DirectXFiles
[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','X','F','i','l','e','s',0};
719 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};
720 static const WCHAR DxDiag_LogicalDisks
[] = {'D','x','D','i','a','g','_','L','o','g','i','c','a','l','D','i','s','k','s',0};
725 static const WCHAR
*root_children
[] = {
726 DxDiag_SystemInfo
, DxDiag_DisplayDevices
, DxDiag_DirectSound
,
727 DxDiag_DirectMusic
, DxDiag_DirectInput
, DxDiag_DirectPlay
,
728 DxDiag_SystemDevices
, DxDiag_DirectXFiles
, DxDiag_DirectShowFilters
,
732 if (!create_root_IDxDiagContainer())
734 skip("Unable to create the root IDxDiagContainer\n");
738 /* Verify the identity and ordering of the root container's children. */
739 hr
= IDxDiagContainer_GetNumberOfChildContainers(pddc
, &count
);
740 ok(hr
== S_OK
, "Expected IDxDiagContainer::GetNumberOfChildContainers to return S_OK, got 0x%08x\n", hr
);
743 skip("IDxDiagContainer::GetNumberOfChildContainers failed\n");
747 ok(count
== sizeof(root_children
)/sizeof(root_children
[0]),
748 "Got unexpected count %u for the number of child containers\n", count
);
750 if (count
!= sizeof(root_children
)/sizeof(root_children
[0]))
752 skip("Received unexpected number of child containers\n");
756 for (index
= 0; index
<= count
; index
++)
758 WCHAR container
[256];
760 hr
= IDxDiagContainer_EnumChildContainerNames(pddc
, index
, container
, sizeof(container
)/sizeof(WCHAR
));
761 if (hr
== E_INVALIDARG
)
764 "Expected IDxDiagContainer::EnumChildContainerNames to return "
765 "E_INVALIDARG on the last index %u\n", count
);
770 ok(!lstrcmpW(container
, root_children
[index
]),
771 "Expected container %s for index %u, got %s\n",
772 wine_dbgstr_w(root_children
[index
]), index
, wine_dbgstr_w(container
));
776 ok(0, "IDxDiagContainer::EnumChildContainerNames unexpectedly returned 0x%08x\n", hr
);
782 IDxDiagContainer_Release(pddc
);
783 IDxDiagProvider_Release(pddp
);
786 static void test_container_properties(IDxDiagContainer
*container
, const struct property_test
*property_tests
, size_t len
)
790 /* Check that the container has no properties if there are no properties to examine. */
795 hr
= IDxDiagContainer_GetNumberOfProps(container
, &prop_count
);
796 ok(hr
== S_OK
, "Expected IDxDiagContainer::GetNumberOfProps to return S_OK, got 0x%08x\n", hr
);
798 ok(prop_count
== 0, "Expected container property count to be zero, got %u\n", prop_count
);
807 /* Examine the variant types of obtained property values. */
808 for (i
= 0; i
< len
; i
++)
810 hr
= IDxDiagContainer_GetProp(container
, property_tests
[i
].prop
, &var
);
811 ok(hr
== S_OK
, "[%d] Expected IDxDiagContainer::GetProp to return S_OK for %s, got 0x%08x\n",
812 i
, wine_dbgstr_w(property_tests
[i
].prop
), hr
);
816 ok(V_VT(&var
) == property_tests
[i
].vt
,
817 "[%d] Expected variant type %d, got %d\n", i
, property_tests
[i
].vt
, V_VT(&var
));
818 trace("%s = %s\n", wine_dbgstr_w(property_tests
[i
].prop
), debugstr_variant(&var
));
825 static void test_DxDiag_SystemInfo(void)
827 static const WCHAR dwOSMajorVersion
[] = {'d','w','O','S','M','a','j','o','r','V','e','r','s','i','o','n',0};
828 static const WCHAR dwOSMinorVersion
[] = {'d','w','O','S','M','i','n','o','r','V','e','r','s','i','o','n',0};
829 static const WCHAR dwOSBuildNumber
[] = {'d','w','O','S','B','u','i','l','d','N','u','m','b','e','r',0};
830 static const WCHAR dwOSPlatformID
[] = {'d','w','O','S','P','l','a','t','f','o','r','m','I','D',0};
831 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};
832 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};
833 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};
834 static const WCHAR bDebug
[] = {'b','D','e','b','u','g',0};
835 static const WCHAR bNECPC98
[] = {'b','N','E','C','P','C','9','8',0};
836 static const WCHAR ullPhysicalMemory
[] = {'u','l','l','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
837 static const WCHAR ullUsedPageFile
[] = {'u','l','l','U','s','e','d','P','a','g','e','F','i','l','e',0};
838 static const WCHAR ullAvailPageFile
[] = {'u','l','l','A','v','a','i','l','P','a','g','e','F','i','l','e',0};
839 static const WCHAR szWindowsDir
[] = {'s','z','W','i','n','d','o','w','s','D','i','r',0};
840 static const WCHAR szCSDVersion
[] = {'s','z','C','S','D','V','e','r','s','i','o','n',0};
841 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};
842 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};
843 static const WCHAR bNetMeetingRunning
[] = {'b','N','e','t','M','e','e','t','i','n','g','R','u','n','n','i','n','g',0};
844 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};
845 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};
846 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};
847 static const WCHAR szLanguagesEnglish
[] = {'s','z','L','a','n','g','u','a','g','e','s','E','n','g','l','i','s','h',0};
848 static const WCHAR szTimeLocalized
[] = {'s','z','T','i','m','e','L','o','c','a','l','i','z','e','d',0};
849 static const WCHAR szTimeEnglish
[] = {'s','z','T','i','m','e','E','n','g','l','i','s','h',0};
850 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};
851 static const WCHAR szPageFileLocalized
[] = {'s','z','P','a','g','e','F','i','l','e','L','o','c','a','l','i','z','e','d',0};
852 static const WCHAR szPageFileEnglish
[] = {'s','z','P','a','g','e','F','i','l','e','E','n','g','l','i','s','h',0};
853 static const WCHAR szOSLocalized
[] = {'s','z','O','S','L','o','c','a','l','i','z','e','d',0};
854 static const WCHAR szOSExLocalized
[] = {'s','z','O','S','E','x','L','o','c','a','l','i','z','e','d',0};
855 static const WCHAR szOSExLongLocalized
[] = {'s','z','O','S','E','x','L','o','n','g','L','o','c','a','l','i','z','e','d',0};
856 static const WCHAR szOSEnglish
[] = {'s','z','O','S','E','n','g','l','i','s','h',0};
857 static const WCHAR szOSExEnglish
[] = {'s','z','O','S','E','x','E','n','g','l','i','s','h',0};
858 static const WCHAR szOSExLongEnglish
[] = {'s','z','O','S','E','x','L','o','n','g','E','n','g','l','i','s','h',0};
860 static const struct property_test property_tests
[] =
862 {dwOSMajorVersion
, VT_UI4
},
863 {dwOSMinorVersion
, VT_UI4
},
864 {dwOSBuildNumber
, VT_UI4
},
865 {dwOSPlatformID
, VT_UI4
},
866 {dwDirectXVersionMajor
, VT_UI4
},
867 {dwDirectXVersionMinor
, VT_UI4
},
868 {szDirectXVersionLetter
, VT_BSTR
},
871 {ullPhysicalMemory
, VT_BSTR
},
872 {ullUsedPageFile
, VT_BSTR
},
873 {ullAvailPageFile
, VT_BSTR
},
874 {szWindowsDir
, VT_BSTR
},
875 {szCSDVersion
, VT_BSTR
},
876 {szDirectXVersionEnglish
, VT_BSTR
},
877 {szDirectXVersionLongEnglish
, VT_BSTR
},
878 {bNetMeetingRunning
, VT_BOOL
},
879 {szMachineNameLocalized
, VT_BSTR
},
880 {szMachineNameEnglish
, VT_BSTR
},
881 {szLanguagesLocalized
, VT_BSTR
},
882 {szLanguagesEnglish
, VT_BSTR
},
883 {szTimeLocalized
, VT_BSTR
},
884 {szTimeEnglish
, VT_BSTR
},
885 {szPhysicalMemoryEnglish
, VT_BSTR
},
886 {szPageFileLocalized
, VT_BSTR
},
887 {szPageFileEnglish
, VT_BSTR
},
888 {szOSLocalized
, VT_BSTR
},
889 {szOSExLocalized
, VT_BSTR
},
890 {szOSExLongLocalized
, VT_BSTR
},
891 {szOSEnglish
, VT_BSTR
},
892 {szOSExEnglish
, VT_BSTR
},
893 {szOSExLongEnglish
, VT_BSTR
},
896 IDxDiagContainer
*container
;
899 if (!create_root_IDxDiagContainer())
901 skip("Unable to create the root IDxDiagContainer\n");
905 hr
= IDxDiagContainer_GetChildContainer(pddc
, DxDiag_SystemInfo
, &container
);
906 ok(hr
== S_OK
, "Expected IDxDiagContainer::GetChildContainer to return S_OK, got 0x%08x\n", hr
);
910 trace("Testing container DxDiag_SystemInfo\n");
911 test_container_properties(container
, property_tests
, sizeof(property_tests
)/sizeof(property_tests
[0]));
912 IDxDiagContainer_Release(container
);
915 IDxDiagContainer_Release(pddc
);
916 IDxDiagProvider_Release(pddp
);
919 static void test_DxDiag_DisplayDevices(void)
921 static const WCHAR szDescription
[] = {'s','z','D','e','s','c','r','i','p','t','i','o','n',0};
922 static const WCHAR szDeviceName
[] = {'s','z','D','e','v','i','c','e','N','a','m','e',0};
923 static const WCHAR szKeyDeviceID
[] = {'s','z','K','e','y','D','e','v','i','c','e','I','D',0};
924 static const WCHAR szKeyDeviceKey
[] = {'s','z','K','e','y','D','e','v','i','c','e','K','e','y',0};
925 static const WCHAR szVendorId
[] = {'s','z','V','e','n','d','o','r','I','d',0};
926 static const WCHAR szDeviceId
[] = {'s','z','D','e','v','i','c','e','I','d',0};
927 static const WCHAR szDeviceIdentifier
[] = {'s','z','D','e','v','i','c','e','I','d','e','n','t','i','f','i','e','r',0};
928 static const WCHAR dwWidth
[] = {'d','w','W','i','d','t','h',0};
929 static const WCHAR dwHeight
[] = {'d','w','H','e','i','g','h','t',0};
930 static const WCHAR dwBpp
[] = {'d','w','B','p','p',0};
931 static const WCHAR szDisplayMemoryLocalized
[] = {'s','z','D','i','s','p','l','a','y','M','e','m','o','r','y','L','o','c','a','l','i','z','e','d',0};
932 static const WCHAR szDisplayMemoryEnglish
[] = {'s','z','D','i','s','p','l','a','y','M','e','m','o','r','y','E','n','g','l','i','s','h',0};
933 static const WCHAR szDriverName
[] = {'s','z','D','r','i','v','e','r','N','a','m','e',0};
934 static const WCHAR szDriverVersion
[] = {'s','z','D','r','i','v','e','r','V','e','r','s','i','o','n',0};
935 static const WCHAR szSubSysId
[] = {'s','z','S','u','b','S','y','s','I','d',0};
936 static const WCHAR szRevisionId
[] = {'s','z','R','e','v','i','s','i','o','n','I','d',0};
937 static const WCHAR dwRefreshRate
[] = {'d','w','R','e','f','r','e','s','h','R','a','t','e',0};
938 static const WCHAR szManufacturer
[] = {'s','z','M','a','n','u','f','a','c','t','u','r','e','r',0};
940 static const struct property_test property_tests
[] =
942 {szDescription
, VT_BSTR
},
943 {szDeviceName
, VT_BSTR
},
944 {szKeyDeviceID
, VT_BSTR
},
945 {szKeyDeviceKey
, VT_BSTR
},
946 {szVendorId
, VT_BSTR
},
947 {szDeviceId
, VT_BSTR
},
948 {szDeviceIdentifier
, VT_BSTR
},
952 {szDisplayMemoryLocalized
, VT_BSTR
},
953 {szDisplayMemoryEnglish
, VT_BSTR
},
954 {szDriverName
, VT_BSTR
},
955 {szDriverVersion
, VT_BSTR
},
956 {szSubSysId
, VT_BSTR
},
957 {szRevisionId
, VT_BSTR
},
958 {dwRefreshRate
, VT_UI4
},
959 {szManufacturer
, VT_BSTR
},
962 IDxDiagContainer
*display_cont
= NULL
;
966 if (!create_root_IDxDiagContainer())
968 skip("Unable to create the root IDxDiagContainer\n");
972 hr
= IDxDiagContainer_GetChildContainer(pddc
, DxDiag_DisplayDevices
, &display_cont
);
973 ok(hr
== S_OK
, "Expected IDxDiagContainer::GetChildContainer to return S_OK, got 0x%08x\n", hr
);
978 hr
= IDxDiagContainer_GetNumberOfProps(display_cont
, &count
);
979 ok(hr
== S_OK
, "Expected IDxDiagContainer::GetNumberOfProps to return S_OK, got 0x%08x\n", hr
);
981 ok(count
== 0, "Expected count to be 0, got %u\n", count
);
983 hr
= IDxDiagContainer_GetNumberOfChildContainers(display_cont
, &count
);
984 ok(hr
== S_OK
, "Expected IDxDiagContainer::GetNumberOfChildContainers to return S_OK, got 0x%08x\n", hr
);
989 for (i
= 0; i
< count
; i
++)
991 WCHAR child_container
[256];
992 IDxDiagContainer
*child
;
994 hr
= IDxDiagContainer_EnumChildContainerNames(display_cont
, i
, child_container
, sizeof(child_container
)/sizeof(WCHAR
));
995 ok(hr
== S_OK
, "Expected IDxDiagContainer::EnumChildContainerNames to return S_OK, got 0x%08x\n", hr
);
997 hr
= IDxDiagContainer_GetChildContainer(display_cont
, child_container
, &child
);
998 ok(hr
== S_OK
, "Expected IDxDiagContainer::GetChildContainer to return S_OK, got 0x%08x\n", hr
);
1002 trace("Testing container %s\n", wine_dbgstr_w(child_container
));
1003 test_container_properties(child
, property_tests
, sizeof(property_tests
)/sizeof(property_tests
[0]));
1008 if (display_cont
) IDxDiagContainer_Release(display_cont
);
1009 IDxDiagContainer_Release(pddc
);
1010 IDxDiagProvider_Release(pddp
);
1013 START_TEST(container
)
1016 test_GetNumberOfChildContainers();
1017 test_GetNumberOfProps();
1018 test_EnumChildContainerNames();
1019 test_GetChildContainer();
1021 test_EnumPropNames();
1024 test_root_children();
1025 test_DxDiag_SystemInfo();
1026 test_DxDiag_DisplayDevices();