d3dx9_36: Implement ID3DXFileDataImpl_Lock and ID3DXFileDataImpl_Unlock + tests.

This commit is contained in:
Christian Costa 2013-01-18 08:49:17 +01:00 committed by Alexandre Julliard
parent 8aa700e7ba
commit 45e43dc5d0
2 changed files with 66 additions and 4 deletions

View File

@ -46,6 +46,12 @@ char templates[] =
"DWORD flags;"
"}\n";
static char objects[] =
"xof 0302txt 0064\n"
"Header Object\n"
"{\n"
"1; 2; 3;\n"
"}\n";
static void test_templates(void)
{
@ -79,8 +85,49 @@ static void test_templates(void)
d3dxfile->lpVtbl->Release(d3dxfile);
}
static void test_lock_unlock(void)
{
ID3DXFile *d3dxfile;
D3DXF_FILELOADMEMORY memory;
ID3DXFileEnumObject *enum_object;
ID3DXFileData *data_object;
const void *data;
SIZE_T size;
HRESULT ret;
ret = D3DXFileCreate(&d3dxfile);
ok(ret == S_OK, "D3DXCreateFile failed with %#x\n", ret);
ret = d3dxfile->lpVtbl->RegisterTemplates(d3dxfile, (const void *)templates, (SIZE_T)(sizeof(templates) - 1));
ok(ret == S_OK, "RegisterTemplates failed with %#x\n", ret);
memory.lpMemory = objects;
memory.dSize = sizeof(objects) - 1;
ret = d3dxfile->lpVtbl->CreateEnumObject(d3dxfile, &memory, D3DXF_FILELOAD_FROMMEMORY, &enum_object);
ok(ret == S_OK, "CreateEnumObject failed with %#x\n", ret);
ret = enum_object->lpVtbl->GetChild(enum_object, 0, &data_object);
ok(ret == S_OK, "GetChild failed with %#x\n", ret);
ret = data_object->lpVtbl->Unlock(data_object);
ok(ret == S_OK, "Unlock failed with %#x\n", ret);
ret = data_object->lpVtbl->Lock(data_object, &size, &data);
ok(ret == S_OK, "Lock failed with %#x\n", ret);
ret = data_object->lpVtbl->Lock(data_object, &size, &data);
ok(ret == S_OK, "Lock failed with %#x\n", ret);
ret = data_object->lpVtbl->Unlock(data_object);
ok(ret == S_OK, "Unlock failed with %#x\n", ret);
ret = data_object->lpVtbl->Unlock(data_object);
ok(ret == S_OK, "Unlock failed with %#x\n", ret);
data_object->lpVtbl->Release(data_object);
enum_object->lpVtbl->Release(enum_object);
d3dxfile->lpVtbl->Release(d3dxfile);
}
START_TEST(xfile)
{
test_templates();
test_lock_unlock();
}

View File

@ -178,17 +178,32 @@ static HRESULT WINAPI ID3DXFileDataImpl_GetId(ID3DXFileData *iface, GUID *guid)
static HRESULT WINAPI ID3DXFileDataImpl_Lock(ID3DXFileData *iface, SIZE_T *size, const void **data)
{
FIXME("(%p)->(%p, %p): stub\n", iface, size, data);
ID3DXFileDataImpl *This = impl_from_ID3DXFileData(iface);
DWORD dxfile_size;
HRESULT ret;
return E_NOTIMPL;
TRACE("(%p)->(%p, %p)\n", iface, size, data);
if (!size || !data)
return E_POINTER;
ret = IDirectXFileData_GetData(This->dxfile_data, NULL, &dxfile_size, (void**)data);
if (ret != DXFILE_OK)
return error_dxfile_to_d3dxfile(ret);
*size = dxfile_size;
return S_OK;
}
static HRESULT WINAPI ID3DXFileDataImpl_Unlock(ID3DXFileData *iface)
{
FIXME("(%p)->(): stub\n", iface);
TRACE("(%p)->()\n", iface);
return E_NOTIMPL;
/* Nothing to do */
return S_OK;
}