d3d11: Use wined3d_device_context_dispatch_indirect().
[wine/zf.git] / dlls / ddrawex / tests / ddrawex.c
blob60d84fe991b1cb662857d7904ebc3a77ca328d68
1 /*
2 * Unit tests for ddrawex specific things
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18 #define COBJMACROS
20 #include "wine/test.h"
21 #include "windef.h"
22 #include "winbase.h"
23 #include "ddraw.h"
24 #include "ddrawex.h"
25 #include "unknwn.h"
27 static IDirectDrawFactory *factory;
28 static HRESULT (WINAPI *pDllGetClassObject)(REFCLSID rclsid, REFIID riid, void **out);
30 static IDirectDraw *createDDraw(void)
32 HRESULT hr;
33 IDirectDraw *dd;
35 hr = IDirectDrawFactory_CreateDirectDraw(factory, NULL, NULL, DDSCL_NORMAL, 0,
36 0, &dd);
37 ok(hr == DD_OK, "Failed to create an IDirectDraw interface, hr = 0x%08x\n", hr);
38 return SUCCEEDED(hr) ? dd : NULL;
41 static ULONG get_ref(IUnknown *o)
43 IUnknown_AddRef(o);
44 return IUnknown_Release(o);
47 static void RefCountTest(void)
49 IDirectDraw *dd1 = createDDraw();
50 IDirectDraw2 *dd2;
51 IDirectDraw3 *dd3;
52 IDirectDraw4 *dd4;
53 HRESULT hr;
54 ULONG ref;
56 ref = get_ref((IUnknown *) dd1);
57 ok(ref == 1, "A new ddraw object's refcount is %u, expected 1\n", ref);
59 IDirectDraw_AddRef(dd1);
60 ref = get_ref((IUnknown *) dd1);
61 if (ref == 1)
63 win_skip("Refcounting is broken\n");
64 IDirectDraw_Release(dd1);
65 return;
67 ok(ref == 2, "After AddRef the refcount is %u, expected 2\n", ref);
68 IDirectDraw_Release(dd1);
69 ref = get_ref((IUnknown *) dd1);
70 ok(ref == 1, "After Release the refcount is %u, expected 1\n", ref);
72 IDirectDraw_QueryInterface(dd1, &IID_IDirectDraw2, (void **) &dd2);
73 ref = get_ref((IUnknown *) dd2);
74 ok(ref == 2, "IDirectDraw2 refcount is %u, expected 2\n", ref);
76 IDirectDraw_QueryInterface(dd1, &IID_IDirectDraw3, (void **) &dd3);
77 ref = get_ref((IUnknown *) dd3);
78 ok(ref == 3, "IDirectDraw3 refcount is %u, expected 3\n", ref);
80 hr = IDirectDraw_QueryInterface(dd1, &IID_IDirectDraw4, (void **) &dd4);
81 if (FAILED(hr))
83 win_skip("Failed to query IDirectDraw4\n");
84 IDirectDraw_Release(dd1);
85 IDirectDraw2_Release(dd2);
86 IDirectDraw3_Release(dd3);
87 return;
89 ref = get_ref((IUnknown *) dd4);
90 ok(ref == 4, "IDirectDraw4 refcount is %u, expected 4\n", ref);
92 IDirectDraw_Release(dd1);
93 IDirectDraw2_Release(dd2);
94 IDirectDraw3_Release(dd3);
96 ref = get_ref((IUnknown *) dd4);
97 ok(ref == 1, "IDirectDraw4 refcount is %u, expected 1\n", ref);
99 IDirectDraw4_Release(dd4);
102 START_TEST(ddrawex)
104 IClassFactory *classfactory = NULL;
105 ULONG ref;
106 HRESULT hr;
107 HMODULE hmod = LoadLibraryA("ddrawex.dll");
108 if(hmod == NULL) {
109 skip("Failed to load ddrawex.dll\n");
110 return;
112 pDllGetClassObject = (void*)GetProcAddress(hmod, "DllGetClassObject");
113 if(pDllGetClassObject == NULL) {
114 skip("Failed to get DllGetClassObject\n");
115 return;
118 hr = pDllGetClassObject(&CLSID_DirectDrawFactory, &IID_IClassFactory, (void **) &classfactory);
119 ok(hr == S_OK, "Failed to create a IClassFactory\n");
120 hr = IClassFactory_CreateInstance(classfactory, NULL, &IID_IDirectDrawFactory, (void **) &factory);
121 ok(hr == S_OK, "Failed to create a IDirectDrawFactory\n");
123 RefCountTest();
125 if(factory) {
126 ref = IDirectDrawFactory_Release(factory);
127 ok(ref == 0, "IDirectDrawFactory not cleanly released\n");
129 if(classfactory) {
130 ref = IClassFactory_Release(classfactory);
131 todo_wine ok(ref == 1, "IClassFactory refcount wrong, ref = %u\n", ref);