ReactOS 0.4.16-dev-117-g38f21f9
provider.c
Go to the documentation of this file.
1/*
2 * Unit tests for IDxDiagProvider
3 *
4 * Copyright (C) 2009 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 "initguid.h"
24#include "wine/dxdiag.h"
25#include "wine/test.h"
26
27static void test_Initialize(void)
28{
29 HRESULT hr;
30 IDxDiagProvider *pddp;
32
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))
39 {
40 skip("Failed to create a IDxDiagProvider instance\n");
41 return;
42 }
43
44 /* Test passing a NULL DXDIAG_INIT_PARAMS pointer. */
46 ok(hr == E_POINTER,
47 "Expected IDxDiagProvider::Initialize to return E_POINTER, got %x\n", hr);
48
49 /* Test passing invalid dwSize values. */
50 params.dwSize = 0;
53 "Expected IDxDiagProvider::Initialize to return E_INVALIDARG, got %x\n", hr);
54
55 params.dwSize = sizeof(params) + 1;
58 "Expected IDxDiagProvider::Initialize to return E_INVALIDARG, got %x\n", hr);
59
60 /* Test passing an unexpected dwDxDiagHeaderVersion value. */
61 params.dwSize = sizeof(params);
62 params.dwDxDiagHeaderVersion = 0;
63 params.bAllowWHQLChecks = FALSE;
64 params.pReserved = NULL;
67 "Expected IDxDiagProvider::Initialize to return E_INVALIDARG, got %x\n", hr);
68
69 /* Setting pReserved to a non-NULL value causes a crash on Windows. */
70 if (0)
71 {
72 params.dwDxDiagHeaderVersion = DXDIAG_DX9_SDK_VERSION;
73 params.bAllowWHQLChecks = FALSE;
74 params.pReserved = (VOID*)0xdeadbeef;
76 trace("IDxDiagProvider::Initialize returned %x\n", hr);
77 }
78
79 /* Test passing an appropriately initialized DXDIAG_INIT_PARAMS. */
80 params.dwDxDiagHeaderVersion = DXDIAG_DX9_SDK_VERSION;
81 params.bAllowWHQLChecks = FALSE;
82 params.pReserved = NULL;
84 ok(hr == S_OK, "Expected IDxDiagProvider::Initialize to return S_OK, got %x\n", hr);
85
86 /* Test initializing multiple times. */
88 ok(hr == S_OK, "Expected IDxDiagProvider::Initialize to return S_OK, got %x\n", hr);
89
91}
92
93static void test_GetRootContainer(void)
94{
95 HRESULT hr;
96 IDxDiagProvider *pddp;
97 IDxDiagContainer *pddc, *pddc2;
99
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))
106 {
107 skip("Failed to create a IDxDiagProvider instance\n");
108 return;
109 }
110
111 /* Test calling IDxDiagProvider::GetRootContainer before initialization. */
114 "Expected IDxDiagProvider::GetRootContainer to return CO_E_NOTINITIALIZED, got %x\n", hr);
115
118 "Expected IDxDiagProvider::GetRootContainer to return CO_E_NOTINITIALIZED, got %x\n", hr);
119
120 params.dwSize = sizeof(params);
121 params.dwDxDiagHeaderVersion = DXDIAG_DX9_SDK_VERSION;
122 params.bAllowWHQLChecks = FALSE;
123 params.pReserved = NULL;
125 ok(hr == S_OK, "Expected IDxDiagProvider::Initialize to return S_OK, got %x\n", hr);
126 if (FAILED(hr))
127 {
128 skip("IDxDiagProvider::Initialize failed\n");
130 return;
131 }
132
133 /* Passing NULL causes a crash on Windows. */
134 if (0)
135 {
137 trace("IDxDiagProvider::GetRootContainer returned %x\n", hr);
138 }
139
141 ok(hr == S_OK, "Expected IDxDiagProvider::GetRootContainer to return S_OK, got %x\n", hr);
142
143 /* IDxDiagProvider::GetRootContainer creates new instances of the root
144 * container rather than maintain a static root container. */
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);
148
152}
153
154START_TEST(provider)
155{
160}
#define CO_E_NOTINITIALIZED
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define broken(x)
Definition: atltest.h:178
#define START_TEST(x)
Definition: atltest.h:75
#define E_INVALIDARG
Definition: ddrawi.h:101
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
#define IDxDiagContainer_Release(p)
Definition: dxdiag.h:66
#define IDxDiagProvider_Release(p)
Definition: dxdiag.h:61
#define IDxDiagProvider_GetRootContainer(p, a)
Definition: dxdiag.h:63
#define DXDIAG_DX9_SDK_VERSION
Definition: dxdiag.h:6
#define IDxDiagProvider_Initialize(p, a, b)
Definition: dxdiag.h:62
GLenum const GLfloat * params
Definition: glext.h:5645
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
static IDxDiagContainer * pddc
Definition: container.c:35
static IDxDiagProvider * pddp
Definition: container.c:34
static void test_Initialize(void)
Definition: provider.c:27
static void test_GetRootContainer(void)
Definition: provider.c:93
HRESULT hr
Definition: shlfolder.c:183
#define REGDB_E_CLASSNOTREG
Definition: winerror.h:2696
#define E_POINTER
Definition: winerror.h:2365