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
25 #include "wine/test.h"
27 static void test_Initialize(void)
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, "Creating a IDxDiagProvider instance failed with %x\n", hr);
38 skip("Failed to create a IDxDiagProvider instance\n");
42 /* Test passing a NULL DXDIAG_INIT_PARAMS pointer. */
43 hr = IDxDiagProvider_Initialize(pddp, NULL);
45 "Expected IDxDiagProvider::Initialize to return E_POINTER, got %x\n", hr);
47 /* Test passing invalid dwSize values. */
49 hr = IDxDiagProvider_Initialize(pddp, ¶ms);
50 ok(hr == E_INVALIDARG,
51 "Expected IDxDiagProvider::Initialize to return E_INVALIDARG, got %x\n", hr);
53 params.dwSize = sizeof(params) + 1;
54 hr = IDxDiagProvider_Initialize(pddp, ¶ms);
55 ok(hr == E_INVALIDARG,
56 "Expected IDxDiagProvider::Initialize to return E_INVALIDARG, got %x\n", hr);
58 /* Test passing an unexpected dwDxDiagHeaderVersion value. */
59 params.dwSize = sizeof(params);
60 params.dwDxDiagHeaderVersion = 0;
61 params.bAllowWHQLChecks = FALSE;
62 params.pReserved = NULL;
63 hr = IDxDiagProvider_Initialize(pddp, ¶ms);
64 ok(hr == E_INVALIDARG,
65 "Expected IDxDiagProvider::Initialize to return E_INVALIDARG, got %x\n", hr);
67 /* Setting pReserved to a non-NULL value causes a crash on Windows. */
70 params.dwDxDiagHeaderVersion = DXDIAG_DX9_SDK_VERSION;
71 params.bAllowWHQLChecks = FALSE;
72 params.pReserved = (VOID*)0xdeadbeef;
73 hr = IDxDiagProvider_Initialize(pddp, ¶ms);
74 trace("IDxDiagProvider::Initialize returned %x\n", hr);
77 /* Test passing an appropriately initialized DXDIAG_INIT_PARAMS. */
78 params.dwDxDiagHeaderVersion = DXDIAG_DX9_SDK_VERSION;
79 params.bAllowWHQLChecks = FALSE;
80 params.pReserved = NULL;
81 hr = IDxDiagProvider_Initialize(pddp, ¶ms);
82 ok(hr == S_OK, "Expected IDxDiagProvider::Initialize to return S_OK, got %x\n", hr);
84 /* Test initializing multiple times. */
85 hr = IDxDiagProvider_Initialize(pddp, ¶ms);
86 ok(hr == S_OK, "Expected IDxDiagProvider::Initialize to return S_OK, got %x\n", hr);
88 IDxDiagProvider_Release(pddp);
91 static void test_GetRootContainer(void)
94 IDxDiagProvider *pddp;
95 IDxDiagContainer *pddc;
96 DXDIAG_INIT_PARAMS params;
98 hr = CoCreateInstance(&CLSID_DxDiagProvider, NULL, CLSCTX_INPROC_SERVER,
99 &IID_IDxDiagProvider, (LPVOID*)&pddp);
100 ok(hr == S_OK, "Creating a IDxDiagProvider instance failed with %x\n", hr);
103 skip("Failed to create a IDxDiagProvider instance\n");
107 /* Test calling IDxDiagProvider::GetRootContainer before initialization. */
108 hr = IDxDiagProvider_GetRootContainer(pddp, NULL);
109 ok(hr == CO_E_NOTINITIALIZED,
110 "Expected IDxDiagProvider::GetRootContainer to return CO_E_NOTINITIALIZED, got %x\n", hr);
112 hr = IDxDiagProvider_GetRootContainer(pddp, &pddc);
113 ok(hr == CO_E_NOTINITIALIZED,
114 "Expected IDxDiagProvider::GetRootContainer to return CO_E_NOTINITIALIZED, got %x\n", hr);
116 params.dwSize = sizeof(params);
117 params.dwDxDiagHeaderVersion = DXDIAG_DX9_SDK_VERSION;
118 params.bAllowWHQLChecks = FALSE;
119 params.pReserved = NULL;
120 hr = IDxDiagProvider_Initialize(pddp, ¶ms);
121 ok(hr == S_OK, "Expected IDxDiagProvider::Initialize to return S_OK, got %x\n", hr);
124 skip("IDxDiagProvider::Initialize failed\n");
125 IDxDiagProvider_Release(pddp);
129 /* Passing NULL causes a crash on Windows. */
132 hr = IDxDiagProvider_GetRootContainer(pddp, NULL);
133 trace("IDxDiagProvider::GetRootContainer returned %x\n", hr);
136 hr = IDxDiagProvider_GetRootContainer(pddp, &pddc);
137 ok(hr == S_OK, "Expected IDxDiagProvider::GetRootContainer to return S_OK, got %x\n", hr);
139 IDxDiagContainer_Release(pddc);
140 IDxDiagProvider_Release(pddp);
147 test_GetRootContainer();