ReactOS  0.4.15-dev-321-g2d9b385
xfile.c File Reference
#include <stdio.h>
#include "wine/test.h"
#include "d3dx9.h"
#include "d3dx9xof.h"
Include dependency graph for xfile.c:

Go to the source code of this file.

Functions

static void test_templates (void)
 
static void test_lock_unlock (void)
 
static void test_getname (void)
 
static void test_type_index_color (void)
 
static void process_data (ID3DXFileData *xfile_data, int level)
 
static void test_dump (void)
 
 START_TEST (xfile)
 

Variables

static const char templates_bad_file_type1 []
 
static const char templates_bad_file_version []
 
static const char templates_bad_file_type2 []
 
static const char templates_bad_file_float_size []
 
static const char templates_parse_error []
 
static const char templates []
 
static char objects []
 
static char object_noname []
 
static char template_using_index_color_lower []
 
static char template_using_index_color_upper []
 

Function Documentation

◆ process_data()

static void process_data ( ID3DXFileData *  xfile_data,
int  level 
)
static

Definition at line 247 of file xfile.c.

248 {
249  HRESULT ret;
250  char name[100];
251  GUID clsid;
252  GUID clsid_type;
253  SIZE_T len = sizeof(name);
254  int i;
255  const BYTE *data;
256  SIZE_T size;
257  SIZE_T children;
258 
259  ret = xfile_data->lpVtbl->GetId(xfile_data, &clsid);
260  ok(ret == S_OK, "ID3DXFileData_GetId failed with %#x\n", ret);
261  ret = xfile_data->lpVtbl->GetName(xfile_data, name, &len);
262  ok(ret == S_OK, "ID3DXFileData_GetName failed with %#x\n", ret);
263  ret = xfile_data->lpVtbl->GetType(xfile_data, &clsid_type);
264  ok(ret == S_OK, "IDirectXFileData_GetType failed with %#x\n", ret);
265  ret = xfile_data->lpVtbl->Lock(xfile_data, &size, (const void**)&data);
266  ok(ret == S_OK, "IDirectXFileData_Lock failed with %#x\n", ret);
267 
268  for (i = 0; i < level; i++)
269  printf(" ");
270 
271  printf("Found object '%s' - %s - %s - %lu\n",
272  len ? name : "", wine_dbgstr_guid(&clsid), wine_dbgstr_guid(&clsid_type), size);
273 
274  if (size)
275  {
276  int j;
277  for (j = 0; j < size; j++)
278  {
279  if (j && !(j%16))
280  printf("\n");
281  printf("%02x ", data[j]);
282  }
283  printf("\n");
284  }
285 
286  ret = xfile_data->lpVtbl->Unlock(xfile_data);
287  ok(ret == S_OK, "ID3DXFileData_Unlock failed with %#x\n", ret);
288 
289  ret = xfile_data->lpVtbl->GetChildren(xfile_data, &children);
290  ok(ret == S_OK, "ID3DXFileData_GetChildren failed with %#x\n", ret);
291 
292  level++;
293 
294  for (i = 0; i < children; i++)
295  {
296  ID3DXFileData *child;
297  int j;
298 
299  ret = xfile_data->lpVtbl->GetChild(xfile_data, i, &child);
300  ok(ret == S_OK, "ID3DXFileData_GetChild failed with %#x\n", ret);
301  for (j = 0; j < level; j++)
302  printf(" ");
303  if (child->lpVtbl->IsReference(child))
304  printf("Found Data Reference (%d)\n", i + 1);
305  else
306  printf("Found Data (%d)\n", i + 1);
307 
309 
310  child->lpVtbl->Release(child);
311  }
312 }
GLint level
Definition: gl.h:1546
static void process_data(ID3DXFileData *xfile_data, int level)
Definition: xfile.c:247
const char * wine_dbgstr_guid(const GUID *guid)
static HWND child
Definition: cursoricon.c:298
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
GLsizeiptr size
Definition: glext.h:5919
LONG HRESULT
Definition: typedefs.h:78
nsrefcnt Release()
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
int ret
REFCLSID clsid
Definition: msctf.c:82
GLenum GLsizei len
Definition: glext.h:6722
unsigned char BYTE
Definition: xxhash.c:193
ULONG_PTR SIZE_T
Definition: typedefs.h:79
#define S_OK
Definition: intsafe.h:59
#define ok(value,...)
Definition: atltest.h:57
Definition: name.c:38
#define printf
Definition: config.h:203
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by test_dump().

◆ START_TEST()

START_TEST ( xfile  )

Definition at line 382 of file xfile.c.

383 {
384  test_templates();
386  test_getname();
388  test_dump();
389 }
static void test_getname(void)
Definition: xfile.c:156
static void test_templates(void)
Definition: xfile.c:83
static void test_lock_unlock(void)
Definition: xfile.c:115
static void test_dump(void)
Definition: xfile.c:316
static void test_type_index_color(void)
Definition: xfile.c:230

◆ test_dump()

static void test_dump ( void  )
static

Definition at line 316 of file xfile.c.

317 {
318  HRESULT ret;
319  ULONG ref;
320  ID3DXFile *xfile = NULL;
321  ID3DXFileEnumObject *xfile_enum_object = NULL;
322  HANDLE file;
323  void *data;
324  DWORD size;
325  SIZE_T children;
326  int i;
327 
328  /* Dump data only if there is an object and a template */
330  if (file == INVALID_HANDLE_VALUE)
331  return;
332  CloseHandle(file);
333 
335  if (file == INVALID_HANDLE_VALUE)
336  return;
337 
339 
340  if (!ReadFile(file, data, 10000, &size, NULL))
341  {
342  skip("Templates file is too big\n");
343  goto exit;
344  }
345 
346  printf("Load templates file (%u bytes)\n", size);
347 
348  ret = D3DXFileCreate(&xfile);
349  ok(ret == S_OK, "D3DXCreateFile failed with %#x\n", ret);
350 
351  ret = xfile->lpVtbl->RegisterTemplates(xfile, data, size);
352  ok(ret == S_OK, "ID3DXFileImpl_RegisterTemplates failed with %#x\n", ret);
353 
354  ret = xfile->lpVtbl->CreateEnumObject(xfile, (void*)"objects.x", D3DXF_FILELOAD_FROMFILE, &xfile_enum_object);
355  ok(ret == S_OK, "ID3DXFile_CreateEnumObject failed with %#x\n", ret);
356 
357  ret = xfile_enum_object->lpVtbl->GetChildren(xfile_enum_object, &children);
358  ok(ret == S_OK, "ID3DXFileEnumObject_GetChildren failed with %#x\n", ret);
359 
360  for (i = 0; i < children; i++)
361  {
362  ID3DXFileData *child;
363  ret = xfile_enum_object->lpVtbl->GetChild(xfile_enum_object, i, &child);
364  ok(ret == S_OK, "ID3DXFileEnumObject_GetChild failed with %#x\n", ret);
365  printf("\n");
366  process_data(child, 0);
367  child->lpVtbl->Release(child);
368  }
369 
370  ref = xfile_enum_object->lpVtbl->Release(xfile_enum_object);
371  ok(ref == 0, "Got refcount %u, expected 0\n", ref);
372 
373  ref = xfile->lpVtbl->Release(xfile);
374  ok(ref == 0, "Got refcount %u, expected 0\n", ref);
375 
376 
377 exit:
378  CloseHandle(file);
380 }
#define CloseHandle
Definition: compat.h:407
static void process_data(ID3DXFileData *xfile_data, int level)
Definition: xfile.c:247
HRESULT WINAPI D3DXFileCreate(ID3DXFile **d3dxfile)
Definition: xfile.c:715
#define INVALID_HANDLE_VALUE
Definition: compat.h:400
Definition: send.c:48
static HWND child
Definition: cursoricon.c:298
#define FILE_SHARE_READ
Definition: compat.h:125
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLenum GLint ref
Definition: glext.h:6028
smooth NULL
Definition: ftsmooth.c:416
#define OPEN_EXISTING
Definition: compat.h:435
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:404
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG HRESULT
Definition: typedefs.h:78
const char file[]
Definition: icontest.c:11
nsrefcnt Release()
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
int ret
#define D3DXF_FILELOAD_FROMFILE
Definition: d3dx9xof.h:38
#define GENERIC_READ
Definition: compat.h:124
ULONG_PTR SIZE_T
Definition: typedefs.h:79
#define S_OK
Definition: intsafe.h:59
#define ok(value,...)
Definition: atltest.h:57
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define skip(...)
Definition: atltest.h:64
unsigned int ULONG
Definition: retypes.h:1
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:408
void exit(int exitcode)
Definition: _exit.c:33
BOOL WINAPI ReadFile(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:123
#define HeapFree(x, y, z)
Definition: compat.h:403
#define printf
Definition: config.h:203
Definition: fci.c:126

Referenced by START_TEST().

◆ test_getname()

static void test_getname ( void  )
static

Definition at line 156 of file xfile.c.

157 {
158  ID3DXFile *d3dxfile;
160  ID3DXFileEnumObject *enum_object;
161  ID3DXFileData *data_object;
162  SIZE_T length;
163  char name[100];
164  HRESULT ret;
165 
166  ret = D3DXFileCreate(&d3dxfile);
167  ok(ret == S_OK, "D3DXCreateFile failed with %#x\n", ret);
168 
169  ret = d3dxfile->lpVtbl->RegisterTemplates(d3dxfile, templates, sizeof(templates) - 1);
170  ok(ret == S_OK, "RegisterTemplates failed with %#x\n", ret);
171 
172  /* Check object with name */
173  memory.lpMemory = objects;
174  memory.dSize = sizeof(objects) - 1;
175  ret = d3dxfile->lpVtbl->CreateEnumObject(d3dxfile, &memory, D3DXF_FILELOAD_FROMMEMORY, &enum_object);
176  ok(ret == S_OK, "CreateEnumObject failed with %#x\n", ret);
177  ret = enum_object->lpVtbl->GetChild(enum_object, 0, &data_object);
178  ok(ret == S_OK, "GetChild failed with %#x\n", ret);
179 
180  ret = data_object->lpVtbl->GetName(data_object, NULL, NULL);
181  ok(ret == D3DXFERR_BADVALUE, "GetName returned %#x, expected %#x\n", ret, D3DXFERR_BADVALUE);
182  ret = data_object->lpVtbl->GetName(data_object, name, NULL);
183  ok(ret == D3DXFERR_BADVALUE, "GetName returned %#x, expected %#x\n", ret, D3DXFERR_BADVALUE);
184  ret = data_object->lpVtbl->GetName(data_object, NULL, &length);
185  ok(ret == S_OK, "GetName failed with %#x\n", ret);
186  ok(length == 7, "Returned length should be 7 instead of %ld\n", length);
187  length = sizeof(name);
188  ret = data_object->lpVtbl->GetName(data_object, name, &length);
189  ok(ret == S_OK, "GetName failed with %#x\n", ret);
190  ok(length == 7, "Returned length should be 7 instead of %ld\n", length);
191  ok(!strcmp(name, "Object"), "Returned string should be 'Object' instead of '%s'\n", name);
192  length = 3;
193  ret = data_object->lpVtbl->GetName(data_object, name, &length);
194  ok(ret== D3DXFERR_BADVALUE, "GetName returned %#x, expected %#x\n", ret, D3DXFERR_BADVALUE);
195 
196  data_object->lpVtbl->Release(data_object);
197  enum_object->lpVtbl->Release(enum_object);
198 
199  /* Check object without name */
200  memory.lpMemory = object_noname;
201  memory.dSize = sizeof(object_noname) - 1;
202  ret = d3dxfile->lpVtbl->CreateEnumObject(d3dxfile, &memory, D3DXF_FILELOAD_FROMMEMORY, &enum_object);
203  ok(ret == S_OK, "CreateEnumObject failed with %#x\n", ret);
204  ret = enum_object->lpVtbl->GetChild(enum_object, 0, &data_object);
205  ok(ret == S_OK, "GetChild failed with %#x\n", ret);
206 
207  /* Contrary to d3dxof, d3dx9_36 returns an empty string with a null byte when no name is available.
208  * If the input size is 0, it returns a length of 1 without touching the buffer */
209  ret = data_object->lpVtbl->GetName(data_object, NULL, &length);
210  ok(ret == S_OK, "GetName failed with %#x\n", ret);
211  ok(length == 1, "Returned length should be 1 instead of %ld\n", length);
212  length = 0;
213  name[0] = 0x7f;
214  ret = data_object->lpVtbl->GetName(data_object, name, &length);
215  ok(ret == S_OK, "GetName failed with %#x\n", ret);
216  ok(length == 1, "Returned length should be 1 instead of %ld\n", length);
217  ok(name[0] == 0x7f, "First character is %#x instead of 0x7f\n", name[0]);
218  length = sizeof(name);
219  name[0] = 0x7f;
220  ret = data_object->lpVtbl->GetName(data_object, name, &length);
221  ok(ret == S_OK, "GetName failed with %#x\n", ret);
222  ok(length == 1, "Returned length should be 1 instead of %ld\n", length);
223  ok(name[0] == 0, "First character is %#x instead of 0x00\n", name[0]);
224 
225  data_object->lpVtbl->Release(data_object);
226  enum_object->lpVtbl->Release(enum_object);
227  d3dxfile->lpVtbl->Release(d3dxfile);
228 }
HRESULT WINAPI D3DXFileCreate(ID3DXFile **d3dxfile)
Definition: xfile.c:715
static char memory[1024 *256]
Definition: process.c:116
smooth NULL
Definition: ftsmooth.c:416
static const char templates[]
Definition: xfile.c:41
LONG HRESULT
Definition: typedefs.h:78
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
#define D3DXFERR_BADVALUE
Definition: d3dx9xof.h:164
int ret
ULONG_PTR SIZE_T
Definition: typedefs.h:79
#define S_OK
Definition: intsafe.h:59
#define ok(value,...)
Definition: atltest.h:57
static char objects[]
Definition: xfile.c:51
Definition: name.c:38
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define D3DXF_FILELOAD_FROMMEMORY
Definition: d3dx9xof.h:41
static char object_noname[]
Definition: xfile.c:58
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by START_TEST().

◆ test_lock_unlock()

static void test_lock_unlock ( void  )
static

Definition at line 115 of file xfile.c.

116 {
117  ID3DXFile *d3dxfile;
119  ID3DXFileEnumObject *enum_object;
120  ID3DXFileData *data_object;
121  const void *data;
122  SIZE_T size;
123  HRESULT ret;
124 
125  ret = D3DXFileCreate(&d3dxfile);
126  ok(ret == S_OK, "D3DXCreateFile failed with %#x\n", ret);
127 
128  ret = d3dxfile->lpVtbl->RegisterTemplates(d3dxfile, templates, sizeof(templates) - 1);
129  ok(ret == S_OK, "RegisterTemplates failed with %#x\n", ret);
130 
131  memory.lpMemory = objects;
132  memory.dSize = sizeof(objects) - 1;
133 
134  ret = d3dxfile->lpVtbl->CreateEnumObject(d3dxfile, &memory, D3DXF_FILELOAD_FROMMEMORY, &enum_object);
135  ok(ret == S_OK, "CreateEnumObject failed with %#x\n", ret);
136 
137  ret = enum_object->lpVtbl->GetChild(enum_object, 0, &data_object);
138  ok(ret == S_OK, "GetChild failed with %#x\n", ret);
139 
140  ret = data_object->lpVtbl->Unlock(data_object);
141  ok(ret == S_OK, "Unlock failed with %#x\n", ret);
142  ret = data_object->lpVtbl->Lock(data_object, &size, &data);
143  ok(ret == S_OK, "Lock failed with %#x\n", ret);
144  ret = data_object->lpVtbl->Lock(data_object, &size, &data);
145  ok(ret == S_OK, "Lock failed with %#x\n", ret);
146  ret = data_object->lpVtbl->Unlock(data_object);
147  ok(ret == S_OK, "Unlock failed with %#x\n", ret);
148  ret = data_object->lpVtbl->Unlock(data_object);
149  ok(ret == S_OK, "Unlock failed with %#x\n", ret);
150 
151  data_object->lpVtbl->Release(data_object);
152  enum_object->lpVtbl->Release(enum_object);
153  d3dxfile->lpVtbl->Release(d3dxfile);
154 }
HRESULT WINAPI D3DXFileCreate(ID3DXFile **d3dxfile)
Definition: xfile.c:715
static char memory[1024 *256]
Definition: process.c:116
static const char templates[]
Definition: xfile.c:41
GLsizeiptr size
Definition: glext.h:5919
LONG HRESULT
Definition: typedefs.h:78
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
int ret
ULONG_PTR SIZE_T
Definition: typedefs.h:79
#define S_OK
Definition: intsafe.h:59
#define ok(value,...)
Definition: atltest.h:57
static char objects[]
Definition: xfile.c:51
#define D3DXF_FILELOAD_FROMMEMORY
Definition: d3dx9xof.h:41

Referenced by START_TEST().

◆ test_templates()

static void test_templates ( void  )
static

Definition at line 83 of file xfile.c.

84 {
85  ID3DXFile *d3dxfile;
86  HRESULT ret;
87 
89  ok(ret == E_POINTER, "D3DXCreateFile returned %#x, expected %#x\n", ret, E_POINTER);
90 
91  ret = D3DXFileCreate(&d3dxfile);
92  ok(ret == S_OK, "D3DXCreateFile failed with %#x\n", ret);
93 
94  ret = d3dxfile->lpVtbl->RegisterTemplates(d3dxfile, templates_bad_file_type1, sizeof(templates_bad_file_type1) - 1);
95  ok(ret == D3DXFERR_BADFILETYPE, "RegisterTemplates returned %#x, expected %#x\n", ret, D3DXFERR_BADFILETYPE);
96 
97  ret = d3dxfile->lpVtbl->RegisterTemplates(d3dxfile, templates_bad_file_version, sizeof(templates_bad_file_version) - 1);
98  ok(ret == D3DXFERR_BADFILEVERSION, "RegisterTemplates returned %#x, expected %#x\n", ret, D3DXFERR_BADFILEVERSION);
99 
100  ret = d3dxfile->lpVtbl->RegisterTemplates(d3dxfile, templates_bad_file_type2, sizeof(templates_bad_file_type2) - 1);
101  ok(ret == D3DXFERR_BADFILETYPE, "RegisterTemplates returned %#x, expected %#x\n", ret, D3DXFERR_BADFILETYPE);
102 
103  ret = d3dxfile->lpVtbl->RegisterTemplates(d3dxfile, templates_bad_file_float_size, sizeof(templates_bad_file_float_size) - 1);
104  ok(ret == D3DXFERR_BADFILEFLOATSIZE, "RegisterTemplates returned %#x, expected %#x\n", ret, D3DXFERR_BADFILEFLOATSIZE);
105 
106  ret = d3dxfile->lpVtbl->RegisterTemplates(d3dxfile, templates_parse_error, sizeof(templates_parse_error) - 1);
107  ok(ret == D3DXFERR_PARSEERROR, "RegisterTemplates returned %#x, expected %#x\n", ret, D3DXFERR_PARSEERROR);
108 
109  ret = d3dxfile->lpVtbl->RegisterTemplates(d3dxfile, templates, sizeof(templates) - 1);
110  ok(ret == S_OK, "RegisterTemplates failed with %#x\n", ret);
111 
112  d3dxfile->lpVtbl->Release(d3dxfile);
113 }
static const char templates_parse_error[]
Definition: xfile.c:37
HRESULT WINAPI D3DXFileCreate(ID3DXFile **d3dxfile)
Definition: xfile.c:715
smooth NULL
Definition: ftsmooth.c:416
#define D3DXFERR_BADFILETYPE
Definition: d3dx9xof.h:171
static const char templates[]
Definition: xfile.c:41
static const char templates_bad_file_type2[]
Definition: xfile.c:31
LONG HRESULT
Definition: typedefs.h:78
int ret
#define D3DXFERR_BADFILEFLOATSIZE
Definition: d3dx9xof.h:173
#define D3DXFERR_PARSEERROR
Definition: d3dx9xof.h:175
#define S_OK
Definition: intsafe.h:59
static const char templates_bad_file_type1[]
Definition: xfile.c:25
#define ok(value,...)
Definition: atltest.h:57
static const char templates_bad_file_float_size[]
Definition: xfile.c:34
#define E_POINTER
Definition: winerror.h:2365
static const char templates_bad_file_version[]
Definition: xfile.c:28
#define D3DXFERR_BADFILEVERSION
Definition: d3dx9xof.h:172

Referenced by START_TEST().

◆ test_type_index_color()

static void test_type_index_color ( void  )
static

Definition at line 230 of file xfile.c.

231 {
232  ID3DXFile *d3dxfile;
233  HRESULT ret;
234 
235  ret = D3DXFileCreate(&d3dxfile);
236  ok(ret == S_OK, "D3DXCreateFile failed with %#x\n", ret);
237 
238  /* Test that 'indexColor' can be used (same as IndexedColor in standard templates) and is case sensitive */
239  ret = d3dxfile->lpVtbl->RegisterTemplates(d3dxfile, template_using_index_color_lower, sizeof(template_using_index_color_lower) - 1);
240  ok(ret == S_OK, "RegisterTemplates failed with %#x\n", ret);
241  ret = d3dxfile->lpVtbl->RegisterTemplates(d3dxfile, template_using_index_color_upper, sizeof(template_using_index_color_upper) - 1);
242  ok(ret == D3DXFERR_PARSEERROR, "RegisterTemplates returned %#x instead of %#x\n", ret, D3DXFERR_PARSEERROR);
243 
244  d3dxfile->lpVtbl->Release(d3dxfile);
245 }
HRESULT WINAPI D3DXFileCreate(ID3DXFile **d3dxfile)
Definition: xfile.c:715
static char template_using_index_color_upper[]
Definition: xfile.c:74
LONG HRESULT
Definition: typedefs.h:78
int ret
#define D3DXFERR_PARSEERROR
Definition: d3dx9xof.h:175
#define S_OK
Definition: intsafe.h:59
static char template_using_index_color_lower[]
Definition: xfile.c:65
#define ok(value,...)
Definition: atltest.h:57

Referenced by START_TEST().

Variable Documentation

◆ object_noname

char object_noname[]
static
Initial value:
=
"xof 0302txt 0064\n"
"Header\n"
"{\n"
"1; 2; 3;\n"
"}\n"

Definition at line 58 of file xfile.c.

Referenced by test_getname().

◆ objects

char objects[]
static
Initial value:
=
"xof 0302txt 0064\n"
"Header Object\n"
"{\n"
"1; 2; 3;\n"
"}\n"

Definition at line 51 of file xfile.c.

Referenced by test_getname(), and test_lock_unlock().

◆ template_using_index_color_lower

char template_using_index_color_lower[]
static
Initial value:
=
"xof 0302txt 0064\n"
"template MeshVertexColors\n"
"{\n"
"<1630B821-7842-11cf-8F52-0040333594A3>\n"
"DWORD nVertexColors;\n"
"array indexColor vertexColors[nVertexColors];\n"
"}\n"

Definition at line 65 of file xfile.c.

Referenced by test_type_index_color().

◆ template_using_index_color_upper

char template_using_index_color_upper[]
static
Initial value:
=
"xof 0302txt 0064\n"
"template MeshVertexColors\n"
"{\n"
"<1630B821-7842-11cf-8F52-0040333594A3>\n"
"DWORD nVertexColors;\n"
"array IndexColor vertexColors[nVertexColors];\n"
"}\n"

Definition at line 74 of file xfile.c.

Referenced by test_type_index_color().

◆ templates

const char templates[]
static
Initial value:
=
"xof 0302txt 0064"
"template Header"
"{"
"<3D82AB43-62DA-11CF-AB39-0020AF71E433>"
"WORD major;"
"WORD minor;"
"DWORD flags;"
"}\n"

Definition at line 41 of file xfile.c.

Referenced by test_getname(), test_lock_unlock(), and test_templates().

◆ templates_bad_file_float_size

const char templates_bad_file_float_size[]
static
Initial value:
=
"xof 0302txt 0050\n"

Definition at line 34 of file xfile.c.

Referenced by test_templates().

◆ templates_bad_file_type1

const char templates_bad_file_type1[]
static
Initial value:
=
"xOf 0302txt 0064\n"

Definition at line 25 of file xfile.c.

Referenced by test_templates().

◆ templates_bad_file_type2

const char templates_bad_file_type2[]
static
Initial value:
=
"xof 0302foo 0064\n"

Definition at line 31 of file xfile.c.

Referenced by test_templates().

◆ templates_bad_file_version

const char templates_bad_file_version[]
static
Initial value:
=
"xof 0102txt 0064\n"

Definition at line 28 of file xfile.c.

Referenced by test_templates().

◆ templates_parse_error

const char templates_parse_error[]
static
Initial value:
=
"xof 0302txt 0064"
"foobar;\n"

Definition at line 37 of file xfile.c.

Referenced by test_templates().