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
);
36 broken(hr
== REGDB_E_CLASSNOTREG
), /* Clean W2K3 */
37 "Creating a IDxDiagProvider instance failed with %x\n", hr
);
40 skip("Failed to create a IDxDiagProvider instance\n");
44 /* Test passing a NULL DXDIAG_INIT_PARAMS pointer. */
45 hr
= IDxDiagProvider_Initialize(pddp
, NULL
);
47 "Expected IDxDiagProvider::Initialize to return E_POINTER, got %x\n", hr
);
49 /* Test passing invalid dwSize values. */
51 hr
= IDxDiagProvider_Initialize(pddp
, ¶ms
);
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
, ¶ms
);
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
, ¶ms
);
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. */
72 params
.dwDxDiagHeaderVersion
= DXDIAG_DX9_SDK_VERSION
;
73 params
.bAllowWHQLChecks
= FALSE
;
74 params
.pReserved
= (VOID
*)0xdeadbeef;
75 hr
= IDxDiagProvider_Initialize(pddp
, ¶ms
);
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
, ¶ms
);
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
, ¶ms
);
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)
96 IDxDiagProvider
*pddp
;
97 IDxDiagContainer
*pddc
;
98 DXDIAG_INIT_PARAMS params
;
100 hr
= CoCreateInstance(&CLSID_DxDiagProvider
, NULL
, CLSCTX_INPROC_SERVER
,
101 &IID_IDxDiagProvider
, (LPVOID
*)&pddp
);
103 broken(hr
== REGDB_E_CLASSNOTREG
), /* Clean W2K3 */
104 "Creating a IDxDiagProvider instance failed with %x\n", hr
);
107 skip("Failed to create a IDxDiagProvider instance\n");
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
, ¶ms
);
125 ok(hr
== S_OK
, "Expected IDxDiagProvider::Initialize to return S_OK, got %x\n", hr
);
128 skip("IDxDiagProvider::Initialize failed\n");
129 IDxDiagProvider_Release(pddp
);
133 /* Passing NULL causes a crash on Windows. */
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 IDxDiagContainer_Release(pddc
);
144 IDxDiagProvider_Release(pddp
);
151 test_GetRootContainer();