ReactOS 0.4.15-dev-8390-g075894b
misc.c File Reference
#include "wine/test.h"
#include "dshow.h"
Include dependency graph for misc.c:

Go to the source code of this file.

Macros

#define COBJMACROS
 
#define QI_SUCCEED(iface, riid, ppv)
 
#define QI_FAIL(iface, riid, ppv)
 
#define ADDREF_EXPECT(iface, num)
 
#define RELEASE_EXPECT(iface, num)
 

Functions

static void test_aggregation (const CLSID clsidOuter, const CLSID clsidInner, const IID iidOuter, const IID iidInner)
 
static void test_null_renderer_aggregations (void)
 
static void test_video_renderer_aggregations (void)
 
static void test_filter_graph_aggregations (void)
 
static void test_filter_mapper_aggregations (void)
 
 START_TEST (misc)
 

Macro Definition Documentation

◆ ADDREF_EXPECT

#define ADDREF_EXPECT (   iface,
  num 
)
Value:
if (iface) { \
refCount = IUnknown_AddRef(iface); \
ok(refCount == num, "IUnknown_AddRef should return %d, got %d\n", num, refCount); \
}
GLuint GLuint num
Definition: glext.h:9618

Definition at line 34 of file misc.c.

◆ COBJMACROS

#define COBJMACROS

Definition at line 21 of file misc.c.

◆ QI_FAIL

#define QI_FAIL (   iface,
  riid,
  ppv 
)
Value:
hr = IUnknown_QueryInterface(iface, &riid, (LPVOID*)&ppv); \
ok(hr == E_NOINTERFACE, "IUnknown_QueryInterface returned %x\n", hr); \
ok(ppv == NULL, "Pointer is %p\n", ppv);
#define NULL
Definition: types.h:112
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
HRESULT hr
Definition: shlfolder.c:183
#define E_NOINTERFACE
Definition: winerror.h:2364

Definition at line 30 of file misc.c.

◆ QI_SUCCEED

#define QI_SUCCEED (   iface,
  riid,
  ppv 
)
Value:
hr = IUnknown_QueryInterface(iface, &riid, (LPVOID*)&ppv); \
ok(hr == S_OK, "IUnknown_QueryInterface returned %x\n", hr); \
ok(ppv != NULL, "Pointer is NULL\n");
#define S_OK
Definition: intsafe.h:52

Definition at line 26 of file misc.c.

◆ RELEASE_EXPECT

#define RELEASE_EXPECT (   iface,
  num 
)
Value:
if (iface) { \
refCount = IUnknown_Release(iface); \
ok(refCount == num, "IUnknown_Release should return %d, got %d\n", num, refCount); \
}

Definition at line 39 of file misc.c.

Function Documentation

◆ START_TEST()

START_TEST ( misc  )

Definition at line 223 of file misc.c.

224{
226
231
233}
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
static void test_null_renderer_aggregations(void)
Definition: misc.c:165
static void test_filter_graph_aggregations(void)
Definition: misc.c:192
static void test_video_renderer_aggregations(void)
Definition: misc.c:178
static void test_filter_mapper_aggregations(void)
Definition: misc.c:209

◆ test_aggregation()

static void test_aggregation ( const CLSID  clsidOuter,
const CLSID  clsidInner,
const IID  iidOuter,
const IID  iidInner 
)
static

Definition at line 44 of file misc.c.

46{
47 HRESULT hr;
48 ULONG refCount;
49 IUnknown *pUnkOuter = NULL;
50 IUnknown *pUnkInner = NULL;
51 IUnknown *pUnkInnerFail = NULL;
52 IUnknown *pUnkOuterTest = NULL;
53 IUnknown *pUnkInnerTest = NULL;
54 IUnknown *pUnkAggregatee = NULL;
55 IUnknown *pUnkAggregator = NULL;
56 IUnknown *pUnkTest = NULL;
57
58 hr = CoCreateInstance(&clsidOuter, NULL, CLSCTX_INPROC_SERVER,
59 &IID_IUnknown, (LPVOID*)&pUnkOuter);
60 ok(hr == S_OK, "CoCreateInstance failed with %x\n", hr);
61 ok(pUnkOuter != NULL, "pUnkOuter is NULL\n");
62
63 if (!pUnkOuter)
64 {
65 skip("pUnkOuter is NULL\n");
66 return;
67 }
68
69 /* for aggregation, we should only be able to request IUnknown */
70 hr = CoCreateInstance(&clsidInner, pUnkOuter, CLSCTX_INPROC_SERVER,
71 &iidInner, (LPVOID*)&pUnkInnerFail);
73 {
74 skip("Class not registered\n");
75 return;
76 }
77 ok(hr == E_NOINTERFACE, "CoCreateInstance returned %x\n", hr);
78 ok(pUnkInnerFail == NULL, "pUnkInnerFail is not NULL\n");
79
80 /* aggregation, request IUnknown */
81 hr = CoCreateInstance(&clsidInner, pUnkOuter, CLSCTX_INPROC_SERVER,
82 &IID_IUnknown, (LPVOID*)&pUnkInner);
83 ok(hr == S_OK, "CoCreateInstance returned %x\n", hr);
84 ok(pUnkInner != NULL, "pUnkInner is NULL\n");
85
86 if (!pUnkInner)
87 {
88 skip("pUnkInner is NULL\n");
89 return;
90 }
91
92 ADDREF_EXPECT(pUnkOuter, 2);
93 ADDREF_EXPECT(pUnkInner, 2);
94 RELEASE_EXPECT(pUnkOuter, 1);
95 RELEASE_EXPECT(pUnkInner, 1);
96
97 QI_FAIL(pUnkOuter, iidInner, pUnkAggregatee);
98 QI_FAIL(pUnkInner, iidOuter, pUnkAggregator);
99
100 /* these QueryInterface calls should work */
101 QI_SUCCEED(pUnkOuter, iidOuter, pUnkAggregator);
102 QI_SUCCEED(pUnkOuter, IID_IUnknown, pUnkOuterTest);
103 /* IGraphConfig interface comes with DirectShow 9 */
104 if(IsEqualGUID(&IID_IGraphConfig, &iidInner))
105 {
106 hr = IUnknown_QueryInterface(pUnkInner, &iidInner, (LPVOID*)&pUnkAggregatee);
107 ok(hr == S_OK || broken(hr == E_NOINTERFACE), "IUnknown_QueryInterface returned %x\n", hr);
108 ok(pUnkAggregatee != NULL || broken(!pUnkAggregatee), "Pointer is NULL\n");
109 }
110 else
111 {
112 QI_SUCCEED(pUnkInner, iidInner, pUnkAggregatee);
113 }
114 QI_SUCCEED(pUnkInner, IID_IUnknown, pUnkInnerTest);
115
116 if (!pUnkAggregator || !pUnkOuterTest || !pUnkAggregatee
117 || !pUnkInnerTest)
118 {
119 skip("One of the required interfaces is NULL\n");
120 return;
121 }
122
123 ADDREF_EXPECT(pUnkAggregator, 5);
124 ADDREF_EXPECT(pUnkOuterTest, 6);
125 ADDREF_EXPECT(pUnkAggregatee, 7);
126 ADDREF_EXPECT(pUnkInnerTest, 3);
127 RELEASE_EXPECT(pUnkAggregator, 6);
128 RELEASE_EXPECT(pUnkOuterTest, 5);
129 RELEASE_EXPECT(pUnkAggregatee, 4);
130 RELEASE_EXPECT(pUnkInnerTest, 2);
131
132 QI_SUCCEED(pUnkAggregator, IID_IUnknown, pUnkTest);
133 QI_SUCCEED(pUnkOuterTest, IID_IUnknown, pUnkTest);
134 QI_SUCCEED(pUnkAggregatee, IID_IUnknown, pUnkTest);
135 QI_SUCCEED(pUnkInnerTest, IID_IUnknown, pUnkTest);
136
137 QI_FAIL(pUnkAggregator, iidInner, pUnkTest);
138 QI_FAIL(pUnkOuterTest, iidInner, pUnkTest);
139 QI_FAIL(pUnkAggregatee, iidInner, pUnkTest);
140 QI_SUCCEED(pUnkInnerTest, iidInner, pUnkTest);
141
142 QI_SUCCEED(pUnkAggregator, iidOuter, pUnkTest);
143 QI_SUCCEED(pUnkOuterTest, iidOuter, pUnkTest);
144 QI_SUCCEED(pUnkAggregatee, iidOuter, pUnkTest);
145 QI_FAIL(pUnkInnerTest, iidOuter, pUnkTest);
146
147 RELEASE_EXPECT(pUnkAggregator, 10);
148 RELEASE_EXPECT(pUnkOuterTest, 9);
149 RELEASE_EXPECT(pUnkAggregatee, 8);
150 RELEASE_EXPECT(pUnkInnerTest, 2);
151 RELEASE_EXPECT(pUnkOuter, 7);
152 RELEASE_EXPECT(pUnkInner, 1);
153
154 do
155 {
156 refCount = IUnknown_Release(pUnkInner);
157 } while (refCount);
158
159 do
160 {
161 refCount = IUnknown_Release(pUnkOuter);
162 } while (refCount);
163}
#define broken(x)
Definition: _sntprintf.h:21
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
const GUID IID_IUnknown
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
#define RELEASE_EXPECT(iface, num)
Definition: misc.c:39
#define QI_FAIL(iface, riid, ppv)
Definition: misc.c:30
#define QI_SUCCEED(iface, riid, ppv)
Definition: misc.c:26
#define ADDREF_EXPECT(iface, num)
Definition: misc.c:34
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
uint32_t ULONG
Definition: typedefs.h:59
#define REGDB_E_CLASSNOTREG
Definition: winerror.h:2696

◆ test_filter_graph_aggregations()

static void test_filter_graph_aggregations ( void  )
static

Definition at line 192 of file misc.c.

193{
194 const IID * iids[] = {
195 &IID_IFilterGraph2, &IID_IMediaControl, &IID_IGraphBuilder,
196 &IID_IFilterGraph, &IID_IMediaSeeking, &IID_IBasicAudio, &IID_IBasicVideo,
197 &IID_IVideoWindow, &IID_IMediaEventEx, &IID_IMediaFilter,
198 &IID_IMediaEventSink, &IID_IGraphConfig, &IID_IMediaPosition
199 };
200 int i;
201
202 for (i = 0; i < sizeof(iids) / sizeof(iids[0]); i++)
203 {
204 test_aggregation(CLSID_SystemClock, CLSID_FilterGraph,
205 IID_IReferenceClock, *iids[i]);
206 }
207}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static void test_aggregation(void)
Definition: registrar.c:143

Referenced by START_TEST().

◆ test_filter_mapper_aggregations()

static void test_filter_mapper_aggregations ( void  )
static

Definition at line 209 of file misc.c.

210{
211 const IID * iids[] = {
212 &IID_IFilterMapper2, &IID_IFilterMapper
213 };
214 int i;
215
216 for (i = 0; i < sizeof(iids) / sizeof(iids[0]); i++)
217 {
218 test_aggregation(CLSID_SystemClock, CLSID_FilterMapper2,
219 IID_IReferenceClock, *iids[i]);
220 }
221}

Referenced by START_TEST().

◆ test_null_renderer_aggregations()

static void test_null_renderer_aggregations ( void  )
static

Definition at line 165 of file misc.c.

166{
167 const IID * iids[] = {
168 &IID_IMediaFilter, &IID_IBaseFilter
169 };
170 int i;
171
172 for (i = 0; i < sizeof(iids) / sizeof(iids[0]); i++)
173 {
174 test_aggregation(CLSID_SystemClock, CLSID_NullRenderer, IID_IReferenceClock, *iids[i]);
175 }
176}
const GUID IID_IBaseFilter

Referenced by START_TEST().

◆ test_video_renderer_aggregations()

static void test_video_renderer_aggregations ( void  )
static

Definition at line 178 of file misc.c.

179{
180 const IID * iids[] = {
181 &IID_IMediaFilter, &IID_IBaseFilter, &IID_IBasicVideo, &IID_IVideoWindow
182 };
183 int i;
184
185 for (i = 0; i < sizeof(iids) / sizeof(iids[0]); i++)
186 {
187 test_aggregation(CLSID_SystemClock, CLSID_VideoRenderer,
188 IID_IReferenceClock, *iids[i]);
189 }
190}

Referenced by START_TEST().