comctl32/trackbar: Fix tic count calculation.
[wine] / dlls / d3dx9_36 / tests / texture.c
1 /*
2  * Tests for the D3DX9 texture functions
3  *
4  * Copyright 2009 Tony Wasserka
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 #include "wine/test.h"
23 #include "d3dx9tex.h"
24 #include "resources.h"
25
26 static inline int get_ref(IUnknown *obj)
27 {
28     IUnknown_AddRef(obj);
29     return IUnknown_Release(obj);
30 }
31
32 static inline void check_ref(IUnknown *obj, int exp)
33 {
34     int ref = get_ref(obj);
35     ok (exp == ref, "Invalid refcount. Expected %d, got %d\n", exp, ref);
36 }
37
38 static inline void check_release(IUnknown *obj, int exp)
39 {
40     int ref = IUnknown_Release(obj);
41     ok (ref == exp, "Invalid refcount. Expected %d, got %d\n", exp, ref);
42 }
43
44 /* 1x1 bmp (1 bpp) */
45 static const unsigned char bmp01[66] = {
46 0x42,0x4d,0x42,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3e,0x00,0x00,0x00,0x28,0x00,
47 0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x00,
48 0x00,0x00,0x04,0x00,0x00,0x00,0x12,0x0b,0x00,0x00,0x12,0x0b,0x00,0x00,0x02,0x00,
49 0x00,0x00,0x02,0x00,0x00,0x00,0xff,0xff,0xff,0x00,0xff,0xff,0xff,0x00,0x00,0x00,
50 0x00,0x00
51 };
52
53 /* 2x2 A8R8G8B8 pixel data */
54 static const unsigned char pixdata[] = {
55 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
56 };
57
58 /* invalid image file */
59 static const unsigned char noimage[4] = {
60 0x11,0x22,0x33,0x44
61 };
62
63 static HRESULT create_file(const char *filename, const unsigned char *data, const unsigned int size)
64 {
65     DWORD received;
66     HANDLE hfile;
67
68     hfile = CreateFileA(filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
69     if(hfile == INVALID_HANDLE_VALUE) return HRESULT_FROM_WIN32(GetLastError());
70
71     if(WriteFile(hfile, data, size, &received, NULL))
72     {
73         CloseHandle(hfile);
74         return D3D_OK;
75     }
76
77     CloseHandle(hfile);
78     return D3DERR_INVALIDCALL;
79 }
80
81 static void test_D3DXGetImageInfo()
82 {
83     HRESULT hr;
84     D3DXIMAGE_INFO info;
85     BOOL testdummy_ok, testbitmap_ok;
86
87     hr = create_file("testdummy.bmp", noimage, sizeof(noimage));  /* invalid image */
88     testdummy_ok = SUCCEEDED(hr);
89
90     hr = create_file("testbitmap.bmp", bmp01, sizeof(bmp01));  /* valid image */
91     testbitmap_ok = SUCCEEDED(hr);
92
93     /* D3DXGetImageInfoFromFile */
94     if(testbitmap_ok) {
95         todo_wine {
96             hr = D3DXGetImageInfoFromFileA("testbitmap.bmp", &info);
97             ok(hr == D3D_OK, "D3DXGetImageInfoFromFile returned %#x, expected %#x\n", hr, D3D_OK);
98         }
99
100         hr = D3DXGetImageInfoFromFileA("testbitmap.bmp", NULL); /* valid image, second parameter is NULL */
101         ok(hr == D3D_OK, "D3DXGetImageInfoFromFile returned %#x, expected %#x\n", hr, D3D_OK);
102     } else skip("Couldn't create \"testbitmap.bmp\"\n");
103
104     if(testdummy_ok) {
105         hr = D3DXGetImageInfoFromFileA("testdummy.bmp", NULL); /* invalid image, second parameter is NULL */
106         ok(hr == D3D_OK, "D3DXGetImageInfoFromFile returned %#x, expected %#x\n", hr, D3D_OK);
107
108         todo_wine {
109             hr = D3DXGetImageInfoFromFileA("testdummy.bmp", &info);
110             ok(hr == D3DXERR_INVALIDDATA, "D3DXGetImageInfoFromFile returned %#x, expected %#x\n", hr, D3DXERR_INVALIDDATA);
111         }
112     } else skip("Couldn't create \"testdummy.bmp\"\n");
113
114     hr = D3DXGetImageInfoFromFileA("filedoesnotexist.bmp", &info);
115     ok(hr == D3DXERR_INVALIDDATA, "D3DXGetImageInfoFromFile returned %#x, expected %#x\n", hr, D3DXERR_INVALIDDATA);
116
117     hr = D3DXGetImageInfoFromFileA("filedoesnotexist.bmp", NULL);
118     ok(hr == D3DXERR_INVALIDDATA, "D3DXGetImageInfoFromFile returned %#x, expected %#x\n", hr, D3DXERR_INVALIDDATA);
119
120     hr = D3DXGetImageInfoFromFileA("", &info);
121     ok(hr == D3DXERR_INVALIDDATA, "D3DXGetImageInfoFromFile returned %#x, expected %#x\n", hr, D3DXERR_INVALIDDATA);
122
123     hr = D3DXGetImageInfoFromFileA(NULL, &info);
124     ok(hr == D3DERR_INVALIDCALL, "D3DXGetImageInfoFromFile returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
125
126     hr = D3DXGetImageInfoFromFileA(NULL, NULL);
127     ok(hr == D3DERR_INVALIDCALL, "D3DXGetImageInfoFromFile returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
128
129
130     /* D3DXGetImageInfoFromResource */
131     todo_wine {
132         hr = D3DXGetImageInfoFromResourceA(NULL, MAKEINTRESOURCEA(IDB_BITMAP_1x1), &info); /* RT_BITMAP */
133         ok(hr == D3D_OK, "D3DXGetImageInfoFromResource returned %#x, expected %#x\n", hr, D3D_OK);
134
135         hr = D3DXGetImageInfoFromResourceA(NULL, MAKEINTRESOURCEA(IDB_BITMAP_1x1), NULL);
136         ok(hr == D3D_OK, "D3DXGetImageInfoFromResource returned %#x, expected %#x\n", hr, D3D_OK);
137
138         hr = D3DXGetImageInfoFromResourceA(NULL, MAKEINTRESOURCEA(IDD_BITMAPDATA_1x1), &info); /* RT_RCDATA */
139         ok(hr == D3D_OK, "D3DXGetImageInfoFromResource returned %#x, expected %#x\n", hr, D3D_OK);
140     }
141
142     hr = D3DXGetImageInfoFromResourceA(NULL, MAKEINTRESOURCEA(IDS_STRING), &info);
143     ok(hr == D3DXERR_INVALIDDATA, "D3DXGetImageInfoFromResource returned %#x, expected %#x\n", hr, D3DXERR_INVALIDDATA);
144
145     hr = D3DXGetImageInfoFromResourceA(NULL, MAKEINTRESOURCEA(IDS_STRING), NULL);
146     ok(hr == D3DXERR_INVALIDDATA, "D3DXGetImageInfoFromResource returned %#x, expected %#x\n", hr, D3DXERR_INVALIDDATA);
147
148     hr = D3DXGetImageInfoFromResourceA(NULL, "resourcedoesnotexist", &info);
149     ok(hr == D3DXERR_INVALIDDATA, "D3DXGetImageInfoFromResource returned %#x, expected %#x\n", hr, D3DXERR_INVALIDDATA);
150
151     hr = D3DXGetImageInfoFromResourceA(NULL, "resourcedoesnotexist", NULL);
152     ok(hr == D3DXERR_INVALIDDATA, "D3DXGetImageInfoFromResource returned %#x, expected %#x\n", hr, D3DXERR_INVALIDDATA);
153
154     hr = D3DXGetImageInfoFromResourceA(NULL, NULL, NULL);
155     ok(hr == D3DXERR_INVALIDDATA, "D3DXGetImageInfoFromResource returned %#x, expected %#x\n", hr, D3DXERR_INVALIDDATA);
156
157
158     /* D3DXGetImageInfoFromFileInMemory */
159     todo_wine {
160         hr = D3DXGetImageInfoFromFileInMemory(bmp01, sizeof(bmp01), &info);
161         ok(hr == D3D_OK, "D3DXGetImageInfoFromFileInMemory returned %#x, expected %#x\n", hr, D3D_OK);
162
163         hr = D3DXGetImageInfoFromFileInMemory(bmp01, sizeof(bmp01)+5, &info); /* too large size */
164         ok(hr == D3D_OK, "D3DXGetImageInfoFromFileInMemory returned %#x, expected %#x\n", hr, D3D_OK);
165     }
166
167     hr = D3DXGetImageInfoFromFileInMemory(bmp01, sizeof(bmp01), NULL);
168     ok(hr == D3D_OK, "D3DXGetImageInfoFromFileInMemory returned %#x, expected %#x\n", hr, D3D_OK);
169
170     hr = D3DXGetImageInfoFromFileInMemory(noimage, sizeof(noimage), NULL);
171     ok(hr == D3D_OK, "D3DXGetImageInfoFromResource returned %#x, expected %#x\n", hr, D3D_OK);
172
173     todo_wine {
174         hr = D3DXGetImageInfoFromFileInMemory(noimage, sizeof(noimage), &info);
175         ok(hr == D3DXERR_INVALIDDATA, "D3DXGetImageInfoFromFileInMemory returned %#x, expected %#x\n", hr, D3DXERR_INVALIDDATA);
176
177         hr = D3DXGetImageInfoFromFileInMemory(bmp01, sizeof(bmp01)-1, &info);
178         ok(hr == D3DXERR_INVALIDDATA, "D3DXGetImageInfoFromFileInMemory returned %#x, expected %#x\n", hr, D3DXERR_INVALIDDATA);
179
180         hr = D3DXGetImageInfoFromFileInMemory(bmp01+1, sizeof(bmp01)-1, &info);
181         ok(hr == D3DXERR_INVALIDDATA, "D3DXGetImageInfoFromFileInMemory returned %#x, expected %#x\n", hr, D3DXERR_INVALIDDATA);
182     }
183
184     hr = D3DXGetImageInfoFromFileInMemory(bmp01, 0, &info);
185     ok(hr == D3DERR_INVALIDCALL, "D3DXGetImageInfoFromFileInMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
186
187     hr = D3DXGetImageInfoFromFileInMemory(bmp01, 0, NULL);
188     ok(hr == D3DERR_INVALIDCALL, "D3DXGetImageInfoFromFileInMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
189
190     hr = D3DXGetImageInfoFromFileInMemory(noimage, 0, &info);
191     ok(hr == D3DERR_INVALIDCALL, "D3DXGetImageInfoFromFileInMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
192
193     hr = D3DXGetImageInfoFromFileInMemory(noimage, 0, NULL);
194     ok(hr == D3DERR_INVALIDCALL, "D3DXGetImageInfoFromFileInMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
195
196     hr = D3DXGetImageInfoFromFileInMemory(NULL, 0, &info);
197     ok(hr == D3DERR_INVALIDCALL, "D3DXGetImageInfoFromFileInMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
198
199     hr = D3DXGetImageInfoFromFileInMemory(NULL, 4, NULL);
200     ok(hr == D3DERR_INVALIDCALL, "D3DXGetImageInfoFromFileInMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
201
202     hr = D3DXGetImageInfoFromFileInMemory(NULL, 4, &info);
203     ok(hr == D3DERR_INVALIDCALL, "D3DXGetImageInfoFromFileInMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
204
205     hr = D3DXGetImageInfoFromFileInMemory(NULL, 0, NULL);
206     ok(hr == D3DERR_INVALIDCALL, "D3DXGetImageInfoFromFileInMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
207
208     /* cleanup */
209     if(testdummy_ok) DeleteFileA("testdummy.bmp");
210     if(testbitmap_ok) DeleteFileA("testbitmap.bmp");
211 }
212
213 static void test_D3DXLoadSurface(IDirect3DDevice9 *device)
214 {
215     HRESULT hr;
216     BOOL testdummy_ok, testbitmap_ok;
217     IDirect3DSurface9 *surf, *newsurf;
218     RECT rect;
219
220     hr = create_file("testdummy.bmp", noimage, sizeof(noimage));  /* invalid image */
221     testdummy_ok = SUCCEEDED(hr);
222
223     hr = create_file("testbitmap.bmp", bmp01, sizeof(bmp01));  /* valid image */
224     testbitmap_ok = SUCCEEDED(hr);
225
226     hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 256, 256, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &surf, NULL);
227     if(FAILED(hr)) {
228         skip("Failed to create a surface (%#x)\n", hr);
229         if(testdummy_ok) DeleteFileA("testdummy.bmp");
230         if(testbitmap_ok) DeleteFileA("testbitmap.bmp");
231         return;
232     }
233
234     /* D3DXLoadSurfaceFromFile */
235     if(testbitmap_ok) {
236         todo_wine {
237             hr = D3DXLoadSurfaceFromFileA(surf, NULL, NULL, "testbitmap.bmp", NULL, D3DX_DEFAULT, 0, NULL);
238             ok(hr == D3D_OK, "D3DXLoadSurfaceFromFile returned %#x, expected %#x\n", hr, D3D_OK);
239         }
240
241         hr = D3DXLoadSurfaceFromFileA(NULL, NULL, NULL, "testbitmap.bmp", NULL, D3DX_DEFAULT, 0, NULL);
242         ok(hr == D3DERR_INVALIDCALL, "D3DXLoadSurfaceFromFile returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
243     } else skip("Couldn't create \"testbitmap.bmp\"\n");
244
245     if(testdummy_ok) {
246         todo_wine {
247             hr = D3DXLoadSurfaceFromFileA(surf, NULL, NULL, "testdummy.bmp", NULL, D3DX_DEFAULT, 0, NULL);
248             ok(hr == D3DXERR_INVALIDDATA, "D3DXLoadSurfaceFromFile returned %#x, expected %#x\n", hr, D3DXERR_INVALIDDATA);
249         }
250     } else skip("Couldn't create \"testdummy.bmp\"\n");
251
252     hr = D3DXLoadSurfaceFromFileA(surf, NULL, NULL, NULL, NULL, D3DX_DEFAULT, 0, NULL);
253     ok(hr == D3DERR_INVALIDCALL, "D3DXLoadSurfaceFromFile returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
254
255     hr = D3DXLoadSurfaceFromFileA(surf, NULL, NULL, "", NULL, D3DX_DEFAULT, 0, NULL);
256     ok(hr == D3DXERR_INVALIDDATA, "D3DXLoadSurfaceFromFile returned %#x, expected %#x\n", hr, D3DXERR_INVALIDDATA);
257
258
259     /* D3DXLoadSurfaceFromResource */
260     todo_wine {
261         hr = D3DXLoadSurfaceFromResourceA(surf, NULL, NULL, NULL, MAKEINTRESOURCE(IDB_BITMAP_1x1), NULL, D3DX_DEFAULT, 0, NULL);
262         ok(hr == D3D_OK, "D3DXLoadSurfaceFromResource returned %#x, expected %#x\n", hr, D3D_OK);
263
264         hr = D3DXLoadSurfaceFromResourceA(surf, NULL, NULL, NULL, MAKEINTRESOURCE(IDD_BITMAPDATA_1x1), NULL, D3DX_DEFAULT, 0, NULL);
265         ok(hr == D3D_OK, "D3DXLoadSurfaceFromResource returned %#x, expected %#x\n", hr, D3D_OK);
266     }
267
268     hr = D3DXLoadSurfaceFromResourceA(surf, NULL, NULL, NULL, NULL, NULL, D3DX_DEFAULT, 0, NULL);
269     ok(hr == D3DXERR_INVALIDDATA, "D3DXLoadSurfaceFromResource returned %#x, expected %#x\n", hr, D3DXERR_INVALIDDATA);
270
271     hr = D3DXLoadSurfaceFromResourceA(NULL, NULL, NULL, NULL, MAKEINTRESOURCE(IDB_BITMAP_1x1), NULL, D3DX_DEFAULT, 0, NULL);
272     ok(hr == D3DERR_INVALIDCALL, "D3DXLoadSurfaceFromResource returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
273
274     hr = D3DXLoadSurfaceFromResourceA(surf, NULL, NULL, NULL, MAKEINTRESOURCE(IDS_STRING), NULL, D3DX_DEFAULT, 0, NULL);
275     ok(hr == D3DXERR_INVALIDDATA, "D3DXLoadSurfaceFromResource returned %#x, expected %#x\n", hr, D3DXERR_INVALIDDATA);
276
277
278     /* D3DXLoadSurfaceFromFileInMemory */
279     todo_wine {
280         hr = D3DXLoadSurfaceFromFileInMemory(surf, NULL, NULL, bmp01, sizeof(bmp01), NULL, D3DX_DEFAULT, 0, NULL);
281         ok(hr == D3D_OK, "D3DXLoadSurfaceFromFileInMemory returned %#x, expected %#x\n", hr, D3D_OK);
282
283         hr = D3DXLoadSurfaceFromFileInMemory(surf, NULL, NULL, noimage, sizeof(noimage), NULL, D3DX_DEFAULT, 0, NULL);
284         ok(hr == D3DXERR_INVALIDDATA, "D3DXLoadSurfaceFromFileInMemory returned %#x, expected %#x\n", hr, D3DXERR_INVALIDDATA);
285     }
286
287     hr = D3DXLoadSurfaceFromFileInMemory(surf, NULL, NULL, bmp01, 0, NULL, D3DX_DEFAULT, 0, NULL);
288     ok(hr == D3DERR_INVALIDCALL, "D3DXLoadSurfaceFromFileInMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
289
290     hr = D3DXLoadSurfaceFromFileInMemory(NULL, NULL, NULL, bmp01, sizeof(bmp01), NULL, D3DX_DEFAULT, 0, NULL);
291     ok(hr == D3DERR_INVALIDCALL, "D3DXLoadSurfaceFromFileInMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
292
293     hr = D3DXLoadSurfaceFromFileInMemory(surf, NULL, NULL, NULL, 8, NULL, D3DX_DEFAULT, 0, NULL);
294     ok(hr == D3DERR_INVALIDCALL, "D3DXLoadSurfaceFromFileInMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
295
296     hr = D3DXLoadSurfaceFromFileInMemory(surf, NULL, NULL, NULL, 0, NULL, D3DX_DEFAULT, 0, NULL);
297     ok(hr == D3DERR_INVALIDCALL, "D3DXLoadSurfaceFromFileInMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
298
299     hr = D3DXLoadSurfaceFromFileInMemory(NULL, NULL, NULL, NULL, 0, NULL, D3DX_DEFAULT, 0, NULL);
300     ok(hr == D3DERR_INVALIDCALL, "D3DXLoadSurfaceFromFileInMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
301
302
303     /* D3DXLoadSurfaceFromMemory */
304     SetRect(&rect, 0, 0, 2, 2);
305
306     todo_wine {
307         hr = D3DXLoadSurfaceFromMemory(surf, NULL, NULL, pixdata, D3DFMT_A8R8G8B8, sizeof(pixdata), NULL, &rect, D3DX_DEFAULT, 0);
308         ok(hr == D3D_OK, "D3DXLoadSurfaceFromMemory returned %#x, expected %#x\n", hr, D3D_OK);
309
310         hr = D3DXLoadSurfaceFromMemory(surf, NULL, NULL, pixdata, D3DFMT_A8R8G8B8, 0, NULL, &rect, D3DX_DEFAULT, 0);
311         ok(hr == D3D_OK, "D3DXLoadSurfaceFromMemory returned %#x, expected %#x\n", hr, D3D_OK);
312     }
313
314     hr = D3DXLoadSurfaceFromMemory(surf, NULL, NULL, NULL, D3DFMT_A8R8G8B8, sizeof(pixdata), NULL, &rect, D3DX_DEFAULT, 0);
315     ok(hr == D3DERR_INVALIDCALL, "D3DXLoadSurfaceFromMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
316
317     hr = D3DXLoadSurfaceFromMemory(NULL, NULL, NULL, pixdata, D3DFMT_A8R8G8B8, sizeof(pixdata), NULL, &rect, D3DX_DEFAULT, 0);
318     ok(hr == D3DERR_INVALIDCALL, "D3DXLoadSurfaceFromMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
319
320     hr = D3DXLoadSurfaceFromMemory(surf, NULL, NULL, pixdata, D3DFMT_A8R8G8B8, sizeof(pixdata), NULL, NULL, D3DX_DEFAULT, 0);
321     ok(hr == D3DERR_INVALIDCALL, "D3DXLoadSurfaceFromMemory returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
322
323     hr = D3DXLoadSurfaceFromMemory(surf, NULL, NULL, pixdata, D3DFMT_UNKNOWN, sizeof(pixdata), NULL, &rect, D3DX_DEFAULT, 0);
324     ok(hr == E_FAIL, "D3DXLoadSurfaceFromMemory returned %#x, expected %#x\n", hr, E_FAIL);
325
326
327     /* D3DXLoadSurfaceFromSurface */
328     hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 256, 256, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &newsurf, NULL);
329     if(SUCCEEDED(hr)) {
330         todo_wine {
331             hr = D3DXLoadSurfaceFromSurface(newsurf, NULL, NULL, surf, NULL, NULL, D3DX_DEFAULT, 0);
332             ok(hr == D3D_OK, "D3DXLoadSurfaceFromSurface returned %#x, expected %#x\n", hr, D3D_OK);
333         }
334
335         hr = D3DXLoadSurfaceFromSurface(NULL, NULL, NULL, surf, NULL, NULL, D3DX_DEFAULT, 0);
336         ok(hr == D3DERR_INVALIDCALL, "D3DXLoadSurfaceFromSurface returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
337
338         hr = D3DXLoadSurfaceFromSurface(newsurf, NULL, NULL, NULL, NULL, NULL, D3DX_DEFAULT, 0);
339         ok(hr == D3DERR_INVALIDCALL, "D3DXLoadSurfaceFromSurface returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
340     } else skip("Failed to create a second surface\n");
341     check_release((IUnknown*)newsurf, 0);
342
343
344     /* cleanup */
345     check_release((IUnknown*)surf, 0);
346
347     if(testdummy_ok) DeleteFileA("testdummy.bmp");
348     if(testbitmap_ok) DeleteFileA("testbitmap.bmp");
349 }
350
351 START_TEST(texture)
352 {
353     HWND wnd;
354     IDirect3D9 *d3d;
355     IDirect3DDevice9 *device;
356     D3DPRESENT_PARAMETERS d3dpp;
357     HRESULT hr;
358
359     wnd = CreateWindow("static", "d3dx9_test", 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL);
360     d3d = Direct3DCreate9(D3D_SDK_VERSION);
361     if (!wnd) {
362         skip("Couldn't create application window\n");
363         return;
364     }
365     if (!d3d) {
366         skip("Couldn't create IDirect3D9 object\n");
367         DestroyWindow(wnd);
368         return;
369     }
370
371     ZeroMemory(&d3dpp, sizeof(d3dpp));
372     d3dpp.Windowed   = TRUE;
373     d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
374     hr = IDirect3D9_CreateDevice(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, wnd, D3DCREATE_MIXED_VERTEXPROCESSING, &d3dpp, &device);
375     if(FAILED(hr)) {
376         skip("Failed to create IDirect3DDevice9 object %#x\n", hr);
377         IDirect3D9_Release(d3d);
378         DestroyWindow(wnd);
379         return;
380     }
381
382     test_D3DXGetImageInfo();
383     test_D3DXLoadSurface(device);
384
385     check_release((IUnknown*)device, 0);
386     check_release((IUnknown*)d3d, 0);
387     if (wnd) DestroyWindow(wnd);
388 }