wininet: Support the Cache-Control max-age directive for setting url cache entry...
[wine/testsucceed.git] / dlls / quartz / tests / misc.c
blob74c386b66709a1c016b27f2291ed4e0a2f4da347
1 /*
2 * Misc unit tests for Quartz
4 * Copyright (C) 2007 Google (Lei Zhang)
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 "wine/test.h"
24 #include "dshow.h"
26 #define QI_SUCCEED(iface, riid, ppv) hr = IUnknown_QueryInterface(iface, &riid, (LPVOID*)&ppv); \
27 ok(hr == S_OK, "IUnknown_QueryInterface returned %x\n", hr); \
28 ok(ppv != NULL, "Pointer is NULL\n");
30 #define QI_FAIL(iface, riid, ppv) hr = IUnknown_QueryInterface(iface, &riid, (LPVOID*)&ppv); \
31 ok(hr == E_NOINTERFACE, "IUnknown_QueryInterface returned %x\n", hr); \
32 ok(ppv == NULL, "Pointer is %p\n", ppv);
34 #define ADDREF_EXPECT(iface, num) if (iface) { \
35 refCount = IUnknown_AddRef(iface); \
36 ok(refCount == num, "IUnknown_AddRef should return %d, got %d\n", num, refCount); \
39 #define RELEASE_EXPECT(iface, num) if (iface) { \
40 refCount = IUnknown_Release(iface); \
41 ok(refCount == num, "IUnknown_Release should return %d, got %d\n", num, refCount); \
44 static void test_aggregation(const CLSID clsidOuter, const CLSID clsidInner,
45 const IID iidOuter, const IID iidInner)
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;
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");
63 if (!pUnkOuter)
65 skip("pUnkOuter is NULL\n");
66 return;
69 /* for aggregation, we should only be able to request IUnknown */
70 hr = CoCreateInstance(&clsidInner, pUnkOuter, CLSCTX_INPROC_SERVER,
71 &iidInner, (LPVOID*)&pUnkInnerFail);
72 ok(hr == E_NOINTERFACE, "CoCreateInstance returned %x\n", hr);
73 ok(pUnkInnerFail == NULL, "pUnkInnerFail is not NULL\n");
75 /* aggregation, request IUnknown */
76 hr = CoCreateInstance(&clsidInner, pUnkOuter, CLSCTX_INPROC_SERVER,
77 &IID_IUnknown, (LPVOID*)&pUnkInner);
78 ok(hr == S_OK, "CoCreateInstance returned %x\n", hr);
79 ok(pUnkInner != NULL, "pUnkInner is NULL\n");
81 if (!pUnkInner)
83 skip("pUnkInner is NULL\n");
84 return;
87 ADDREF_EXPECT(pUnkOuter, 2);
88 ADDREF_EXPECT(pUnkInner, 2);
89 RELEASE_EXPECT(pUnkOuter, 1);
90 RELEASE_EXPECT(pUnkInner, 1);
92 QI_FAIL(pUnkOuter, iidInner, pUnkAggregatee);
93 QI_FAIL(pUnkInner, iidOuter, pUnkAggregator);
95 /* these QueryInterface calls should work */
96 QI_SUCCEED(pUnkOuter, iidOuter, pUnkAggregator);
97 QI_SUCCEED(pUnkOuter, IID_IUnknown, pUnkOuterTest);
98 /* IGraphConfig interface comes with DirectShow 9 */
99 if(IsEqualGUID(&IID_IGraphConfig, &iidInner))
101 hr = IUnknown_QueryInterface(pUnkInner, &iidInner, (LPVOID*)&pUnkAggregatee);
102 ok(hr == S_OK || broken(hr == E_NOINTERFACE), "IUnknown_QueryInterface returned %x\n", hr);
103 ok(pUnkAggregatee != NULL || broken(!pUnkAggregatee), "Pointer is NULL\n");
105 else
107 QI_SUCCEED(pUnkInner, iidInner, pUnkAggregatee);
109 QI_SUCCEED(pUnkInner, IID_IUnknown, pUnkInnerTest);
111 if (!pUnkAggregator || !pUnkOuterTest || !pUnkAggregatee
112 || !pUnkInnerTest)
114 skip("One of the required interfaces is NULL\n");
115 return;
118 ADDREF_EXPECT(pUnkAggregator, 5);
119 ADDREF_EXPECT(pUnkOuterTest, 6);
120 ADDREF_EXPECT(pUnkAggregatee, 7);
121 ADDREF_EXPECT(pUnkInnerTest, 3);
122 RELEASE_EXPECT(pUnkAggregator, 6);
123 RELEASE_EXPECT(pUnkOuterTest, 5);
124 RELEASE_EXPECT(pUnkAggregatee, 4);
125 RELEASE_EXPECT(pUnkInnerTest, 2);
127 QI_SUCCEED(pUnkAggregator, IID_IUnknown, pUnkTest);
128 QI_SUCCEED(pUnkOuterTest, IID_IUnknown, pUnkTest);
129 QI_SUCCEED(pUnkAggregatee, IID_IUnknown, pUnkTest);
130 QI_SUCCEED(pUnkInnerTest, IID_IUnknown, pUnkTest);
132 QI_FAIL(pUnkAggregator, iidInner, pUnkTest);
133 QI_FAIL(pUnkOuterTest, iidInner, pUnkTest);
134 QI_FAIL(pUnkAggregatee, iidInner, pUnkTest);
135 QI_SUCCEED(pUnkInnerTest, iidInner, pUnkTest);
137 QI_SUCCEED(pUnkAggregator, iidOuter, pUnkTest);
138 QI_SUCCEED(pUnkOuterTest, iidOuter, pUnkTest);
139 QI_SUCCEED(pUnkAggregatee, iidOuter, pUnkTest);
140 QI_FAIL(pUnkInnerTest, iidOuter, pUnkTest);
142 RELEASE_EXPECT(pUnkAggregator, 10);
143 RELEASE_EXPECT(pUnkOuterTest, 9);
144 RELEASE_EXPECT(pUnkAggregatee, 8);
145 RELEASE_EXPECT(pUnkInnerTest, 2);
146 RELEASE_EXPECT(pUnkOuter, 7);
147 RELEASE_EXPECT(pUnkInner, 1);
151 refCount = IUnknown_Release(pUnkInner);
152 } while (refCount);
156 refCount = IUnknown_Release(pUnkOuter);
157 } while (refCount);
160 static void test_video_renderer_aggregations(void)
162 const IID * iids[] = {
163 &IID_IMediaFilter, &IID_IBaseFilter, &IID_IBasicVideo, &IID_IVideoWindow
165 int i;
167 for (i = 0; i < sizeof(iids) / sizeof(iids[0]); i++)
169 test_aggregation(CLSID_SystemClock, CLSID_VideoRenderer,
170 IID_IReferenceClock, *iids[i]);
174 static void test_filter_graph_aggregations(void)
176 const IID * iids[] = {
177 &IID_IFilterGraph2, &IID_IMediaControl, &IID_IGraphBuilder,
178 &IID_IFilterGraph, &IID_IMediaSeeking, &IID_IBasicAudio, &IID_IBasicVideo,
179 &IID_IVideoWindow, &IID_IMediaEventEx, &IID_IMediaFilter,
180 &IID_IMediaEventSink, &IID_IGraphConfig, &IID_IMediaPosition
182 int i;
184 for (i = 0; i < sizeof(iids) / sizeof(iids[0]); i++)
186 test_aggregation(CLSID_SystemClock, CLSID_FilterGraph,
187 IID_IReferenceClock, *iids[i]);
191 static void test_filter_mapper_aggregations(void)
193 const IID * iids[] = {
194 &IID_IFilterMapper2, &IID_IFilterMapper
196 int i;
198 for (i = 0; i < sizeof(iids) / sizeof(iids[0]); i++)
200 test_aggregation(CLSID_SystemClock, CLSID_FilterMapper2,
201 IID_IReferenceClock, *iids[i]);
205 START_TEST(misc)
207 CoInitialize(NULL);
209 test_video_renderer_aggregations();
210 test_filter_graph_aggregations();
211 test_filter_mapper_aggregations();
213 CoUninitialize();