2008-08-19 00:30:44 +02:00
|
|
|
/*
|
|
|
|
* Some unit tests for d3dxof
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008 Christian Costa
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include "wine/test.h"
|
|
|
|
#include "dxfile.h"
|
|
|
|
|
2008-08-26 08:19:03 +02:00
|
|
|
static HMODULE hd3dxof;
|
|
|
|
static HRESULT (WINAPI *pDirectXFileCreate)(LPDIRECTXFILE*);
|
|
|
|
|
2008-08-19 00:30:44 +02:00
|
|
|
char template[] =
|
2008-08-19 14:00:32 +02:00
|
|
|
"xof 0302txt 0064\n"
|
2008-08-19 00:30:44 +02:00
|
|
|
"template Header\n"
|
|
|
|
"{\n"
|
2008-08-29 11:11:54 +02:00
|
|
|
"<3D82AB43-62DA-11CF-AB39-0020AF71E433>\n"
|
|
|
|
"WORD major;\n"
|
|
|
|
"WORD minor;\n"
|
|
|
|
"DWORD flags;\n"
|
2008-08-19 00:30:44 +02:00
|
|
|
"}\n";
|
|
|
|
|
2008-08-26 08:19:03 +02:00
|
|
|
static void init_function_pointers(void)
|
|
|
|
{
|
|
|
|
/* We have to use LoadLibrary as no d3dxof functions are referenced directly */
|
|
|
|
hd3dxof = LoadLibraryA("d3dxof.dll");
|
|
|
|
|
|
|
|
pDirectXFileCreate = (void *)GetProcAddress(hd3dxof, "DirectXFileCreate");
|
|
|
|
}
|
|
|
|
|
2008-08-19 00:30:44 +02:00
|
|
|
static unsigned long getRefcount(IUnknown *iface)
|
|
|
|
{
|
|
|
|
IUnknown_AddRef(iface);
|
|
|
|
return IUnknown_Release(iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_d3dxof(void)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
unsigned long ref;
|
|
|
|
LPDIRECTXFILE lpDirectXFile = NULL;
|
2008-08-26 08:19:03 +02:00
|
|
|
|
|
|
|
if (!pDirectXFileCreate)
|
|
|
|
{
|
|
|
|
win_skip("DirectXFileCreate is not available\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = pDirectXFileCreate(&lpDirectXFile);
|
2008-08-19 00:30:44 +02:00
|
|
|
ok(hr == DXFILE_OK, "DirectXFileCreate: %x\n", hr);
|
|
|
|
if(!lpDirectXFile)
|
|
|
|
{
|
2008-08-26 08:19:03 +02:00
|
|
|
skip("Couldn't create DirectXFile interface\n");
|
2008-08-19 00:30:44 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ref = getRefcount( (IUnknown *) lpDirectXFile);
|
|
|
|
ok(ref == 1, "Got refcount %ld, expected 1\n", ref);
|
|
|
|
|
|
|
|
ref = IDirectXFile_AddRef(lpDirectXFile);
|
|
|
|
ok(ref == 2, "Got refcount %ld, expected 1\n", ref);
|
|
|
|
|
|
|
|
ref = IDirectXFile_Release(lpDirectXFile);
|
|
|
|
ok(ref == 1, "Got refcount %ld, expected 1\n", ref);
|
|
|
|
|
|
|
|
hr = IDirectXFile_RegisterTemplates(lpDirectXFile, template, strlen(template));
|
2008-08-19 14:00:32 +02:00
|
|
|
ok(hr == DXFILE_OK, "IDirectXFileImpl_RegisterTemplates: %x\n", hr);
|
2008-08-19 00:30:44 +02:00
|
|
|
|
|
|
|
ref = IDirectXFile_Release(lpDirectXFile);
|
|
|
|
ok(ref == 0, "Got refcount %ld, expected 1\n", ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
START_TEST(d3dxof)
|
|
|
|
{
|
2008-08-26 08:19:03 +02:00
|
|
|
init_function_pointers();
|
|
|
|
|
2008-08-19 00:30:44 +02:00
|
|
|
test_d3dxof();
|
2008-08-26 08:19:03 +02:00
|
|
|
|
|
|
|
FreeLibrary(hd3dxof);
|
2008-08-19 00:30:44 +02:00
|
|
|
}
|