gphoto2.ds: Set supported groups.
[wine.git] / dlls / dxdiagn / tests / provider.c
blob69006f06408a973b38573361d3dbe2ac3c0532c0
1 /*
2 * Unit tests for IDxDiagProvider
4 * Copyright (C) 2009 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 "initguid.h"
24 #include "dxdiag.h"
25 #include "wine/test.h"
27 static void test_Initialize(void)
29 HRESULT hr;
30 IDxDiagProvider *pddp;
31 DXDIAG_INIT_PARAMS params;
33 hr = CoCreateInstance(&CLSID_DxDiagProvider, NULL, CLSCTX_INPROC_SERVER,
34 &IID_IDxDiagProvider, (LPVOID*)&pddp);
35 ok(hr == S_OK ||
36 broken(hr == REGDB_E_CLASSNOTREG), /* Clean W2K3 */
37 "Creating a IDxDiagProvider instance failed with %x\n", hr);
38 if (FAILED(hr))
40 skip("Failed to create a IDxDiagProvider instance\n");
41 return;
44 /* Test passing a NULL DXDIAG_INIT_PARAMS pointer. */
45 hr = IDxDiagProvider_Initialize(pddp, NULL);
46 ok(hr == E_POINTER,
47 "Expected IDxDiagProvider::Initialize to return E_POINTER, got %x\n", hr);
49 /* Test passing invalid dwSize values. */
50 params.dwSize = 0;
51 hr = IDxDiagProvider_Initialize(pddp, &params);
52 ok(hr == E_INVALIDARG,
53 "Expected IDxDiagProvider::Initialize to return E_INVALIDARG, got %x\n", hr);
55 params.dwSize = sizeof(params) + 1;
56 hr = IDxDiagProvider_Initialize(pddp, &params);
57 ok(hr == E_INVALIDARG,
58 "Expected IDxDiagProvider::Initialize to return E_INVALIDARG, got %x\n", hr);
60 /* Test passing an unexpected dwDxDiagHeaderVersion value. */
61 params.dwSize = sizeof(params);
62 params.dwDxDiagHeaderVersion = 0;
63 params.bAllowWHQLChecks = FALSE;
64 params.pReserved = NULL;
65 hr = IDxDiagProvider_Initialize(pddp, &params);
66 ok(hr == E_INVALIDARG,
67 "Expected IDxDiagProvider::Initialize to return E_INVALIDARG, got %x\n", hr);
69 /* Setting pReserved to a non-NULL value causes a crash on Windows. */
70 if (0)
72 params.dwDxDiagHeaderVersion = DXDIAG_DX9_SDK_VERSION;
73 params.bAllowWHQLChecks = FALSE;
74 params.pReserved = (VOID*)0xdeadbeef;
75 hr = IDxDiagProvider_Initialize(pddp, &params);
76 trace("IDxDiagProvider::Initialize returned %x\n", hr);
79 /* Test passing an appropriately initialized DXDIAG_INIT_PARAMS. */
80 params.dwDxDiagHeaderVersion = DXDIAG_DX9_SDK_VERSION;
81 params.bAllowWHQLChecks = FALSE;
82 params.pReserved = NULL;
83 hr = IDxDiagProvider_Initialize(pddp, &params);
84 ok(hr == S_OK, "Expected IDxDiagProvider::Initialize to return S_OK, got %x\n", hr);
86 /* Test initializing multiple times. */
87 hr = IDxDiagProvider_Initialize(pddp, &params);
88 ok(hr == S_OK, "Expected IDxDiagProvider::Initialize to return S_OK, got %x\n", hr);
90 IDxDiagProvider_Release(pddp);
93 static void test_GetRootContainer(void)
95 HRESULT hr;
96 IDxDiagProvider *pddp;
97 IDxDiagContainer *pddc, *pddc2;
98 DXDIAG_INIT_PARAMS params;
100 hr = CoCreateInstance(&CLSID_DxDiagProvider, NULL, CLSCTX_INPROC_SERVER,
101 &IID_IDxDiagProvider, (LPVOID*)&pddp);
102 ok(hr == S_OK ||
103 broken(hr == REGDB_E_CLASSNOTREG), /* Clean W2K3 */
104 "Creating a IDxDiagProvider instance failed with %x\n", hr);
105 if (FAILED(hr))
107 skip("Failed to create a IDxDiagProvider instance\n");
108 return;
111 /* Test calling IDxDiagProvider::GetRootContainer before initialization. */
112 hr = IDxDiagProvider_GetRootContainer(pddp, NULL);
113 ok(hr == CO_E_NOTINITIALIZED,
114 "Expected IDxDiagProvider::GetRootContainer to return CO_E_NOTINITIALIZED, got %x\n", hr);
116 hr = IDxDiagProvider_GetRootContainer(pddp, &pddc);
117 ok(hr == CO_E_NOTINITIALIZED,
118 "Expected IDxDiagProvider::GetRootContainer to return CO_E_NOTINITIALIZED, got %x\n", hr);
120 params.dwSize = sizeof(params);
121 params.dwDxDiagHeaderVersion = DXDIAG_DX9_SDK_VERSION;
122 params.bAllowWHQLChecks = FALSE;
123 params.pReserved = NULL;
124 hr = IDxDiagProvider_Initialize(pddp, &params);
125 ok(hr == S_OK, "Expected IDxDiagProvider::Initialize to return S_OK, got %x\n", hr);
126 if (FAILED(hr))
128 skip("IDxDiagProvider::Initialize failed\n");
129 IDxDiagProvider_Release(pddp);
130 return;
133 /* Passing NULL causes a crash on Windows. */
134 if (0)
136 hr = IDxDiagProvider_GetRootContainer(pddp, NULL);
137 trace("IDxDiagProvider::GetRootContainer returned %x\n", hr);
140 hr = IDxDiagProvider_GetRootContainer(pddp, &pddc);
141 ok(hr == S_OK, "Expected IDxDiagProvider::GetRootContainer to return S_OK, got %x\n", hr);
143 /* IDxDiagProvider::GetRootContainer creates new instances of the root
144 * container rather than maintain a static root container. */
145 hr = IDxDiagProvider_GetRootContainer(pddp, &pddc2);
146 ok(hr == S_OK, "Expected IDxDiagProvider::GetRootContainer to return S_OK, got %x\n", hr);
147 ok(pddc != pddc2, "Expected the two pointers (%p vs. %p) to be unequal\n", pddc, pddc2);
149 IDxDiagContainer_Release(pddc2);
150 IDxDiagContainer_Release(pddc);
151 IDxDiagProvider_Release(pddp);
154 START_TEST(provider)
156 CoInitialize(NULL);
157 test_Initialize();
158 test_GetRootContainer();
159 CoUninitialize();