Release 1.6-rc2.
[wine/testsucceed.git] / dlls / ddraw / tests / refcount.c
blobb5a699b7b2ef66d74e7a36df3b40a432938412e0
1 /*
2 * Some unit tests for ddraw reference counting
4 * Copyright (C) 2006 Stefan Dösinger
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
20 #define COBJMACROS
22 #include "wine/test.h"
23 #include "ddraw.h"
24 #include "d3d.h"
25 #include "unknwn.h"
27 static HRESULT (WINAPI *pDirectDrawCreateEx)(LPGUID,LPVOID*,REFIID,LPUNKNOWN);
29 static void init_function_pointers(void)
31 HMODULE hmod = GetModuleHandleA("ddraw.dll");
32 pDirectDrawCreateEx = (void*)GetProcAddress(hmod, "DirectDrawCreateEx");
35 static ULONG getRefcount(IUnknown *iface)
37 IUnknown_AddRef(iface);
38 return IUnknown_Release(iface);
41 static void test_ddraw_objects(void)
43 HRESULT hr;
44 ULONG ref;
45 IDirectDraw7 *DDraw7;
46 IDirectDraw4 *DDraw4;
47 IDirectDraw2 *DDraw2;
48 IDirectDraw *DDraw1;
49 IDirectDrawPalette *palette;
50 IDirectDrawSurface7 *surface = NULL;
51 IDirectDrawSurface *surface1;
52 IDirectDrawSurface4 *surface4;
53 PALETTEENTRY Table[256];
54 DDSURFACEDESC2 ddsd;
56 hr = pDirectDrawCreateEx(NULL, (void **) &DDraw7, &IID_IDirectDraw7, NULL);
57 ok(hr == DD_OK || hr==DDERR_NODIRECTDRAWSUPPORT, "DirectDrawCreateEx returned: %x\n", hr);
58 if(!DDraw7)
60 trace("Couldn't create DDraw interface, skipping tests\n");
61 return;
64 hr = IDirectDraw7_QueryInterface(DDraw7, &IID_IDirectDraw4, (void **) &DDraw4);
65 ok(hr == DD_OK, "IDirectDraw7_QueryInterface returned %08x\n", hr);
66 hr = IDirectDraw7_QueryInterface(DDraw7, &IID_IDirectDraw2, (void **) &DDraw2);
67 ok(hr == DD_OK, "IDirectDraw7_QueryInterface returned %08x\n", hr);
68 hr = IDirectDraw7_QueryInterface(DDraw7, &IID_IDirectDraw, (void **) &DDraw1);
69 ok(hr == DD_OK, "IDirectDraw7_QueryInterface returned %08x\n", hr);
71 ref = getRefcount( (IUnknown *) DDraw7);
72 ok(ref == 1, "Got refcount %d, expected 1\n", ref);
74 /* Fails without a cooplevel */
75 hr = IDirectDraw7_CreatePalette(DDraw7, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, Table, &palette, NULL);
76 ok(hr == DDERR_NOCOOPERATIVELEVELSET, "CreatePalette returned %08x\n", hr);
78 /* This check is before the cooplevel check */
79 hr = IDirectDraw7_CreatePalette(DDraw7, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, Table, &palette, (void *) 0xdeadbeef);
80 ok(hr == CLASS_E_NOAGGREGATION, "CreatePalette returned %08x\n", hr);
82 hr = IDirectDraw7_SetCooperativeLevel(DDraw7, 0, DDSCL_NORMAL);
83 ok(hr == DD_OK, "SetCooperativeLevel failed with %08x\n", hr);
85 memset(&ddsd, 0, sizeof(ddsd));
86 ddsd.dwSize = sizeof(ddsd);
87 ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
88 ddsd.dwWidth = 64;
89 ddsd.dwHeight = 64;
90 ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
91 U4(ddsd).ddpfPixelFormat.dwSize = sizeof(U4(ddsd).ddpfPixelFormat);
92 U4(ddsd).ddpfPixelFormat.dwFlags = DDPF_PALETTEINDEXED8 | DDPF_RGB;
93 U1(U4(ddsd).ddpfPixelFormat).dwRGBBitCount = 8;
95 hr = IDirectDraw7_CreateSurface(DDraw7, &ddsd, &surface, NULL);
96 if (!surface)
98 win_skip("Could not create surface : %08x\n", hr);
99 IDirectDraw7_Release(DDraw7);
100 return;
102 ok(hr == DD_OK, "CreateSurface failed with %08x\n", hr);
104 /* DDraw refcount increased by 1 */
105 ref = getRefcount( (IUnknown *) DDraw7);
106 ok(ref == 2, "Got refcount %d, expected 2\n", ref);
108 /* Surface refcount starts with 1 */
109 ref = getRefcount( (IUnknown *) surface);
110 ok(ref == 1, "Got refcount %d, expected 1\n", ref);
112 hr = IDirectDraw7_CreatePalette(DDraw7, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, Table, &palette, NULL);
113 ok(hr == DD_OK, "CreatePalette returned %08x\n", hr);
115 /* DDraw refcount increased by 1 */
116 ref = getRefcount( (IUnknown *) DDraw7);
117 ok(ref == 3, "Got refcount %d, expected 3\n", ref);
119 /* Palette starts with 1 */
120 ref = getRefcount( (IUnknown *) palette);
121 ok(ref == 1, "Got refcount %d, expected 1\n", ref);
123 /* Test attaching a palette to a surface */
124 hr = IDirectDrawSurface7_SetPalette(surface, palette);
125 ok(hr == DD_OK, "IDirectDrawSurface_SetPalette failed with %08x\n", hr);
127 /* Palette refcount increased, surface stays the same */
128 ref = getRefcount( (IUnknown *) palette);
129 ok(ref == 2, "Got refcount %d, expected 2\n", ref);
130 ref = getRefcount( (IUnknown *) surface);
131 ok(ref == 1, "Got refcount %d, expected 1\n", ref);
133 IDirectDrawSurface7_Release(surface);
134 /* Increased before - decrease now */
135 ref = getRefcount( (IUnknown *) DDraw7);
136 ok(ref == 2, "Got refcount %d, expected 2\n", ref);
138 /* Releasing the surface detaches the palette */
139 ref = getRefcount( (IUnknown *) palette);
140 ok(ref == 1, "Got refcount %d, expected 1\n", ref);
142 IDirectDrawPalette_Release(palette);
144 /* Increased before - decrease now */
145 ref = getRefcount( (IUnknown *) DDraw7);
146 ok(ref == 1, "Got refcount %d, expected 1\n", ref);
148 /* Not all interfaces are AddRefed when a palette is created */
149 hr = IDirectDraw4_CreatePalette(DDraw4, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, Table, &palette, NULL);
150 ok(hr == DD_OK, "CreatePalette returned %08x\n", hr);
151 ref = getRefcount( (IUnknown *) DDraw4);
152 ok(ref == 2, "Got refcount %d, expected 2\n", ref);
153 IDirectDrawPalette_Release(palette);
155 /* No addref here */
156 hr = IDirectDraw2_CreatePalette(DDraw2, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, Table, &palette, NULL);
157 ok(hr == DD_OK, "CreatePalette returned %08x\n", hr);
158 ref = getRefcount( (IUnknown *) DDraw2);
159 ok(ref == 1, "Got refcount %d, expected 1\n", ref);
160 IDirectDrawPalette_Release(palette);
162 /* No addref here */
163 hr = IDirectDraw_CreatePalette(DDraw1, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, Table, &palette, NULL);
164 ok(hr == DD_OK, "CreatePalette returned %08x\n", hr);
165 ref = getRefcount( (IUnknown *) DDraw1);
166 ok(ref == 1, "Got refcount %d, expected 1\n", ref);
167 IDirectDrawPalette_Release(palette);
169 /* Similar for surfaces */
170 hr = IDirectDraw4_CreateSurface(DDraw4, &ddsd, &surface4, NULL);
171 ok(hr == DD_OK, "CreateSurface returned %08x\n", hr);
172 ref = getRefcount( (IUnknown *) DDraw4);
173 ok(ref == 2, "Got refcount %d, expected 2\n", ref);
174 IDirectDrawSurface4_Release(surface4);
176 ddsd.dwSize = sizeof(DDSURFACEDESC);
177 hr = IDirectDraw2_CreateSurface(DDraw2, (DDSURFACEDESC *) &ddsd, &surface1, NULL);
178 ok(hr == DD_OK, "CreateSurface returned %08x\n", hr);
179 ref = getRefcount( (IUnknown *) DDraw2);
180 ok(ref == 1, "Got refcount %d, expected 1\n", ref);
181 IDirectDrawSurface_Release(surface1);
183 hr = IDirectDraw_CreateSurface(DDraw1, (DDSURFACEDESC *) &ddsd, &surface1, NULL);
184 ok(hr == DD_OK, "CreateSurface returned %08x\n", hr);
185 ref = getRefcount( (IUnknown *) DDraw1);
186 ok(ref == 1, "Got refcount %d, expected 1\n", ref);
187 IDirectDrawSurface_Release(surface1);
189 IDirectDraw7_Release(DDraw7);
190 IDirectDraw4_Release(DDraw4);
191 IDirectDraw2_Release(DDraw2);
192 IDirectDraw_Release(DDraw1);
195 static void test_iface_refcnt(void)
197 HRESULT hr;
198 IDirectDraw *DDraw1;
199 IDirectDraw2 *DDraw2;
200 IDirectDraw4 *DDraw4;
201 IDirectDraw7 *DDraw7;
202 IDirect3D7 *D3D7;
203 IDirect3D3 *D3D3;
204 IDirect3D2 *D3D2;
205 IDirect3D *D3D1;
206 long ref;
208 hr = pDirectDrawCreateEx(NULL, (void **) &DDraw7, &IID_IDirectDraw7, NULL);
209 ok(hr == DD_OK || hr==DDERR_NODIRECTDRAWSUPPORT, "DirectDrawCreateEx returned: %x\n", hr);
210 if(!DDraw7)
212 trace("Couldn't create DDraw interface, skipping tests\n");
213 return;
216 ref = getRefcount( (IUnknown *) DDraw7);
217 ok(ref == 1, "Initial IDirectDraw7 reference count is %ld\n", ref);
219 hr = IDirectDraw7_QueryInterface(DDraw7, &IID_IDirectDraw4, (void **) &DDraw4);
220 ok(hr == DD_OK, "IDirectDraw7_QueryInterface returned %08x\n", hr);
221 hr = IDirectDraw7_QueryInterface(DDraw7, &IID_IDirectDraw2, (void **) &DDraw2);
222 ok(hr == DD_OK, "IDirectDraw7_QueryInterf&ace returned %08x\n", hr);
223 hr = IDirectDraw7_QueryInterface(DDraw7, &IID_IDirectDraw, (void **) &DDraw1);
224 ok(hr == DD_OK, "IDirectDraw7_QueryInterface returned %08x\n", hr);
226 /* All interfaces now have refcount 1! */
227 ref = getRefcount( (IUnknown *) DDraw7);
228 ok(ref == 1, "IDirectDraw7 reference count is %ld\n", ref);
229 ref = getRefcount( (IUnknown *) DDraw7);
230 ok(ref == 1, "IDirectDraw7 reference count is %ld\n", ref);
231 ref = getRefcount( (IUnknown *) DDraw4);
232 ok(ref == 1, "IDirectDraw4 reference count is %ld\n", ref);
233 ref = getRefcount( (IUnknown *) DDraw2);
234 ok(ref == 1, "IDirectDraw2 reference count is %ld\n", ref);
235 ref = getRefcount( (IUnknown *) DDraw1);
236 ok(ref == 1, "IDirectDraw reference count is %ld\n", ref);
238 hr = IDirectDraw7_QueryInterface(DDraw7, &IID_IDirect3D7, (void **) &D3D7);
239 ok(hr == DD_OK || hr == E_NOINTERFACE, /* win64 */
240 "IDirectDraw7_QueryInterface returned %08x\n", hr);
241 if (FAILED(hr))
243 IDirectDraw7_Release(DDraw7);
244 IDirectDraw4_Release(DDraw4);
245 IDirectDraw2_Release(DDraw2);
246 IDirectDraw_Release(DDraw1);
247 skip( "no IDirect3D7 support\n" );
248 return;
251 /* Apparently IDirectDrawX and IDirect3DX are linked together */
252 ref = getRefcount( (IUnknown *) D3D7);
253 ok(ref == 2, "IDirect3D7 reference count is %ld\n", ref);
254 ref = getRefcount( (IUnknown *) DDraw7);
255 ok(ref == 2, "IDirectDraw7 reference count is %ld\n", ref);
257 IDirectDraw7_AddRef(DDraw7);
258 ref = getRefcount( (IUnknown *) D3D7);
259 ok(ref == 3, "IDirect3D7 reference count is %ld\n", ref);
260 ref = getRefcount( (IUnknown *) DDraw7);
261 ok(ref == 3, "IDirectDraw7 reference count is %ld\n", ref);
263 IDirect3D7_Release(D3D7);
264 ref = getRefcount( (IUnknown *) D3D7);
265 ok(ref == 2, "IDirect3D7 reference count is %ld\n", ref);
266 ref = getRefcount( (IUnknown *) DDraw7);
267 ok(ref == 2, "IDirectDraw7 reference count is %ld\n", ref);
269 /* Can't get older d3d interfaces. WHY????? */
270 hr = IDirectDraw7_QueryInterface(DDraw7, &IID_IDirect3D3, (void **) &D3D3);
271 todo_wine ok(hr == E_NOINTERFACE, "IDirectDraw7_QueryInterface returned %08x\n", hr);
272 if(hr == DD_OK && D3D3) IDirect3D3_Release(D3D3);
274 hr = IDirectDraw4_QueryInterface(DDraw4, &IID_IDirect3D3, (void **) &D3D3);
275 todo_wine ok(hr == E_NOINTERFACE, "IDirectDraw4_QueryInterface returned %08x\n", hr);
276 if(hr == DD_OK && D3D3) IDirect3D3_Release(D3D3);
278 hr = IDirectDraw7_QueryInterface(DDraw7, &IID_IDirect3D2, (void **) &D3D2);
279 todo_wine ok(hr == E_NOINTERFACE, "IDirectDraw7_QueryInterface returned %08x\n", hr);
280 if(hr == DD_OK && D3D2) IDirect3D2_Release(D3D2);
282 hr = IDirectDraw2_QueryInterface(DDraw2, &IID_IDirect3D2, (void **) &D3D2);
283 todo_wine ok(hr == E_NOINTERFACE, "IDirectDraw2_QueryInterface returned %08x\n", hr);
284 if(hr == DD_OK && D3D2) IDirect3D2_Release(D3D2);
286 hr = IDirectDraw7_QueryInterface(DDraw7, &IID_IDirect3D, (void **) &D3D1);
287 todo_wine ok(hr == E_NOINTERFACE, "IDirectDraw7_QueryInterface returned %08x\n", hr);
288 if(hr == DD_OK && D3D1) IDirect3D_Release(D3D1);
290 hr = IDirectDraw_QueryInterface(DDraw1, &IID_IDirect3D, (void **) &D3D1);
291 todo_wine ok(hr == E_NOINTERFACE, "IDirectDraw_QueryInterface returned %08x\n", hr);
292 if(hr == DD_OK && D3D1) IDirect3D_Release(D3D1);
294 hr = IDirect3D7_QueryInterface(D3D7, &IID_IDirect3D, (void **) &D3D1);
295 todo_wine ok(hr == E_NOINTERFACE, "IDirect3D7_QueryInterface returned %08x\n", hr);
296 if(hr == DD_OK && D3D1) IDirect3D_Release(D3D1);
298 /* Try an AddRef, it only affects the AddRefed interface */
299 IDirectDraw4_AddRef(DDraw4);
300 ref = getRefcount( (IUnknown *) DDraw7);
301 ok(ref == 2, "IDirectDraw7 reference count is %ld\n", ref); /* <-- From the d3d query */
302 ref = getRefcount( (IUnknown *) DDraw4);
303 ok(ref == 2, "IDirectDraw4 reference count is %ld\n", ref); /* <-- The AddRef call */
304 ref = getRefcount( (IUnknown *) DDraw2);
305 ok(ref == 1, "IDirectDraw2 reference count is %ld\n", ref);
306 ref = getRefcount( (IUnknown *) DDraw1);
307 ok(ref == 1, "IDirectDraw reference count is %ld\n", ref);
308 ref = getRefcount( (IUnknown *) D3D7);
309 ok(ref == 2, "IDirect3D7 reference count is %ld\n", ref); /* <-- From the d3d query */
310 IDirectDraw4_Release(DDraw4);
312 /* Make sure that they are one object, not different ones */
313 hr = IDirectDraw4_SetCooperativeLevel(DDraw4, GetDesktopWindow(), DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
314 ok(hr == DD_OK, "IDirectDraw4::SetCooperativeLevel returned %08x\n", hr);
315 /* After an window has been set, DDSCL_SETFOCUSWINDOW should return DDERR_HWNDALREADYSET, see the mode test */
316 hr = IDirectDraw7_SetCooperativeLevel(DDraw7, NULL, DDSCL_SETFOCUSWINDOW);
317 ok(hr == DDERR_HWNDALREADYSET, "IDirectDraw7::SetCooperativeLevel returned %08x\n", hr);
319 /* All done, release all interfaces */
320 IDirectDraw7_Release(DDraw7);
321 IDirectDraw4_Release(DDraw4);
322 IDirectDraw2_Release(DDraw2);
323 IDirectDraw_Release(DDraw1);
324 IDirect3D7_Release(D3D7);
327 static void test_d3d_ifaces(void)
329 IDirectDraw *DDraw1;
330 IDirectDraw2 *DDraw2;
331 IDirectDraw4 *DDraw4;
332 IDirect3D *D3D1;
333 IDirect3D2 *D3D2;
334 IDirect3D3 *D3D3;
335 IDirect3D7 *D3D7;
336 HRESULT hr;
337 long ref;
339 hr = DirectDrawCreate(NULL, &DDraw1, NULL);
340 ok(hr == DD_OK || hr==DDERR_NODIRECTDRAWSUPPORT, "DirectDrawCreateEx returned: %x\n", hr);
341 if(!DDraw1)
343 trace("DirectDrawCreate failed with %08x\n", hr);
344 return;
347 hr = IDirectDraw_QueryInterface(DDraw1, &IID_IDirectDraw2, (void **) &DDraw2);
348 ok(hr == DD_OK, "IDirectDraw_QueryInterface returned %08x\n", hr);
349 hr = IDirectDraw_QueryInterface(DDraw1, &IID_IDirectDraw4, (void **) &DDraw4);
350 ok(hr == DD_OK, "IDirectDraw_QueryInterface returned %08x\n", hr);
352 ref = getRefcount( (IUnknown *) DDraw4);
353 ok(ref == 1, "IDirectDraw4 reference count is %ld\n", ref);
354 ref = getRefcount( (IUnknown *) DDraw2);
355 ok(ref == 1, "IDirectDraw2 reference count is %ld\n", ref);
356 ref = getRefcount( (IUnknown *) DDraw1);
357 ok(ref == 1, "IDirectDraw reference count is %ld\n", ref);
359 /* FIXME: This test suggests that IDirect3D, IDirect3D2 and IDirect3D3 are linked
360 * to IDirectDraw. However, they are linked to whatever interface is used to QI the
361 * first IDirect3D? interface. If DDraw1 is replaced with DDraw4 here the tests break */
362 hr = IDirectDraw_QueryInterface(DDraw1, &IID_IDirect3D, (void **) &D3D1);
363 if (hr == E_NOINTERFACE) /* win64 */
365 IDirectDraw4_Release(DDraw4);
366 IDirectDraw2_Release(DDraw2);
367 IDirectDraw_Release(DDraw1);
368 skip( "no IDirect3D support\n" );
369 return;
371 ok(hr == DD_OK, "IDirectDraw_QueryInterface returned %08x\n", hr);
372 ref = getRefcount( (IUnknown *) DDraw4);
373 ok(ref == 1, "IDirectDraw4 reference count is %ld\n", ref);
374 ref = getRefcount( (IUnknown *) DDraw2);
375 ok(ref == 1, "IDirectDraw2 reference count is %ld\n", ref);
376 ref = getRefcount( (IUnknown *) DDraw1);
377 ok(ref == 2, "IDirectDraw reference count is %ld\n", ref);
378 IDirect3D_Release(D3D1);
380 hr = IDirectDraw2_QueryInterface(DDraw2, &IID_IDirect3D2, (void **) &D3D2);
381 ok(hr == DD_OK, "IDirectDraw_QueryInterface returned %08x\n", hr);
382 ref = getRefcount( (IUnknown *) DDraw4);
383 ok(ref == 1, "IDirectDraw4 reference count is %ld\n", ref);
384 ref = getRefcount( (IUnknown *) DDraw2);
385 ok(ref == 1, "IDirectDraw2 reference count is %ld\n", ref);
386 ref = getRefcount( (IUnknown *) DDraw1);
387 ok(ref == 2, "IDirectDraw reference count is %ld\n", ref);
388 IDirect3D2_Release(D3D2);
390 hr = IDirectDraw4_QueryInterface(DDraw4, &IID_IDirect3D3, (void **) &D3D3);
391 ok(hr == DD_OK, "IDirectDraw_QueryInterface returned %08x\n", hr);
392 ref = getRefcount( (IUnknown *) DDraw4);
393 ok(ref == 1, "IDirectDraw4 reference count is %ld\n", ref);
394 ref = getRefcount( (IUnknown *) DDraw2);
395 ok(ref == 1, "IDirectDraw2 reference count is %ld\n", ref);
396 ref = getRefcount( (IUnknown *) DDraw1);
397 ok(ref == 2, "IDirectDraw reference count is %ld\n", ref);
398 IDirect3D3_Release(D3D3);
400 /* Try to AddRef the D3D3 interface that has been released already */
401 IDirect3D3_AddRef(D3D3);
402 ref = getRefcount( (IUnknown *) DDraw1);
403 ok(ref == 2, "IDirectDraw reference count is %ld\n", ref);
404 ref = getRefcount( (IUnknown *) D3D3);
405 ok(ref == 2, "IDirect3D3 reference count is %ld\n", ref);
406 /* The newer interfaces remain untouched */
407 ref = getRefcount( (IUnknown *) DDraw4);
408 ok(ref == 1, "IDirectDraw4 reference count is %ld\n", ref);
409 ref = getRefcount( (IUnknown *) DDraw2);
410 ok(ref == 1, "IDirectDraw2 reference count is %ld\n", ref);
411 IDirect3D3_Release(D3D3);
412 ref = getRefcount( (IUnknown *) DDraw1);
413 ok(ref == 1, "IDirectDraw reference count is %ld\n", ref);
414 ref = getRefcount( (IUnknown *) DDraw1);
415 ok(ref == 1, "IDirectDraw reference count is %ld\n", ref);
417 /* It is possible to query any IDirect3D interfaces from any IDirectDraw interface,
418 * Except IDirect3D7, it can only be returned by IDirectDraw7(which can't return older ifaces)
420 hr = IDirectDraw_QueryInterface(DDraw2, &IID_IDirect3D, (void **) &D3D1);
421 ok(hr == DD_OK, "IDirectDraw2_QueryInterface returned %08x\n", hr);
422 IDirect3D_Release(D3D1);
423 hr = IDirectDraw4_QueryInterface(DDraw4, &IID_IDirect3D, (void **) &D3D1);
424 ok(hr == DD_OK, "IDirectDraw4_QueryInterface returned %08x\n", hr);
425 IDirect3D_Release(D3D1);
427 hr = IDirectDraw_QueryInterface(DDraw1, &IID_IDirect3D2, (void **) &D3D2);
428 ok(hr == DD_OK, "IDirectDraw_QueryInterface returned %08x\n", hr);
429 IDirect3D_Release(D3D2);
430 hr = IDirectDraw4_QueryInterface(DDraw4, &IID_IDirect3D2, (void **) &D3D2);
431 ok(hr == DD_OK, "IDirectDraw4_QueryInterface returned %08x\n", hr);
432 IDirect3D_Release(D3D2);
434 hr = IDirectDraw_QueryInterface(DDraw1, &IID_IDirect3D3, (void **) &D3D3);
435 ok(hr == DD_OK, "IDirectDraw_QueryInterface returned %08x\n", hr);
436 IDirect3D_Release(D3D3);
437 hr = IDirectDraw2_QueryInterface(DDraw2, &IID_IDirect3D3, (void **) &D3D3);
438 ok(hr == DD_OK, "IDirectDraw2_QueryInterface returned %08x\n", hr);
439 IDirect3D_Release(D3D3);
441 /* This does NOT work */
442 hr = IDirectDraw_QueryInterface(DDraw1, &IID_IDirect3D7, (void **) &D3D7);
443 todo_wine ok(hr == E_NOINTERFACE, "IDirectDraw_QueryInterface returned %08x\n", hr);
444 if(D3D7) IDirect3D_Release(D3D7);
445 hr = IDirectDraw2_QueryInterface(DDraw2, &IID_IDirect3D7, (void **) &D3D7);
446 todo_wine ok(hr == E_NOINTERFACE, "IDirectDraw2_QueryInterface returned %08x\n", hr);
447 if(D3D7) IDirect3D_Release(D3D7);
448 hr = IDirectDraw4_QueryInterface(DDraw4, &IID_IDirect3D7, (void **) &D3D7);
449 todo_wine ok(hr == E_NOINTERFACE, "IDirectDraw4_QueryInterface returned %08x\n", hr);
450 if(D3D7) IDirect3D_Release(D3D7);
452 /* Release the interfaces */
453 IDirectDraw4_Release(DDraw4);
454 IDirectDraw2_Release(DDraw2);
455 IDirectDraw_Release(DDraw1);
458 START_TEST(refcount)
460 init_function_pointers();
461 if(!pDirectDrawCreateEx)
463 win_skip("function DirectDrawCreateEx not available\n");
464 return;
466 test_ddraw_objects();
467 test_iface_refcnt();
468 test_d3d_ifaces();