wintrust: Fix copy-paste error.
[wine] / dlls / d3drm / tests / d3drm.c
1 /*
2  * Copyright 2010 Christian Costa
3  *
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.
8  *
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.
13  *
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
17  */
18
19 #include "d3drm.h"
20
21 #include "wine/test.h"
22
23 static HMODULE d3drm_handle = 0;
24
25 static HRESULT (WINAPI * pDirect3DRMCreate)(LPDIRECT3DRM* ppDirect3DRM);
26
27 #define D3DRM_GET_PROC(func) \
28     p ## func = (void*)GetProcAddress(d3drm_handle, #func); \
29     if(!p ## func) { \
30       trace("GetProcAddress(%s) failed\n", #func); \
31       FreeLibrary(d3drm_handle); \
32       return FALSE; \
33     }
34
35 static BOOL InitFunctionPtrs(void)
36 {
37     d3drm_handle = LoadLibraryA("d3drm.dll");
38
39     if(!d3drm_handle)
40     {
41         skip("Could not load d3drm.dll\n");
42         return FALSE;
43     }
44
45     D3DRM_GET_PROC(Direct3DRMCreate)
46
47     return TRUE;
48 }
49
50 char data_ok[] =
51 "xof 0302txt 0064\n"
52 "Mesh Object\n"
53 "{\n"
54 "0;\n"
55 "0;\n"
56 "}\n";
57
58 char data_bad[] =
59 "xof 0302txt 0064\n"
60 "Header Object\n"
61 "{\n"
62 "1; 2; 3;\n"
63 "}\n";
64
65 void Test(void)
66 {
67     HRESULT hr;
68     LPDIRECT3DRM pD3DRM;
69     LPDIRECT3DRMMESHBUILDER pMeshBuilder;
70     D3DRMLOADMEMORY info;
71
72     hr = pDirect3DRMCreate(&pD3DRM);
73     ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x)\n", hr);
74
75     hr = IDirect3DRM_CreateMeshBuilder(pD3DRM, &pMeshBuilder);
76     ok(hr == D3DRM_OK, "Cannot get IDirect3DRMMeshBuilder interface (hr = %x)\n", hr);
77
78     info.lpMemory = data_bad;
79     info.dSize = sizeof(data_bad);
80     hr = IDirect3DRMMeshBuilder_Load(pMeshBuilder, &info, NULL, D3DRMLOAD_FROMMEMORY, NULL, NULL);
81     ok(hr == D3DRMERR_BADFILE, "Sould have returned D3DRMERR_BADFILE (hr = %x)\n", hr);
82
83     info.lpMemory = data_ok;
84     info.dSize = sizeof(data_ok);
85     hr = IDirect3DRMMeshBuilder_Load(pMeshBuilder, &info, NULL, D3DRMLOAD_FROMMEMORY, NULL, NULL);
86     ok(hr == D3DRM_OK, "Cannot load mesh data (hr = %x)\n", hr);
87
88     IDirect3DRMMeshBuilder_Release(pMeshBuilder);
89
90     IDirect3DRM_Release(pD3DRM);
91 }
92
93 START_TEST(d3drm)
94 {
95     if (!InitFunctionPtrs())
96         return;
97
98     Test();
99
100     FreeLibrary(d3drm_handle);
101 }