ReactOS 0.4.17-dev-966-gf06eace
container.c
Go to the documentation of this file.
1/*
2 * Unit tests for IDxDiagContainer
3 *
4 * Copyright 2010 Andrew Nguyen
5 *
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.
10 *
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.
15 *
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
19 */
20
21#define COBJMACROS
22
23#include <stdio.h>
24#include "dxdiag.h"
25#include "oleauto.h"
26#include "wine/test.h"
27
29{
30 const WCHAR *prop;
32};
33
34static IDxDiagProvider *pddp;
35static IDxDiagContainer *pddc;
36
38{
39 HRESULT hr;
41
42 hr = CoCreateInstance(&CLSID_DxDiagProvider, NULL, CLSCTX_INPROC_SERVER,
43 &IID_IDxDiagProvider, (LPVOID*)&pddp);
44 if (SUCCEEDED(hr))
45 {
46 params.dwSize = sizeof(params);
47 params.dwDxDiagHeaderVersion = DXDIAG_DX9_SDK_VERSION;
48 params.bAllowWHQLChecks = FALSE;
49 params.pReserved = NULL;
51 if (SUCCEEDED(hr))
52 {
54 if (SUCCEEDED(hr))
55 return TRUE;
56 }
58 }
59 return FALSE;
60}
61
63{
64 HRESULT hr;
66
68 {
69 skip("Unable to create the root IDxDiagContainer\n");
70 return;
71 }
72
75 "Expected IDxDiagContainer::GetNumberOfChildContainers to return E_INVALIDARG, got 0x%08lx\n", hr);
76
78 ok(hr == S_OK,
79 "Expected IDxDiagContainer::GetNumberOfChildContainers to return S_OK, got 0x%08lx\n", hr);
80 if (hr == S_OK)
81 ok(count != 0, "Expected the number of child containers for the root container to be non-zero\n");
82
85}
86
87static void test_GetNumberOfProps(void)
88{
89 HRESULT hr;
91
93 {
94 skip("Unable to create the root IDxDiagContainer\n");
95 return;
96 }
97
99 ok(hr == E_INVALIDARG, "Expected IDxDiagContainer::GetNumberOfProps to return E_INVALIDARG, got 0x%08lx\n", hr);
100
102 ok(hr == S_OK, "Expected IDxDiagContainer::GetNumberOfProps to return S_OK, got 0x%08lx\n", hr);
103 if (hr == S_OK)
104 ok(count == 0, "Expected the number of properties for the root container to be zero\n");
105
108}
109
111{
112 HRESULT hr;
113 WCHAR container[256];
114 DWORD maxcount, index;
115 static const WCHAR testW[] = L"test";
116
118 {
119 skip("Unable to create the root IDxDiagContainer\n");
120 return;
121 }
122
123 /* Test various combinations of invalid parameters. */
125 ok(hr == E_INVALIDARG,
126 "Expected IDxDiagContainer::EnumChildContainerNames to return E_INVALIDARG, got 0x%08lx\n", hr);
127
129 ok(hr == E_INVALIDARG,
130 "Expected IDxDiagContainer::EnumChildContainerNames to return E_INVALIDARG, got 0x%08lx\n", hr);
131
132 /* Test the conditions in which the output buffer can be modified. */
133 memcpy(container, testW, sizeof(testW));
135 ok(hr == E_INVALIDARG,
136 "Expected IDxDiagContainer::EnumChildContainerNames to return E_INVALIDARG, got 0x%08lx\n", hr);
137 ok(!memcmp(container, testW, sizeof(testW)),
138 "Expected the container buffer to be untouched, got %s\n", wine_dbgstr_w(container));
139
140 memcpy(container, testW, sizeof(testW));
142 ok(hr == E_INVALIDARG,
143 "Expected IDxDiagContainer::EnumChildContainerNames to return E_INVALIDARG, got 0x%08lx\n", hr);
144 ok(!memcmp(container, testW, sizeof(testW)),
145 "Expected the container buffer to be untouched, got %s\n", wine_dbgstr_w(container));
146
147 memcpy(container, testW, sizeof(testW));
149 ok(hr == E_INVALIDARG,
150 "Expected IDxDiagContainer::EnumChildContainerNames to return E_INVALIDARG, got 0x%08lx\n", hr);
151 ok(!memcmp(container, L"\0est", sizeof(L"\0est")),
152 "Expected the container buffer string to be empty, got %s\n", wine_dbgstr_w(container));
153
155 ok(hr == S_OK, "Expected IDxDiagContainer::GetNumberOfChildContainers to return S_OK, got 0x%08lx\n", hr);
156 if (FAILED(hr))
157 {
158 skip("IDxDiagContainer::GetNumberOfChildContainers failed\n");
159 goto cleanup;
160 }
161
162 trace("Starting child container enumeration of the root container:\n");
163
164 /* We should be able to enumerate as many child containers as the value
165 * that IDxDiagContainer::GetNumberOfChildContainers returns. */
166 for (index = 0; index <= maxcount; index++)
167 {
168 /* A buffer size of 1 is unlikely to be valid, as only a null terminator
169 * could be stored, and it is unlikely that a container name could be empty. */
170 DWORD buffersize = 1;
171 memcpy(container, testW, sizeof(testW));
173 if (hr == E_INVALIDARG)
174 {
175 /* We should get here when index is one more than the maximum index value. */
176 ok(maxcount == index,
177 "Expected IDxDiagContainer::EnumChildContainerNames to return E_INVALIDARG "
178 "on the last index %ld, got 0x%08lx\n", index, hr);
179 ok(container[0] == '\0',
180 "Expected the container buffer string to be empty, got %s\n", wine_dbgstr_w(container));
181 break;
182 }
184 {
185 WCHAR temp[256];
186
187 ok(container[0] == '\0',
188 "Expected the container buffer string to be empty, got %s\n", wine_dbgstr_w(container));
189
190 /* Get the container name to compare against. */
192 ok(hr == S_OK,
193 "Expected IDxDiagContainer::EnumChildContainerNames to return S_OK, got 0x%08lx\n", hr);
194
195 /* Show that the DirectX SDK's stipulation that the buffer be at
196 * least 256 characters long is a mere suggestion, and smaller sizes
197 * can be acceptable also. IDxDiagContainer::EnumChildContainerNames
198 * doesn't provide a way of getting the exact size required, so the
199 * buffersize value will be iterated to at most 256 characters. */
200 for (buffersize = 2; buffersize <= 256; buffersize++)
201 {
202 memcpy(container, testW, sizeof(testW));
205 break;
206
207 ok(!memcmp(temp, container, sizeof(WCHAR)*(buffersize - 1)),
208 "Expected truncated container name string, got %s\n", wine_dbgstr_w(container));
209 }
210
211 ok(hr == S_OK,
212 "Expected IDxDiagContainer::EnumChildContainerNames to return S_OK, "
213 "got hr = 0x%08lx, buffersize = %ld\n", hr, buffersize);
214 if (hr == S_OK)
215 trace("pddc[%ld] = %s, length = %ld\n", index, wine_dbgstr_w(container), buffersize);
216 }
217 else
218 {
219 ok(0, "IDxDiagContainer::EnumChildContainerNames unexpectedly returned 0x%08lx\n", hr);
220 break;
221 }
222 }
223
224cleanup:
227}
228
229static void test_GetChildContainer(void)
230{
231 HRESULT hr;
232 WCHAR container[256] = {0};
233 IDxDiagContainer *child;
234
236 {
237 skip("Unable to create the root IDxDiagContainer\n");
238 return;
239 }
240
241 /* Test various combinations of invalid parameters. */
243 ok(hr == E_INVALIDARG,
244 "Expected IDxDiagContainer::GetChildContainer to return E_INVALIDARG, got 0x%08lx\n", hr);
245
246 child = (void*)0xdeadbeef;
248 ok(hr == E_INVALIDARG,
249 "Expected IDxDiagContainer::GetChildContainer to return E_INVALIDARG, got 0x%08lx\n", hr);
250 ok(child == (void*)0xdeadbeef, "Expected output pointer to be unchanged, got %p\n", child);
251
253 ok(hr == E_INVALIDARG,
254 "Expected IDxDiagContainer::GetChildContainer to return E_INVALIDARG, got 0x%08lx\n", hr);
255
256 child = (void*)0xdeadbeef;
258 ok(hr == E_INVALIDARG,
259 "Expected IDxDiagContainer::GetChildContainer to return E_INVALIDARG, got 0x%08lx\n", hr);
260 ok(child == NULL, "Expected output pointer to be NULL, got %p\n", child);
261
262 /* Get the name of a suitable child container. */
264 ok(hr == S_OK,
265 "Expected IDxDiagContainer::EnumChildContainerNames to return S_OK, got 0x%08lx\n", hr);
266 if (FAILED(hr))
267 {
268 skip("IDxDiagContainer::EnumChildContainerNames failed\n");
269 goto cleanup;
270 }
271
272 child = (void*)0xdeadbeef;
274 ok(hr == S_OK,
275 "Expected IDxDiagContainer::GetChildContainer to return S_OK, got 0x%08lx\n", hr);
276 ok(child != NULL && child != (void*)0xdeadbeef, "Expected a valid output pointer, got %p\n", child);
277
278 if (SUCCEEDED(hr))
279 {
280 IDxDiagContainer *ptr;
281
282 /* Show that IDxDiagContainer::GetChildContainer returns a different pointer
283 * for multiple calls for the same container name. */
285 ok(hr == S_OK,
286 "Expected IDxDiagContainer::GetChildContainer to return S_OK, got 0x%08lx\n", hr);
287 if (SUCCEEDED(hr))
288 ok(ptr != child, "Expected the two pointers (%p vs. %p) to be unequal\n", child, ptr);
289
292 }
293
294cleanup:
297}
298
299static void test_dot_parsing(void)
300{
301 HRESULT hr;
302 WCHAR containerbufW[256] = {0}, childbufW[256] = {0};
304 size_t i;
305 static const struct
306 {
307 const char *format;
308 const HRESULT expect;
309 } test_strings[] = {
310 { "%s.%s", S_OK },
311 { "%s.%s.", S_OK },
312 { ".%s.%s", E_INVALIDARG },
313 { "%s.%s..", E_INVALIDARG },
314 { ".%s.%s.", E_INVALIDARG },
315 { "..%s.%s", E_INVALIDARG },
316 };
317
319 {
320 skip("Unable to create the root IDxDiagContainer\n");
321 return;
322 }
323
324 /* Find a container with a child container of its own. */
326 ok(hr == S_OK, "Expected IDxDiagContainer::GetNumberOfChildContainers to return S_OK, got 0x%08lx\n", hr);
327 if (FAILED(hr))
328 {
329 skip("IDxDiagContainer::GetNumberOfChildContainers failed\n");
330 goto cleanup;
331 }
332
333 for (index = 0; index < count; index++)
334 {
335 IDxDiagContainer *child;
336
337 hr = IDxDiagContainer_EnumChildContainerNames(pddc, index, containerbufW, ARRAY_SIZE(containerbufW));
338 ok(hr == S_OK, "Expected IDxDiagContainer_EnumChildContainerNames to return S_OK, got 0x%08lx\n", hr);
339 if (FAILED(hr))
340 {
341 skip("IDxDiagContainer::EnumChildContainerNames failed\n");
342 goto cleanup;
343 }
344
346 ok(hr == S_OK, "Expected IDxDiagContainer::GetChildContainer to return S_OK, got 0x%08lx\n", hr);
347
348 if (SUCCEEDED(hr))
349 {
350 hr = IDxDiagContainer_EnumChildContainerNames(child, 0, childbufW, ARRAY_SIZE(childbufW));
351 ok(hr == S_OK || hr == E_INVALIDARG,
352 "Expected IDxDiagContainer::EnumChildContainerNames to return S_OK or E_INVALIDARG, got 0x%08lx\n", hr);
354
355 if (SUCCEEDED(hr))
356 break;
357 }
358 }
359
360 if (!*containerbufW || !*childbufW)
361 {
362 skip("Unable to find a suitable container\n");
363 goto cleanup;
364 }
365
366 trace("Testing IDxDiagContainer::GetChildContainer dot parsing with container %s and child container %s.\n",
367 wine_dbgstr_w(containerbufW), wine_dbgstr_w(childbufW));
368
369 for (i = 0; i < ARRAY_SIZE(test_strings); i++)
370 {
371 IDxDiagContainer *child;
372 char containerbufA[256];
373 char childbufA[256];
374 char dotbufferA[255 + 255 + 3 + 1];
375 WCHAR dotbufferW[255 + 255 + 3 + 1]; /* containerbuf + childbuf + dots + null terminator */
376
377 WideCharToMultiByte(CP_ACP, 0, containerbufW, -1, containerbufA, sizeof(containerbufA), NULL, NULL);
378 WideCharToMultiByte(CP_ACP, 0, childbufW, -1, childbufA, sizeof(childbufA), NULL, NULL);
379 sprintf(dotbufferA, test_strings[i].format, containerbufA, childbufA);
380 MultiByteToWideChar(CP_ACP, 0, dotbufferA, -1, dotbufferW, ARRAY_SIZE(dotbufferW));
381
382 trace("Trying container name %s\n", wine_dbgstr_w(dotbufferW));
384 ok(hr == test_strings[i].expect,
385 "Expected IDxDiagContainer::GetChildContainer to return 0x%08lx for %s, got 0x%08lx\n",
386 test_strings[i].expect, wine_dbgstr_w(dotbufferW), hr);
387 if (SUCCEEDED(hr))
389 }
390
391cleanup:
394}
395
396static void test_EnumPropNames(void)
397{
398 HRESULT hr;
399 WCHAR container[256], property[256];
400 IDxDiagContainer *child = NULL;
401 DWORD count, index, propcount;
402 static const WCHAR testW[] = L"test";
403
405 {
406 skip("Unable to create the root IDxDiagContainer\n");
407 return;
408 }
409
410 /* Find a container with a non-zero number of properties. */
412 ok(hr == S_OK, "Expected IDxDiagContainer::GetNumberOfChildContainers to return S_OK, got 0x%08lx\n", hr);
413 if (FAILED(hr))
414 {
415 skip("IDxDiagContainer::GetNumberOfChildContainers failed\n");
416 goto cleanup;
417 }
418
419 for (index = 0; index < count; index++)
420 {
422 ok(hr == S_OK, "Expected IDxDiagContainer_EnumChildContainerNames to return S_OK, got 0x%08lx\n", hr);
423 if (FAILED(hr))
424 {
425 skip("IDxDiagContainer::EnumChildContainerNames failed\n");
426 goto cleanup;
427 }
428
430 ok(hr == S_OK, "Expected IDxDiagContainer::GetChildContainer to return S_OK, got 0x%08lx\n", hr);
431
432 if (SUCCEEDED(hr))
433 {
435 ok(hr == S_OK, "Expected IDxDiagContainer::GetNumberOfProps to return S_OK, got 0x%08lx\n", hr);
436
437 if (!propcount)
438 {
440 child = NULL;
441 }
442 else
443 break;
444 }
445 }
446
447 if (!child)
448 {
449 skip("Unable to find a container with non-zero property count\n");
450 goto cleanup;
451 }
452
454 ok(hr == E_INVALIDARG, "Expected IDxDiagContainer::EnumPropNames to return E_INVALIDARG, got 0x%08lx\n", hr);
455
456 memcpy(property, testW, sizeof(testW));
458 ok(hr == E_INVALIDARG, "Expected IDxDiagContainer::EnumPropNames to return E_INVALIDARG, got 0x%08lx\n", hr);
459 ok(!memcmp(property, testW, sizeof(testW)),
460 "Expected the property buffer to be unchanged, got %s\n", wine_dbgstr_w(property));
461
462 memcpy(property, testW, sizeof(testW));
464 ok(hr == E_INVALIDARG, "Expected IDxDiagContainer::EnumPropNames to return E_INVALIDARG, got 0x%08lx\n", hr);
465 ok(!memcmp(property, testW, sizeof(testW)),
466 "Expected the property buffer to be unchanged, got %s\n", wine_dbgstr_w(property));
467
468 trace("Starting property enumeration of the %s container:\n", wine_dbgstr_w(container));
469
470 /* We should be able to enumerate as many properties as the value that
471 * IDxDiagContainer::GetNumberOfProps returns. */
472 for (index = 0; index <= propcount; index++)
473 {
474 /* A buffer size of 1 is unlikely to be valid, as only a null terminator
475 * could be stored, and it is unlikely that a property name could be empty. */
476 DWORD buffersize = 1;
477
478 memcpy(property, testW, sizeof(testW));
480 if (hr == E_INVALIDARG)
481 {
482 /* We should get here when index is one more than the maximum index value. */
483 ok(propcount == index,
484 "Expected IDxDiagContainer::EnumPropNames to return E_INVALIDARG "
485 "on the last index %ld, got 0x%08lx\n", index, hr);
486 ok(!memcmp(property, testW, sizeof(testW)),
487 "Expected the property buffer to be unchanged, got %s\n", wine_dbgstr_w(property));
488 break;
489 }
491 {
492 WCHAR temp[256];
493
494 ok(property[0] == '\0',
495 "Expected the property buffer string to be empty, got %s\n", wine_dbgstr_w(property));
497 ok(hr == S_OK,
498 "Expected IDxDiagContainer::EnumPropNames to return S_OK, got 0x%08lx\n", hr);
499
500 /* Show that the DirectX SDK's stipulation that the buffer be at
501 * least 256 characters long is a mere suggestion, and smaller sizes
502 * can be acceptable also. IDxDiagContainer::EnumPropNames doesn't
503 * provide a way of getting the exact size required, so the buffersize
504 * value will be iterated to at most 256 characters. */
505 for (buffersize = 2; buffersize <= 256; buffersize++)
506 {
507 memcpy(property, testW, sizeof(testW));
510 break;
511
512 ok(!memcmp(temp, property, sizeof(WCHAR)*(buffersize - 1)),
513 "Expected truncated property name string, got %s\n", wine_dbgstr_w(property));
514 }
515
516 ok(hr == S_OK,
517 "Expected IDxDiagContainer::EnumPropNames to return S_OK, "
518 "got hr = 0x%08lx, buffersize = %ld\n", hr, buffersize);
519 if (hr == S_OK)
520 trace("child[%ld] = %s, length = %ld\n", index, wine_dbgstr_w(property), buffersize);
521 }
522 else
523 {
524 ok(0, "IDxDiagContainer::EnumPropNames unexpectedly returned 0x%08lx\n", hr);
525 break;
526 }
527 }
528
530
531cleanup:
534}
535
536static void test_GetProp(void)
537{
538 HRESULT hr;
539 WCHAR container[256], property[256];
540 IDxDiagContainer *child = NULL;
542 VARIANT var;
543 SAFEARRAY *sa;
544 SAFEARRAYBOUND bound;
545 ULONG ref;
546 static const WCHAR testW[] = L"test";
547
549 {
550 skip("Unable to create the root IDxDiagContainer\n");
551 return;
552 }
553
554 /* Find a container with a property. */
556 ok(hr == S_OK, "Expected IDxDiagContainer::GetNumberOfChildContainers to return S_OK, got 0x%08lx\n", hr);
557 if (FAILED(hr))
558 {
559 skip("IDxDiagContainer::GetNumberOfChildContainers failed\n");
560 goto cleanup;
561 }
562
563 for (index = 0; index < count; index++)
564 {
566 ok(hr == S_OK, "Expected IDxDiagContainer_EnumChildContainerNames to return S_OK, got 0x%08lx\n", hr);
567 if (FAILED(hr))
568 {
569 skip("IDxDiagContainer::EnumChildContainerNames failed\n");
570 goto cleanup;
571 }
572
574 ok(hr == S_OK, "Expected IDxDiagContainer::GetChildContainer to return S_OK, got 0x%08lx\n", hr);
575
576 if (SUCCEEDED(hr))
577 {
579 ok(hr == S_OK || hr == E_INVALIDARG,
580 "Expected IDxDiagContainer::EnumPropNames to return S_OK or E_INVALIDARG, got 0x%08lx\n", hr);
581
582 if (SUCCEEDED(hr))
583 break;
584 else
585 {
587 child = NULL;
588 }
589 }
590 }
591
592 if (!child)
593 {
594 skip("Unable to find a suitable container\n");
595 goto cleanup;
596 }
597
599 ok(hr == E_INVALIDARG, "Expected IDxDiagContainer::GetProp to return E_INVALIDARG, got 0x%08lx\n", hr);
600
601 V_VT(&var) = 0xdead;
603 ok(hr == E_INVALIDARG, "Expected IDxDiagContainer::GetProp to return E_INVALIDARG, got 0x%08lx\n", hr);
604 ok(V_VT(&var) == 0xdead, "Expected the variant to be untouched, got %u\n", V_VT(&var));
605
607 ok(hr == E_INVALIDARG, "Expected IDxDiagContainer::GetProp to return E_INVALIDARG, got 0x%08lx\n", hr);
608
609 V_VT(&var) = 0xdead;
611 ok(hr == E_INVALIDARG, "Expected IDxDiagContainer::GetProp to return E_INVALIDARG, got 0x%08lx\n", hr);
612 ok(V_VT(&var) == 0xdead, "Expected the variant to be untouched, got %u\n", V_VT(&var));
613
615 ok(hr == E_INVALIDARG, "Expected IDxDiagContainer::GetProp to return E_INVALIDARG, got 0x%08lx\n", hr);
616
617 V_VT(&var) = 0xdead;
619 ok(hr == E_INVALIDARG, "Expected IDxDiagContainer::GetProp to return E_INVALIDARG, got 0x%08lx\n", hr);
620 ok(V_VT(&var) == 0xdead, "Expected the variant to be untouched, got %u\n", V_VT(&var));
621
624 ok(hr == S_OK, "Expected IDxDiagContainer::GetProp to return S_OK, got 0x%08lx\n", hr);
625 ok(V_VT(&var) != VT_EMPTY, "Expected the variant to be modified, got %d\n", V_VT(&var));
626
627 /* Since the documentation for IDxDiagContainer::GetProp claims that the
628 * function reports return values from VariantCopy, try to exercise failure
629 * paths in handling the destination variant. */
630
631 /* Try an invalid variant type. */
632 V_VT(&var) = 0xdead;
634 ok(hr == S_OK, "Expected IDxDiagContainer::GetProp to return S_OK, got 0x%08lx\n", hr);
635 ok(V_VT(&var) != 0xdead, "Expected the variant to be modified, got %d\n", V_VT(&var));
636
637 /* Try passing a variant with a locked SAFEARRAY. */
638 bound.cElements = 1;
639 bound.lLbound = 0;
640 sa = SafeArrayCreate(VT_UI1, 1, &bound);
641 ok(sa != NULL, "Expected SafeArrayCreate to return a valid pointer\n");
642
643 V_VT(&var) = (VT_ARRAY | VT_UI1);
644 V_ARRAY(&var) = sa;
645
647 ok(hr == S_OK, "Expected SafeArrayLock to return S_OK, got 0x%08lx\n", hr);
648
650 ok(hr == S_OK, "Expected IDxDiagContainer::GetProp to return S_OK, got 0x%08lx\n", hr);
651 ok(V_VT(&var) != (VT_ARRAY | VT_UI1), "Expected the variant to be modified\n");
652
654 ok(hr == S_OK, "Expected SafeArrayUnlock to return S_OK, got 0x%08lx\n", hr);
656 ok(hr == S_OK, "Expected SafeArrayDestroy to return S_OK, got 0x%08lx\n", hr);
657
658 /* Determine whether GetProp calls VariantClear on the passed variant. */
659 V_VT(&var) = VT_UNKNOWN;
662
664 ok(hr == S_OK, "Expected IDxDiagContainer::GetProp to return S_OK, got 0x%08lx\n", hr);
665 ok(V_VT(&var) != VT_UNKNOWN, "Expected the variant to be modified\n");
666
669 ok(ref == 2, "Expected reference count to be 2, got %lu\n", ref);
671
673cleanup:
676}
677
678static void test_root_children(void)
679{
680 HRESULT hr;
682
683 static const WCHAR *root_children[] = {
684 L"DxDiag_SystemInfo", L"DxDiag_DisplayDevices", L"DxDiag_DirectSound",
685 L"DxDiag_DirectMusic", L"DxDiag_DirectInput", L"DxDiag_DirectPlay",
686 L"DxDiag_SystemDevices", L"DxDiag_DirectXFiles", L"DxDiag_DirectShowFilters",
687 L"DxDiag_LogicalDisks"
688 };
689
691 {
692 skip("Unable to create the root IDxDiagContainer\n");
693 return;
694 }
695
696 /* Verify the identity and ordering of the root container's children. */
698 ok(hr == S_OK, "Expected IDxDiagContainer::GetNumberOfChildContainers to return S_OK, got 0x%08lx\n", hr);
699 if (FAILED(hr))
700 {
701 skip("IDxDiagContainer::GetNumberOfChildContainers failed\n");
702 goto cleanup;
703 }
704
705 ok(count == ARRAY_SIZE(root_children),
706 "Got unexpected count %lu for the number of child containers\n", count);
707
708 if (count != ARRAY_SIZE(root_children))
709 {
710 skip("Received unexpected number of child containers\n");
711 goto cleanup;
712 }
713
714 for (index = 0; index <= count; index++)
715 {
716 WCHAR container[256];
717
719 if (hr == E_INVALIDARG)
720 {
721 ok(index == count,
722 "Expected IDxDiagContainer::EnumChildContainerNames to return "
723 "E_INVALIDARG on the last index %lu\n", count);
724 break;
725 }
726 else if (hr == S_OK)
727 {
728 ok(!lstrcmpW(container, root_children[index]),
729 "Expected container %s for index %lu, got %s\n",
730 wine_dbgstr_w(root_children[index]), index, wine_dbgstr_w(container));
731 }
732 else
733 {
734 ok(0, "IDxDiagContainer::EnumChildContainerNames unexpectedly returned 0x%08lx\n", hr);
735 break;
736 }
737 }
738
739cleanup:
742}
743
744static void test_container_properties(IDxDiagContainer *container, const struct property_test *property_tests, size_t len)
745{
746 HRESULT hr;
747
748 /* Check that the container has no properties if there are no properties to examine. */
749 if (len == 0)
750 {
751 DWORD prop_count;
752
754 ok(hr == S_OK, "Expected IDxDiagContainer::GetNumberOfProps to return S_OK, got 0x%08lx\n", hr);
755 if (hr == S_OK)
756 ok(prop_count == 0, "Expected container property count to be zero, got %lu\n", prop_count);
757 }
758 else
759 {
760 VARIANT var;
761 int i;
762
764
765 /* Examine the variant types of obtained property values. */
766 for (i = 0; i < len; i++)
767 {
768 hr = IDxDiagContainer_GetProp(container, property_tests[i].prop, &var);
769 ok(hr == S_OK, "[%d] Expected IDxDiagContainer::GetProp to return S_OK for %s, got 0x%08lx\n",
770 i, wine_dbgstr_w(property_tests[i].prop), hr);
771
772 if (hr == S_OK)
773 {
774 ok(V_VT(&var) == property_tests[i].vt,
775 "[%d] Expected variant type %d, got %d\n", i, property_tests[i].vt, V_VT(&var));
776 trace("%s = %s\n", wine_dbgstr_w(property_tests[i].prop), debugstr_variant(&var));
778 }
779 }
780 }
781}
782
783static void test_DxDiag_SystemInfo(void)
784{
785 static const struct property_test property_tests[] =
786 {
787 {L"dwOSMajorVersion", VT_UI4},
788 {L"dwOSMinorVersion", VT_UI4},
789 {L"dwOSBuildNumber", VT_UI4},
790 {L"dwOSPlatformID", VT_UI4},
791 {L"dwDirectXVersionMajor", VT_UI4},
792 {L"dwDirectXVersionMinor", VT_UI4},
793 {L"szDirectXVersionLetter", VT_BSTR},
794 {L"bDebug", VT_BOOL},
795 {L"bIsD3DDebugRuntime", VT_BOOL},
796 {L"bNECPC98", VT_BOOL},
797 {L"ullPhysicalMemory", VT_BSTR},
798 {L"ullUsedPageFile", VT_BSTR},
799 {L"ullAvailPageFile", VT_BSTR},
800 {L"szWindowsDir", VT_BSTR},
801 {L"szCSDVersion", VT_BSTR},
802 {L"szDirectXVersionEnglish", VT_BSTR},
803 {L"szDirectXVersionLongEnglish", VT_BSTR},
804 {L"bNetMeetingRunning", VT_BOOL},
805 {L"szMachineNameLocalized", VT_BSTR},
806 {L"szMachineNameEnglish", VT_BSTR},
807 {L"szLanguagesLocalized", VT_BSTR},
808 {L"szLanguagesEnglish", VT_BSTR},
809 {L"szTimeLocalized", VT_BSTR},
810 {L"szTimeEnglish", VT_BSTR},
811 {L"szPhysicalMemoryEnglish", VT_BSTR},
812 {L"szPageFileLocalized", VT_BSTR},
813 {L"szPageFileEnglish", VT_BSTR},
814 {L"szOSLocalized", VT_BSTR},
815 {L"szOSExLocalized", VT_BSTR},
816 {L"szOSExLongLocalized", VT_BSTR},
817 {L"szOSEnglish", VT_BSTR},
818 {L"szOSExEnglish", VT_BSTR},
819 {L"szOSExLongEnglish", VT_BSTR},
820 {L"szProcessorEnglish", VT_BSTR},
821 };
822
823 IDxDiagContainer *container, *container2;
824 HRESULT hr;
825
827 {
828 skip("Unable to create the root IDxDiagContainer\n");
829 return;
830 }
831
832 hr = IDxDiagContainer_GetChildContainer(pddc, L"", &container2);
833 ok(hr == E_INVALIDARG, "Expected IDxDiagContainer::GetChildContainer to return E_INVALIDARG, got 0x%08lx\n", hr);
834
835 hr = IDxDiagContainer_GetChildContainer(pddc, L"DxDiag_SystemInfo", &container);
836 ok(hr == S_OK, "Expected IDxDiagContainer::GetChildContainer to return S_OK, got 0x%08lx\n", hr);
837
838 if (hr == S_OK)
839 {
840 trace("Testing container DxDiag_SystemInfo\n");
841 test_container_properties(container, property_tests, ARRAY_SIZE(property_tests));
842
843 container2 = NULL;
845 ok(hr == S_OK, "Expected IDxDiagContainer::GetChildContainer to return S_OK, got 0x%08lx\n", hr);
846 ok(container2 != NULL, "Expected container2 != NULL\n");
847 ok(container2 != container, "Expected container != container2\n");
848
849 IDxDiagContainer_Release(container2);
851 }
852
855}
856
858{
859 static const struct property_test property_tests[] =
860 {
861 {L"szDescription", VT_BSTR},
862 {L"szDeviceName", VT_BSTR},
863 {L"szKeyDeviceID", VT_BSTR},
864 {L"szKeyDeviceKey", VT_BSTR},
865 {L"szVendorId", VT_BSTR},
866 {L"szDeviceId", VT_BSTR},
867 {L"szDeviceIdentifier", VT_BSTR},
868 {L"dwWidth", VT_UI4},
869 {L"dwHeight", VT_UI4},
870 {L"dwBpp", VT_UI4},
871 {L"szDisplayMemoryLocalized", VT_BSTR},
872 {L"szDisplayMemoryEnglish", VT_BSTR},
873 {L"szDriverName", VT_BSTR},
874 {L"szDriverVersion", VT_BSTR},
875 {L"szSubSysId", VT_BSTR},
876 {L"szRevisionId", VT_BSTR},
877 {L"dwRefreshRate", VT_UI4},
878 {L"szManufacturer", VT_BSTR},
879 {L"b3DAccelerationExists", VT_BOOL},
880 {L"b3DAccelerationEnabled", VT_BOOL},
881 {L"bAGPEnabled", VT_BOOL},
882 {L"bAGPExistenceValid", VT_BOOL},
883 {L"bAGPExists", VT_BOOL},
884 {L"bDDAccelerationEnabled", VT_BOOL},
885 {L"iAdapter", VT_UI4},
886 };
887
888 IDxDiagContainer *display_cont = NULL;
889 DWORD count, i;
890 HRESULT hr;
891
893 {
894 skip("Unable to create the root IDxDiagContainer\n");
895 return;
896 }
897
898 hr = IDxDiagContainer_GetChildContainer(pddc, L"DxDiag_DisplayDevices", &display_cont);
899 ok(hr == S_OK, "Expected IDxDiagContainer::GetChildContainer to return S_OK, got 0x%08lx\n", hr);
900
901 if (hr != S_OK)
902 goto cleanup;
903
905 ok(hr == S_OK, "Expected IDxDiagContainer::GetNumberOfProps to return S_OK, got 0x%08lx\n", hr);
906 if (hr == S_OK)
907 ok(count == 0, "Expected count to be 0, got %lu\n", count);
908
910 ok(hr == S_OK, "Expected IDxDiagContainer::GetNumberOfChildContainers to return S_OK, got 0x%08lx\n", hr);
911
912 if (hr != S_OK)
913 goto cleanup;
914
915 for (i = 0; i < count; i++)
916 {
917 WCHAR child_container[256];
918 IDxDiagContainer *child;
919
920 hr = IDxDiagContainer_EnumChildContainerNames(display_cont, i, child_container, ARRAY_SIZE(child_container));
921 ok(hr == S_OK, "Expected IDxDiagContainer::EnumChildContainerNames to return S_OK, got 0x%08lx\n", hr);
922
923 hr = IDxDiagContainer_GetChildContainer(display_cont, child_container, &child);
924 ok(hr == S_OK, "Expected IDxDiagContainer::GetChildContainer to return S_OK, got 0x%08lx\n", hr);
925
926 if (hr == S_OK)
927 {
928 trace("Testing container %s\n", wine_dbgstr_w(child_container));
929 test_container_properties(child, property_tests, ARRAY_SIZE(property_tests));
930 }
932 }
933
934cleanup:
935 if (display_cont) IDxDiagContainer_Release(display_cont);
938}
939
941{
942 static const struct property_test property_tests[] =
943 {
944 {L"szDescription", VT_BSTR},
945 {L"szGuidDeviceID", VT_BSTR},
946 {L"szDriverName", VT_BSTR},
947 {L"szDriverPath", VT_BSTR},
948 {L"szHardwareID", VT_BSTR},
949 };
950
951 IDxDiagContainer *sound_cont = NULL;
952 DWORD count, i;
953 HRESULT hr;
954
956 {
957 skip("Unable to create the root IDxDiagContainer\n");
958 return;
959 }
960
961 hr = IDxDiagContainer_GetChildContainer(pddc, L"DxDiag_DirectSound.DxDiag_SoundDevices", &sound_cont);
962 ok(hr == S_OK, "Expected IDxDiagContainer::GetChildContainer to return S_OK, got 0x%08lx\n", hr);
963
965 ok(hr == S_OK, "Expected IDxDiagContainer::GetNumberOfProps to return S_OK, got 0x%08lx\n", hr);
966 ok(count == 0, "Expected count to be 0, got %lu\n", count);
967
969 ok(hr == S_OK, "Expected IDxDiagContainer::GetNumberOfChildContainers to return S_OK, got 0x%08lx\n", hr);
970
971 for (i = 0; i < count; i++)
972 {
973 IDxDiagContainer *child, *child2;
974 WCHAR child_container[256];
975
976 hr = IDxDiagContainer_EnumChildContainerNames(sound_cont, i, child_container, ARRAY_SIZE(child_container));
977 ok(hr == S_OK, "Expected IDxDiagContainer::EnumChildContainerNames to return S_OK, got 0x%08lx\n", hr);
978
979 hr = IDxDiagContainer_GetChildContainer(sound_cont, child_container, &child);
980 ok(hr == S_OK, "Expected IDxDiagContainer::GetChildContainer to return S_OK, got 0x%08lx\n", hr);
981
982 trace("Testing container %s\n", wine_dbgstr_w(child_container));
983 test_container_properties(child, property_tests, ARRAY_SIZE(property_tests));
984
985 child2 = NULL;
987 ok(hr == S_OK, "Expected IDxDiagContainer::GetChildContainer to return S_OK, got 0x%08lx\n", hr);
988 ok(child2 != NULL, "Expected child2 != NULL\n");
989 ok(child2 != child, "Expected child != child2\n");
990
993 }
994
995 IDxDiagContainer_Release(sound_cont);
998}
999
1001{
1002 static const struct property_test property_tests[] =
1003 {
1004 {L"szDescription", VT_BSTR},
1005 {L"szGuidDeviceID", VT_BSTR},
1006 {L"szDriverName", VT_BSTR},
1007 {L"szDriverPath", VT_BSTR},
1008 };
1009
1010 IDxDiagContainer *sound_cont = NULL;
1011 DWORD count, i;
1012 HRESULT hr;
1013
1015 {
1016 skip("Unable to create the root IDxDiagContainer\n");
1017 return;
1018 }
1019
1020 hr = IDxDiagContainer_GetChildContainer(pddc, L"DxDiag_DirectSound.DxDiag_SoundCaptureDevices", &sound_cont);
1021 ok(hr == S_OK, "Expected IDxDiagContainer::GetChildContainer to return S_OK, got 0x%08lx\n", hr);
1022
1024 ok(hr == S_OK, "Expected IDxDiagContainer::GetNumberOfProps to return S_OK, got 0x%08lx\n", hr);
1025 ok(count == 0, "Expected count to be 0, got %lu\n", count);
1026
1028 ok(hr == S_OK, "Expected IDxDiagContainer::GetNumberOfChildContainers to return S_OK, got 0x%08lx\n", hr);
1029
1030 for (i = 0; i < count; i++)
1031 {
1032 WCHAR child_container[256];
1033 IDxDiagContainer *child;
1034
1035 hr = IDxDiagContainer_EnumChildContainerNames(sound_cont, i, child_container, ARRAY_SIZE(child_container));
1036 ok(hr == S_OK, "Expected IDxDiagContainer::EnumChildContainerNames to return S_OK, got 0x%08lx\n", hr);
1037
1038 hr = IDxDiagContainer_GetChildContainer(sound_cont, child_container, &child);
1039 ok(hr == S_OK, "Expected IDxDiagContainer::GetChildContainer to return S_OK, got 0x%08lx\n", hr);
1040
1041 trace("Testing container %s\n", wine_dbgstr_w(child_container));
1042 test_container_properties(child, property_tests, ARRAY_SIZE(property_tests));
1043
1045 }
1046
1047 IDxDiagContainer_Release(sound_cont);
1050}
1051
1053{
1061 test_GetProp();
1062
1069}
#define expect(EXPECTED, GOT)
Definition: SystemMenu.c:483
static struct sockaddr_in sa
Definition: adnsresfilter.c:69
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define START_TEST(x)
Definition: atltest.h:75
#define index(s, c)
Definition: various.h:29
#define ARRAY_SIZE(A)
Definition: main.h:20
#define E_INVALIDARG
Definition: ddrawi.h:101
HRESULT hr
Definition: delayimp.cpp:582
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: combase.c:2842
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, IUnknown *outer, DWORD cls_context, REFIID riid, void **obj)
Definition: combase.c:1685
#define CP_ACP
Definition: compat.h:109
unsigned short VARTYPE
Definition: compat.h:2254
#define WideCharToMultiByte
Definition: compat.h:111
#define MultiByteToWideChar
Definition: compat.h:110
@ VT_BSTR
Definition: compat.h:2303
@ VT_UNKNOWN
Definition: compat.h:2308
@ VT_ARRAY
Definition: compat.h:2341
@ VT_BOOL
Definition: compat.h:2306
@ VT_UI4
Definition: compat.h:2313
@ VT_EMPTY
Definition: compat.h:2295
@ VT_UI1
Definition: compat.h:2311
static void cleanup(void)
Definition: main.c:1335
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4152
static REFPROPVARIANT PROPVAR_CHANGE_FLAGS VARTYPE vt
Definition: suminfo.c:90
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2807
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:531
HRESULT WINAPI SafeArrayUnlock(SAFEARRAY *psa)
Definition: safearray.c:831
HRESULT WINAPI SafeArrayLock(SAFEARRAY *psa)
Definition: safearray.c:795
HRESULT WINAPI SafeArrayDestroy(SAFEARRAY *psa)
Definition: safearray.c:1347
SAFEARRAY *WINAPI SafeArrayCreate(VARTYPE vt, UINT cDims, SAFEARRAYBOUND *rgsabound)
Definition: safearray.c:600
static const char * debugstr_variant(const VARIANT *var)
Definition: dom.c:505
#define L(x)
Definition: resources.c:13
#define IDxDiagContainer_Release(p)
Definition: dxdiag.h:66
#define IDxDiagProvider_Release(p)
Definition: dxdiag.h:61
#define IDxDiagContainer_GetProp(p, a, b)
Definition: dxdiag.h:72
#define IDxDiagContainer_GetChildContainer(p, a, b)
Definition: dxdiag.h:69
#define IDxDiagContainer_GetNumberOfProps(p, a)
Definition: dxdiag.h:70
#define IDxDiagContainer_AddRef(p)
Definition: dxdiag.h:65
#define IDxDiagProvider_GetRootContainer(p, a)
Definition: dxdiag.h:63
#define DXDIAG_DX9_SDK_VERSION
Definition: dxdiag.h:6
#define IDxDiagContainer_GetNumberOfChildContainers(p, a)
Definition: dxdiag.h:67
#define IDxDiagProvider_Initialize(p, a, b)
Definition: dxdiag.h:62
#define DXDIAG_E_INSUFFICIENT_BUFFER
Definition: dxdiag.h:57
#define IDxDiagContainer_EnumChildContainerNames(p, a, b, c)
Definition: dxdiag.h:68
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint index
Definition: glext.h:6031
GLenum const GLfloat * params
Definition: glext.h:5645
GLenum GLsizei len
Definition: glext.h:6722
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
#define wine_dbgstr_w
Definition: kernel32.h:34
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static PVOID ptr
Definition: dispmode.c:27
#define sprintf
Definition: sprintf.c:45
const char * var
Definition: shader.c:5879
static void test_DxDiag_SoundDevices(void)
Definition: container.c:940
static void test_DxDiag_SystemInfo(void)
Definition: container.c:783
static void test_dot_parsing(void)
Definition: container.c:299
static void test_root_children(void)
Definition: container.c:678
static void test_GetChildContainer(void)
Definition: container.c:229
static void test_container_properties(IDxDiagContainer *container, const struct property_test *property_tests, size_t len)
Definition: container.c:744
static void test_GetProp(void)
Definition: container.c:536
static IDxDiagContainer * pddc
Definition: container.c:35
static void test_GetNumberOfChildContainers(void)
Definition: container.c:62
static IDxDiagProvider * pddp
Definition: container.c:34
static void test_EnumChildContainerNames(void)
Definition: container.c:110
static void test_DxDiag_SoundCaptureDevices(void)
Definition: container.c:1000
static BOOL create_root_IDxDiagContainer(void)
Definition: container.c:37
static void test_GetNumberOfProps(void)
Definition: container.c:87
static void test_DxDiag_DisplayDevices(void)
Definition: container.c:857
static void test_EnumPropNames(void)
Definition: container.c:396
static const WCHAR testW[]
Definition: typelib.c:1450
static HWND child
Definition: cursoricon.c:298
#define V_ARRAY(A)
Definition: oleauto.h:222
#define V_UNKNOWN(A)
Definition: oleauto.h:281
#define V_VT(A)
Definition: oleauto.h:211
short WCHAR
Definition: pedump.c:58
#define IDxDiagContainer_EnumPropNames(p, a, b, c)
Definition: dxdiag.h:101
static calc_node_t temp
Definition: rpn_ieee.c:38
const WCHAR * prop
Definition: container.c:30
VARTYPE vt
Definition: container.c:31
Definition: send.c:48
uint32_t ULONG
Definition: typedefs.h:59
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
Definition: variant.c:626
void WINAPI VariantInit(VARIANTARG *pVarg)
Definition: variant.c:547