Release 1.3.7.
[wine/gsoc-2012-control.git] / dlls / dxdiagn / tests / container.c
blob6787c704d846b732cd0c690b89f12bf6bf704e04
1 /*
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
21 #define COBJMACROS
23 #include <stdio.h>
24 #include "dxdiag.h"
25 #include "oleauto.h"
26 #include "wine/test.h"
28 static IDxDiagProvider *pddp;
29 static IDxDiagContainer *pddc;
31 static BOOL create_root_IDxDiagContainer(void)
33 HRESULT hr;
34 DXDIAG_INIT_PARAMS params;
36 hr = CoCreateInstance(&CLSID_DxDiagProvider, NULL, CLSCTX_INPROC_SERVER,
37 &IID_IDxDiagProvider, (LPVOID*)&pddp);
38 if (SUCCEEDED(hr))
40 params.dwSize = sizeof(params);
41 params.dwDxDiagHeaderVersion = DXDIAG_DX9_SDK_VERSION;
42 params.bAllowWHQLChecks = FALSE;
43 params.pReserved = NULL;
44 hr = IDxDiagProvider_Initialize(pddp, &params);
45 if (SUCCEEDED(hr))
47 hr = IDxDiagProvider_GetRootContainer(pddp, &pddc);
48 if (SUCCEEDED(hr))
49 return TRUE;
51 IDxDiagProvider_Release(pddp);
53 return FALSE;
56 static void test_GetNumberOfChildContainers(void)
58 HRESULT hr;
59 DWORD count;
61 if (!create_root_IDxDiagContainer())
63 skip("Unable to create the root IDxDiagContainer\n");
64 return;
67 hr = IDxDiagContainer_GetNumberOfChildContainers(pddc, NULL);
68 ok(hr == E_INVALIDARG,
69 "Expected IDxDiagContainer::GetNumberOfChildContainers to return E_INVALIDARG, got 0x%08x\n", hr);
71 hr = IDxDiagContainer_GetNumberOfChildContainers(pddc, &count);
72 ok(hr == S_OK,
73 "Expected IDxDiagContainer::GetNumberOfChildContainers to return S_OK, got 0x%08x\n", hr);
74 if (hr == S_OK)
75 ok(count != 0, "Expected the number of child containers for the root container to be non-zero\n");
77 IDxDiagContainer_Release(pddc);
78 IDxDiagProvider_Release(pddp);
81 static void test_GetNumberOfProps(void)
83 HRESULT hr;
84 DWORD count;
86 if (!create_root_IDxDiagContainer())
88 skip("Unable to create the root IDxDiagContainer\n");
89 return;
92 hr = IDxDiagContainer_GetNumberOfProps(pddc, NULL);
93 ok(hr == E_INVALIDARG, "Expected IDxDiagContainer::GetNumberOfProps to return E_INVALIDARG, got 0x%08x\n", hr);
95 hr = IDxDiagContainer_GetNumberOfProps(pddc, &count);
96 ok(hr == S_OK, "Expected IDxDiagContainer::GetNumberOfProps to return S_OK, got 0x%08x\n", hr);
97 if (hr == S_OK)
98 ok(count == 0, "Expected the number of properties for the root container to be zero\n");
100 IDxDiagContainer_Release(pddc);
101 IDxDiagProvider_Release(pddp);
104 static void test_EnumChildContainerNames(void)
106 HRESULT hr;
107 WCHAR container[256];
108 DWORD maxcount, index;
109 static const WCHAR testW[] = {'t','e','s','t',0};
110 static const WCHAR zerotestW[] = {0,'e','s','t',0};
112 if (!create_root_IDxDiagContainer())
114 skip("Unable to create the root IDxDiagContainer\n");
115 return;
118 /* Test various combinations of invalid parameters. */
119 hr = IDxDiagContainer_EnumChildContainerNames(pddc, 0, NULL, 0);
120 ok(hr == E_INVALIDARG,
121 "Expected IDxDiagContainer::EnumChildContainerNames to return E_INVALIDARG, got 0x%08x\n", hr);
123 hr = IDxDiagContainer_EnumChildContainerNames(pddc, 0, NULL, sizeof(container)/sizeof(WCHAR));
124 ok(hr == E_INVALIDARG,
125 "Expected IDxDiagContainer::EnumChildContainerNames to return E_INVALIDARG, got 0x%08x\n", hr);
127 /* Test the conditions in which the output buffer can be modified. */
128 memcpy(container, testW, sizeof(testW));
129 hr = IDxDiagContainer_EnumChildContainerNames(pddc, 0, container, 0);
130 ok(hr == E_INVALIDARG,
131 "Expected IDxDiagContainer::EnumChildContainerNames to return E_INVALIDARG, got 0x%08x\n", hr);
132 ok(!memcmp(container, testW, sizeof(testW)),
133 "Expected the container buffer to be untouched, got %s\n", wine_dbgstr_w(container));
135 memcpy(container, testW, sizeof(testW));
136 hr = IDxDiagContainer_EnumChildContainerNames(pddc, ~0, container, 0);
137 ok(hr == E_INVALIDARG,
138 "Expected IDxDiagContainer::EnumChildContainerNames to return E_INVALIDARG, got 0x%08x\n", hr);
139 ok(!memcmp(container, testW, sizeof(testW)),
140 "Expected the container buffer to be untouched, got %s\n", wine_dbgstr_w(container));
142 memcpy(container, testW, sizeof(testW));
143 hr = IDxDiagContainer_EnumChildContainerNames(pddc, ~0, container, sizeof(container)/sizeof(WCHAR));
144 ok(hr == E_INVALIDARG,
145 "Expected IDxDiagContainer::EnumChildContainerNames to return E_INVALIDARG, got 0x%08x\n", hr);
146 ok(!memcmp(container, zerotestW, sizeof(zerotestW)),
147 "Expected the container buffer string to be empty, got %s\n", wine_dbgstr_w(container));
149 hr = IDxDiagContainer_GetNumberOfChildContainers(pddc, &maxcount);
150 ok(hr == S_OK, "Expected IDxDiagContainer::GetNumberOfChildContainers to return S_OK, got 0x%08x\n", hr);
151 if (FAILED(hr))
153 skip("IDxDiagContainer::GetNumberOfChildContainers failed\n");
154 goto cleanup;
157 trace("Starting child container enumeration of the root container:\n");
159 /* We should be able to enumerate as many child containers as the value
160 * that IDxDiagContainer::GetNumberOfChildContainers returns. */
161 for (index = 0; index <= maxcount; index++)
163 /* A buffer size of 1 is unlikely to be valid, as only a null terminator
164 * could be stored, and it is unlikely that a container name could be empty. */
165 DWORD buffersize = 1;
166 memcpy(container, testW, sizeof(testW));
167 hr = IDxDiagContainer_EnumChildContainerNames(pddc, index, container, buffersize);
168 if (hr == E_INVALIDARG)
170 /* We should get here when index is one more than the maximum index value. */
171 ok(maxcount == index,
172 "Expected IDxDiagContainer::EnumChildContainerNames to return E_INVALIDARG "
173 "on the last index %d, got 0x%08x\n", index, hr);
174 ok(container[0] == '\0',
175 "Expected the container buffer string to be empty, got %s\n", wine_dbgstr_w(container));
176 break;
178 else if (hr == DXDIAG_E_INSUFFICIENT_BUFFER)
180 WCHAR temp[256];
182 ok(container[0] == '\0',
183 "Expected the container buffer string to be empty, got %s\n", wine_dbgstr_w(container));
185 /* Get the container name to compare against. */
186 hr = IDxDiagContainer_EnumChildContainerNames(pddc, index, temp, sizeof(temp)/sizeof(WCHAR));
187 ok(hr == S_OK,
188 "Expected IDxDiagContainer::EnumChildContainerNames to return S_OK, got 0x%08x\n", hr);
190 /* Show that the DirectX SDK's stipulation that the buffer be at
191 * least 256 characters long is a mere suggestion, and smaller sizes
192 * can be acceptable also. IDxDiagContainer::EnumChildContainerNames
193 * doesn't provide a way of getting the exact size required, so the
194 * buffersize value will be iterated to at most 256 characters. */
195 for (buffersize = 2; buffersize <= 256; buffersize++)
197 memcpy(container, testW, sizeof(testW));
198 hr = IDxDiagContainer_EnumChildContainerNames(pddc, index, container, buffersize);
199 if (hr != DXDIAG_E_INSUFFICIENT_BUFFER)
200 break;
202 ok(!memcmp(temp, container, sizeof(WCHAR)*(buffersize - 1)),
203 "Expected truncated container name string, got %s\n", wine_dbgstr_w(container));
206 ok(hr == S_OK,
207 "Expected IDxDiagContainer::EnumChildContainerNames to return S_OK, "
208 "got hr = 0x%08x, buffersize = %d\n", hr, buffersize);
209 if (hr == S_OK)
210 trace("pddc[%d] = %s, length = %d\n", index, wine_dbgstr_w(container), buffersize);
212 else
214 ok(0, "IDxDiagContainer::EnumChildContainerNames unexpectedly returned 0x%08x\n", hr);
215 break;
219 cleanup:
220 IDxDiagContainer_Release(pddc);
221 IDxDiagProvider_Release(pddp);
224 static void test_GetChildContainer(void)
226 HRESULT hr;
227 WCHAR container[256] = {0};
228 IDxDiagContainer *child;
230 if (!create_root_IDxDiagContainer())
232 skip("Unable to create the root IDxDiagContainer\n");
233 return;
236 /* Test various combinations of invalid parameters. */
237 hr = IDxDiagContainer_GetChildContainer(pddc, NULL, NULL);
238 ok(hr == E_INVALIDARG,
239 "Expected IDxDiagContainer::GetChildContainer to return E_INVALIDARG, got 0x%08x\n", hr);
241 child = (void*)0xdeadbeef;
242 hr = IDxDiagContainer_GetChildContainer(pddc, NULL, &child);
243 ok(hr == E_INVALIDARG,
244 "Expected IDxDiagContainer::GetChildContainer to return E_INVALIDARG, got 0x%08x\n", hr);
245 ok(child == (void*)0xdeadbeef, "Expected output pointer to be unchanged, got %p\n", child);
247 hr = IDxDiagContainer_GetChildContainer(pddc, container, NULL);
248 ok(hr == E_INVALIDARG,
249 "Expected IDxDiagContainer::GetChildContainer to return E_INVALIDARG, got 0x%08x\n", hr);
251 child = (void*)0xdeadbeef;
252 hr = IDxDiagContainer_GetChildContainer(pddc, container, &child);
253 ok(hr == E_INVALIDARG,
254 "Expected IDxDiagContainer::GetChildContainer to return E_INVALIDARG, got 0x%08x\n", hr);
255 ok(child == NULL, "Expected output pointer to be NULL, got %p\n", child);
257 /* Get the name of a suitable child container. */
258 hr = IDxDiagContainer_EnumChildContainerNames(pddc, 0, container, sizeof(container)/sizeof(WCHAR));
259 ok(hr == S_OK,
260 "Expected IDxDiagContainer::EnumChildContainerNames to return S_OK, got 0x%08x\n", hr);
261 if (FAILED(hr))
263 skip("IDxDiagContainer::EnumChildContainerNames failed\n");
264 goto cleanup;
267 child = (void*)0xdeadbeef;
268 hr = IDxDiagContainer_GetChildContainer(pddc, container, &child);
269 ok(hr == S_OK,
270 "Expected IDxDiagContainer::GetChildContainer to return S_OK, got 0x%08x\n", hr);
271 ok(child != NULL && child != (void*)0xdeadbeef, "Expected a valid output pointer, got %p\n", child);
273 if (SUCCEEDED(hr))
275 IDxDiagContainer *ptr;
277 /* Show that IDxDiagContainer::GetChildContainer returns a different pointer
278 * for multiple calls for the same container name. */
279 hr = IDxDiagContainer_GetChildContainer(pddc, container, &ptr);
280 ok(hr == S_OK,
281 "Expected IDxDiagContainer::GetChildContainer to return S_OK, got 0x%08x\n", hr);
282 if (SUCCEEDED(hr))
283 todo_wine ok(ptr != child, "Expected the two pointers (%p vs. %p) to be unequal\n", child, ptr);
285 IDxDiagContainer_Release(ptr);
286 IDxDiagContainer_Release(child);
289 cleanup:
290 IDxDiagContainer_Release(pddc);
291 IDxDiagProvider_Release(pddp);
294 static void test_dot_parsing(void)
296 HRESULT hr;
297 WCHAR containerbufW[256] = {0}, childbufW[256] = {0};
298 DWORD count, index;
299 size_t i;
300 static const struct
302 const char *format;
303 const HRESULT expect;
304 } test_strings[] = {
305 { "%s.%s", S_OK },
306 { "%s.%s.", S_OK },
307 { ".%s.%s", E_INVALIDARG },
308 { "%s.%s..", E_INVALIDARG },
309 { ".%s.%s.", E_INVALIDARG },
310 { "..%s.%s", E_INVALIDARG },
313 if (!create_root_IDxDiagContainer())
315 skip("Unable to create the root IDxDiagContainer\n");
316 return;
319 /* Find a container with a child container of its own. */
320 hr = IDxDiagContainer_GetNumberOfChildContainers(pddc, &count);
321 ok(hr == S_OK, "Expected IDxDiagContainer::GetNumberOfChildContainers to return S_OK, got 0x%08x\n", hr);
322 if (FAILED(hr))
324 skip("IDxDiagContainer::GetNumberOfChildContainers failed\n");
325 goto cleanup;
328 for (index = 0; index < count; index++)
330 IDxDiagContainer *child;
332 hr = IDxDiagContainer_EnumChildContainerNames(pddc, index, containerbufW, sizeof(containerbufW)/sizeof(WCHAR));
333 ok(hr == S_OK, "Expected IDxDiagContainer_EnumChildContainerNames to return S_OK, got 0x%08x\n", hr);
334 if (FAILED(hr))
336 skip("IDxDiagContainer::EnumChildContainerNames failed\n");
337 goto cleanup;
340 hr = IDxDiagContainer_GetChildContainer(pddc, containerbufW, &child);
341 ok(hr == S_OK, "Expected IDxDiagContainer::GetChildContainer to return S_OK, got 0x%08x\n", hr);
343 if (SUCCEEDED(hr))
345 hr = IDxDiagContainer_EnumChildContainerNames(child, 0, childbufW, sizeof(childbufW)/sizeof(WCHAR));
346 ok(hr == S_OK || hr == E_INVALIDARG,
347 "Expected IDxDiagContainer::EnumChildContainerNames to return S_OK or E_INVALIDARG, got 0x%08x\n", hr);
348 IDxDiagContainer_Release(child);
350 if (SUCCEEDED(hr))
351 break;
355 if (!*containerbufW || !*childbufW)
357 skip("Unable to find a suitable container\n");
358 goto cleanup;
361 trace("Testing IDxDiagContainer::GetChildContainer dot parsing with container %s and child container %s.\n",
362 wine_dbgstr_w(containerbufW), wine_dbgstr_w(childbufW));
364 for (i = 0; i < sizeof(test_strings)/sizeof(test_strings[0]); i++)
366 IDxDiagContainer *child;
367 char containerbufA[256];
368 char childbufA[256];
369 char dotbufferA[255 + 255 + 3 + 1];
370 WCHAR dotbufferW[255 + 255 + 3 + 1]; /* containerbuf + childbuf + dots + null terminator */
372 WideCharToMultiByte(CP_ACP, 0, containerbufW, -1, containerbufA, sizeof(containerbufA), NULL, NULL);
373 WideCharToMultiByte(CP_ACP, 0, childbufW, -1, childbufA, sizeof(childbufA), NULL, NULL);
374 sprintf(dotbufferA, test_strings[i].format, containerbufA, childbufA);
375 MultiByteToWideChar(CP_ACP, 0, dotbufferA, -1, dotbufferW, sizeof(dotbufferW)/sizeof(WCHAR));
377 trace("Trying container name %s\n", wine_dbgstr_w(dotbufferW));
378 hr = IDxDiagContainer_GetChildContainer(pddc, dotbufferW, &child);
379 ok(hr == test_strings[i].expect,
380 "Expected IDxDiagContainer::GetChildContainer to return 0x%08x for %s, got 0x%08x\n",
381 test_strings[i].expect, wine_dbgstr_w(dotbufferW), hr);
382 if (SUCCEEDED(hr))
383 IDxDiagContainer_Release(child);
386 cleanup:
387 IDxDiagContainer_Release(pddc);
388 IDxDiagProvider_Release(pddp);
391 static void test_EnumPropNames(void)
393 HRESULT hr;
394 WCHAR container[256], property[256];
395 IDxDiagContainer *child = NULL;
396 DWORD count, index, propcount;
397 static const WCHAR testW[] = {'t','e','s','t',0};
399 if (!create_root_IDxDiagContainer())
401 skip("Unable to create the root IDxDiagContainer\n");
402 return;
405 /* Find a container with a non-zero number of properties. */
406 hr = IDxDiagContainer_GetNumberOfChildContainers(pddc, &count);
407 ok(hr == S_OK, "Expected IDxDiagContainer::GetNumberOfChildContainers to return S_OK, got 0x%08x\n", hr);
408 if (FAILED(hr))
410 skip("IDxDiagContainer::GetNumberOfChildContainers failed\n");
411 goto cleanup;
414 for (index = 0; index < count; index++)
416 hr = IDxDiagContainer_EnumChildContainerNames(pddc, index, container, sizeof(container)/sizeof(WCHAR));
417 ok(hr == S_OK, "Expected IDxDiagContainer_EnumChildContainerNames to return S_OK, got 0x%08x\n", hr);
418 if (FAILED(hr))
420 skip("IDxDiagContainer::EnumChildContainerNames failed\n");
421 goto cleanup;
424 hr = IDxDiagContainer_GetChildContainer(pddc, container, &child);
425 ok(hr == S_OK, "Expected IDxDiagContainer::GetChildContainer to return S_OK, got 0x%08x\n", hr);
427 if (SUCCEEDED(hr))
429 hr = IDxDiagContainer_GetNumberOfProps(child, &propcount);
430 ok(hr == S_OK, "Expected IDxDiagContainer::GetNumberOfProps to return S_OK, got 0x%08x\n", hr);
432 if (!propcount)
434 IDxDiagContainer_Release(child);
435 child = NULL;
437 else
438 break;
442 if (!child)
444 skip("Unable to find a container with non-zero property count\n");
445 goto cleanup;
448 hr = IDxDiagContainer_EnumPropNames(child, ~0, NULL, 0);
449 ok(hr == E_INVALIDARG, "Expected IDxDiagContainer::EnumPropNames to return E_INVALIDARG, got 0x%08x\n", hr);
451 memcpy(property, testW, sizeof(testW));
452 hr = IDxDiagContainer_EnumPropNames(child, ~0, property, 0);
453 ok(hr == E_INVALIDARG, "Expected IDxDiagContainer::EnumPropNames to return E_INVALIDARG, got 0x%08x\n", hr);
454 ok(!memcmp(property, testW, sizeof(testW)),
455 "Expected the property buffer to be unchanged, got %s\n", wine_dbgstr_w(property));
457 memcpy(property, testW, sizeof(testW));
458 hr = IDxDiagContainer_EnumPropNames(child, ~0, property, sizeof(property)/sizeof(WCHAR));
459 ok(hr == E_INVALIDARG, "Expected IDxDiagContainer::EnumPropNames to return E_INVALIDARG, got 0x%08x\n", hr);
460 ok(!memcmp(property, testW, sizeof(testW)),
461 "Expected the property buffer to be unchanged, got %s\n", wine_dbgstr_w(property));
463 trace("Starting property enumeration of the %s container:\n", wine_dbgstr_w(container));
465 /* We should be able to enumerate as many properties as the value that
466 * IDxDiagContainer::GetNumberOfProps returns. */
467 for (index = 0; index <= propcount; index++)
469 /* A buffer size of 1 is unlikely to be valid, as only a null terminator
470 * could be stored, and it is unlikely that a property name could be empty. */
471 DWORD buffersize = 1;
473 memcpy(property, testW, sizeof(testW));
474 hr = IDxDiagContainer_EnumPropNames(child, index, property, buffersize);
475 if (hr == E_INVALIDARG)
477 /* We should get here when index is one more than the maximum index value. */
478 ok(propcount == index,
479 "Expected IDxDiagContainer::EnumPropNames to return E_INVALIDARG "
480 "on the last index %d, got 0x%08x\n", index, hr);
481 ok(!memcmp(property, testW, sizeof(testW)),
482 "Expected the property buffer to be unchanged, got %s\n", wine_dbgstr_w(property));
483 break;
485 else if (hr == DXDIAG_E_INSUFFICIENT_BUFFER)
487 WCHAR temp[256];
489 ok(property[0] == '\0',
490 "Expected the property buffer string to be empty, got %s\n", wine_dbgstr_w(property));
491 hr = IDxDiagContainer_EnumPropNames(child, index, temp, sizeof(temp)/sizeof(WCHAR));
492 ok(hr == S_OK,
493 "Expected IDxDiagContainer::EnumPropNames to return S_OK, got 0x%08x\n", hr);
495 /* Show that the DirectX SDK's stipulation that the buffer be at
496 * least 256 characters long is a mere suggestion, and smaller sizes
497 * can be acceptable also. IDxDiagContainer::EnumPropNames doesn't
498 * provide a way of getting the exact size required, so the buffersize
499 * value will be iterated to at most 256 characters. */
500 for (buffersize = 2; buffersize <= 256; buffersize++)
502 memcpy(property, testW, sizeof(testW));
503 hr = IDxDiagContainer_EnumPropNames(child, index, property, buffersize);
504 if (hr != DXDIAG_E_INSUFFICIENT_BUFFER)
505 break;
507 ok(!memcmp(temp, property, sizeof(WCHAR)*(buffersize - 1)),
508 "Expected truncated property name string, got %s\n", wine_dbgstr_w(property));
511 ok(hr == S_OK,
512 "Expected IDxDiagContainer::EnumPropNames to return S_OK, "
513 "got hr = 0x%08x, buffersize = %d\n", hr, buffersize);
514 if (hr == S_OK)
515 trace("child[%d] = %s, length = %d\n", index, wine_dbgstr_w(property), buffersize);
517 else
519 ok(0, "IDxDiagContainer::EnumPropNames unexpectedly returned 0x%08x\n", hr);
520 break;
524 IDxDiagContainer_Release(child);
526 cleanup:
527 IDxDiagContainer_Release(pddc);
528 IDxDiagProvider_Release(pddp);
531 static void test_GetProp(void)
533 HRESULT hr;
534 WCHAR container[256], property[256];
535 IDxDiagContainer *child = NULL;
536 DWORD count, index;
537 VARIANT var;
538 SAFEARRAY *sa;
539 SAFEARRAYBOUND bound;
540 static const WCHAR emptyW[] = {0};
541 static const WCHAR testW[] = {'t','e','s','t',0};
543 if (!create_root_IDxDiagContainer())
545 skip("Unable to create the root IDxDiagContainer\n");
546 return;
549 /* Find a container with a property. */
550 hr = IDxDiagContainer_GetNumberOfChildContainers(pddc, &count);
551 ok(hr == S_OK, "Expected IDxDiagContainer::GetNumberOfChildContainers to return S_OK, got 0x%08x\n", hr);
552 if (FAILED(hr))
554 skip("IDxDiagContainer::GetNumberOfChildContainers failed\n");
555 goto cleanup;
558 for (index = 0; index < count; index++)
560 hr = IDxDiagContainer_EnumChildContainerNames(pddc, index, container, sizeof(container)/sizeof(WCHAR));
561 ok(hr == S_OK, "Expected IDxDiagContainer_EnumChildContainerNames to return S_OK, got 0x%08x\n", hr);
562 if (FAILED(hr))
564 skip("IDxDiagContainer::EnumChildContainerNames failed\n");
565 goto cleanup;
568 hr = IDxDiagContainer_GetChildContainer(pddc, container, &child);
569 ok(hr == S_OK, "Expected IDxDiagContainer::GetChildContainer to return S_OK, got 0x%08x\n", hr);
571 if (SUCCEEDED(hr))
573 hr = IDxDiagContainer_EnumPropNames(child, 0, property, sizeof(property)/sizeof(WCHAR));
574 ok(hr == S_OK || hr == E_INVALIDARG,
575 "Expected IDxDiagContainer::EnumPropNames to return S_OK or E_INVALIDARG, got 0x%08x\n", hr);
577 if (SUCCEEDED(hr))
578 break;
579 else
581 IDxDiagContainer_Release(child);
582 child = NULL;
587 if (!child)
589 skip("Unable to find a suitable container\n");
590 goto cleanup;
593 hr = IDxDiagContainer_GetProp(child, NULL, NULL);
594 ok(hr == E_INVALIDARG, "Expected IDxDiagContainer::GetProp to return E_INVALIDARG, got 0x%08x\n", hr);
596 V_VT(&var) = 0xdead;
597 hr = IDxDiagContainer_GetProp(child, NULL, &var);
598 ok(hr == E_INVALIDARG, "Expected IDxDiagContainer::GetProp to return E_INVALIDARG, got 0x%08x\n", hr);
599 ok(V_VT(&var) == 0xdead, "Expected the variant to be untouched, got %u\n", V_VT(&var));
601 hr = IDxDiagContainer_GetProp(child, emptyW, NULL);
602 ok(hr == E_INVALIDARG, "Expected IDxDiagContainer::GetProp to return E_INVALIDARG, got 0x%08x\n", hr);
604 V_VT(&var) = 0xdead;
605 hr = IDxDiagContainer_GetProp(child, emptyW, &var);
606 ok(hr == E_INVALIDARG, "Expected IDxDiagContainer::GetProp to return E_INVALIDARG, got 0x%08x\n", hr);
607 ok(V_VT(&var) == 0xdead, "Expected the variant to be untouched, got %u\n", V_VT(&var));
609 hr = IDxDiagContainer_GetProp(child, testW, NULL);
610 ok(hr == E_INVALIDARG, "Expected IDxDiagContainer::GetProp to return E_INVALIDARG, got 0x%08x\n", hr);
612 V_VT(&var) = 0xdead;
613 hr = IDxDiagContainer_GetProp(child, testW, &var);
614 ok(hr == E_INVALIDARG, "Expected IDxDiagContainer::GetProp to return E_INVALIDARG, got 0x%08x\n", hr);
615 ok(V_VT(&var) == 0xdead, "Expected the variant to be untouched, got %u\n", V_VT(&var));
617 VariantInit(&var);
618 hr = IDxDiagContainer_GetProp(child, property, &var);
619 ok(hr == S_OK, "Expected IDxDiagContainer::GetProp to return S_OK, got 0x%08x\n", hr);
620 ok(V_VT(&var) != VT_EMPTY, "Expected the variant to be modified, got %d\n", V_VT(&var));
622 /* Since the documentation for IDxDiagContainer::GetProp claims that the
623 * function reports return values from VariantCopy, try to exercise failure
624 * paths in handling the destination variant. */
626 /* Try an invalid variant type. */
627 V_VT(&var) = 0xdead;
628 hr = IDxDiagContainer_GetProp(child, property, &var);
629 ok(hr == S_OK, "Expected IDxDiagContainer::GetProp to return S_OK, got 0x%08x\n", hr);
630 ok(V_VT(&var) != 0xdead, "Expected the variant to be modified, got %d\n", V_VT(&var));
632 /* Try passing a variant with a locked SAFEARRAY. */
633 bound.cElements = 1;
634 bound.lLbound = 0;
635 sa = SafeArrayCreate(VT_UI1, 1, &bound);
636 ok(sa != NULL, "Expected SafeArrayCreate to return a valid pointer\n");
638 V_VT(&var) = (VT_ARRAY | VT_UI1);
639 V_ARRAY(&var) = sa;
641 hr = SafeArrayLock(sa);
642 ok(hr == S_OK, "Expected SafeArrayLock to return S_OK, got 0x%08x\n", hr);
644 hr = IDxDiagContainer_GetProp(child, property, &var);
645 ok(hr == S_OK, "Expected IDxDiagContainer::GetProp to return S_OK, got 0x%08x\n", hr);
646 ok(V_VT(&var) != (VT_ARRAY | VT_UI1), "Expected the variant to be modified\n");
648 hr = SafeArrayUnlock(sa);
649 ok(hr == S_OK, "Expected SafeArrayUnlock to return S_OK, got 0x%08x\n", hr);
650 hr = SafeArrayDestroy(sa);
651 ok(hr == S_OK, "Expected SafeArrayDestroy to return S_OK, got 0x%08x\n", hr);
652 IDxDiagContainer_Release(child);
654 cleanup:
655 IDxDiagContainer_Release(pddc);
656 IDxDiagProvider_Release(pddp);
659 START_TEST(container)
661 CoInitialize(NULL);
662 test_GetNumberOfChildContainers();
663 test_GetNumberOfProps();
664 test_EnumChildContainerNames();
665 test_GetChildContainer();
666 test_dot_parsing();
667 test_EnumPropNames();
668 test_GetProp();
669 CoUninitialize();