Commit 60039a5b authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

ddrawex: Start some tests.

parent efcecb9b
......@@ -24407,6 +24407,14 @@ dlls/ddrawex/Makefile: dlls/ddrawex/Makefile.in dlls/Makedll.rules"
ac_config_files="$ac_config_files dlls/ddrawex/Makefile"
ALL_MAKEFILES="$ALL_MAKEFILES \\
dlls/ddrawex/tests/Makefile"
test "x$enable_tests" != xno && ALL_TEST_DIRS="$ALL_TEST_DIRS \\
ddrawex/tests"
ALL_MAKEFILE_DEPENDS="$ALL_MAKEFILE_DEPENDS
dlls/ddrawex/tests/Makefile: dlls/ddrawex/tests/Makefile.in dlls/Maketest.rules"
ac_config_files="$ac_config_files dlls/ddrawex/tests/Makefile"
ALL_MAKEFILES="$ALL_MAKEFILES \\
dlls/devenum/Makefile"
test "x$enable_devenum" != xno && ALL_DLL_DIRS="$ALL_DLL_DIRS \\
devenum"
......@@ -28037,6 +28045,7 @@ do
"dlls/ddraw/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/ddraw/Makefile" ;;
"dlls/ddraw/tests/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/ddraw/tests/Makefile" ;;
"dlls/ddrawex/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/ddrawex/Makefile" ;;
"dlls/ddrawex/tests/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/ddrawex/tests/Makefile" ;;
"dlls/devenum/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/devenum/Makefile" ;;
"dlls/dinput/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/dinput/Makefile" ;;
"dlls/dinput/tests/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/dinput/tests/Makefile" ;;
......
......@@ -1825,6 +1825,7 @@ WINE_CONFIG_MAKEFILE([dlls/dciman32/Makefile],[dlls/Makedll.rules],[dlls],[ALL_D
WINE_CONFIG_MAKEFILE([dlls/ddraw/Makefile],[dlls/Makedll.rules],[dlls],[ALL_DLL_DIRS])
WINE_CONFIG_MAKEFILE([dlls/ddraw/tests/Makefile],[dlls/Maketest.rules],[dlls],[ALL_TEST_DIRS],[enable_tests])
WINE_CONFIG_MAKEFILE([dlls/ddrawex/Makefile],[dlls/Makedll.rules],[dlls],[ALL_DLL_DIRS])
WINE_CONFIG_MAKEFILE([dlls/ddrawex/tests/Makefile],[dlls/Maketest.rules],[dlls],[ALL_TEST_DIRS],[enable_tests])
WINE_CONFIG_MAKEFILE([dlls/devenum/Makefile],[dlls/Makedll.rules],[dlls],[ALL_DLL_DIRS])
WINE_CONFIG_MAKEFILE([dlls/dinput/Makefile],[dlls/Makedll.rules],[dlls],[ALL_DLL_DIRS])
WINE_CONFIG_MAKEFILE([dlls/dinput/tests/Makefile],[dlls/Maketest.rules],[dlls],[ALL_TEST_DIRS],[enable_tests])
......
TOPSRCDIR = @top_srcdir@
TOPOBJDIR = ../../..
SRCDIR = @srcdir@
VPATH = @srcdir@
TESTDLL = ddrawex.dll
IMPORTS = user32 gdi32 kernel32
CTESTS = \
surface.c
@MAKE_TEST_RULES@
@DEPENDENCIES@ # everything below this line is overwritten by make depend
/*
* Copyright 2006 Ulrich Czekalla
*
* 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
*/
#ifndef __WINE_DDRAWEX_DDRAWEX_H
#define __WINE_DDRAWEX_DDRAWEX_H
DEFINE_GUID(CLSID_DirectDrawFactory, 0x4fd2a832, 0x86c8, 0x11d0, 0x8f, 0xca, 0x0, 0xc0, 0x4f, 0xd9, 0x18, 0x9d);
DEFINE_GUID(IID_IDirectDrawFactory, 0x4fd2a833, 0x86c8, 0x11d0, 0x8f, 0xca, 0x0, 0xc0, 0x4f, 0xd9, 0x18, 0x9d);
#define INTERFACE IDirectDrawFactory
DECLARE_INTERFACE_(IDirectDrawFactory, IUnknown)
{
STDMETHOD_(HRESULT, QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
STDMETHOD_(ULONG, AddRef)(THIS) PURE;
STDMETHOD_(ULONG, Release)(THIS) PURE;
STDMETHOD(CreateDirectDraw)(THIS_ GUID * pGUID, HWND hWnd, DWORD dwCoopLevelFlags,
DWORD dwReserved, IUnknown *pUnkOuter, IDirectDraw **ppDirectDraw) PURE;
STDMETHOD(_DirectDrawEnumerate)(THIS_ LPDDENUMCALLBACKW lpCallback, LPVOID lpContext) PURE;
};
#undef INTERFACE
#if !defined(__cplusplus) || defined(CINTERFACE)
/*** IUnknown methods ***/
#define IDirectDrawFactory_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
#define IDirectDrawFactory_AddRef(p) (p)->lpVtbl->AddRef(p)
#define IDirectDrawFactory_Release(p) (p)->lpVtbl->Release(p)
#define IDirectDrawFactory_CreateDirectDraw(p,a,b,c,d,e,f) (p)->lpVtbl->CreateDirectDraw(p,a,b,c,d,e,f)
#define IDirectDrawFactory_DirectDrawEnumerate(p,a,b) (p)->lpVtbl->_DirectDrawEnumerate(p,a,b)
#endif
#endif /* __WINE_DDRAWEX_DDRAWEX_H */
/*
* Unit tests for ddrawex surfaces
*
* 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
/* For IID_IDirectDraw3 - it is not in dxguid.dll */
#define INITGUID
#include <assert.h>
#include "wine/test.h"
#include "windef.h"
#include "winbase.h"
#include "ddraw.h"
#include "ddrawex.h"
#include "unknwn.h"
static IDirectDrawFactory *factory;
static HRESULT (WINAPI *pDllGetClassObject)(REFCLSID rclsid, REFIID riid, LPVOID *ppv);
static IDirectDraw *createDD(void)
{
HRESULT hr;
IDirectDraw *dd;
hr = IDirectDrawFactory_CreateDirectDraw(factory, NULL, NULL, DDSCL_NORMAL, 0,
0, &dd);
ok(hr == DD_OK, "Failed to create an IDirectDraw interface, hr = 0x%08x\n", hr);
return SUCCEEDED(hr) ? dd : NULL;
}
static void dctest_surf(IDirectDrawSurface *surf, int ddsdver) {
HRESULT hr;
HDC dc, dc2 = (HDC) 0x1234;
DDSURFACEDESC ddsd;
DDSURFACEDESC2 ddsd2;
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
memset(&ddsd2, 0, sizeof(ddsd2));
ddsd2.dwSize = sizeof(ddsd2);
hr = IDirectDrawSurface_GetDC(surf, &dc);
ok(hr == DD_OK, "IDirectDrawSurface_GetDC failed: 0x%08x\n", hr);
hr = IDirectDrawSurface_GetDC(surf, &dc);
ok(hr == DDERR_DCALREADYCREATED, "IDirectDrawSurface_GetDC failed: 0x%08x\n", hr);
ok(dc2 == (HDC) 0x1234, "The failed GetDC call changed the dc: %p\n", dc2);
hr = IDirectDrawSurface_Lock(surf, NULL, ddsdver == 1 ? &ddsd : ((DDSURFACEDESC *) &ddsd2), 0, NULL);
ok(hr == DDERR_SURFACEBUSY, "IDirectDrawSurface_Lock returned 0x%08x, expected DDERR_ALREADYLOCKED\n", hr);
hr = IDirectDrawSurface_ReleaseDC(surf, dc);
ok(hr == DD_OK, "IDirectDrawSurface_ReleaseDC failed: 0x%08x\n", hr);
hr = IDirectDrawSurface_ReleaseDC(surf, dc);
ok(hr == DDERR_NODC, "IDirectDrawSurface_ReleaseDC returned 0x%08x, expected DDERR_NODC\n", hr);
}
static void GetDCTest(void)
{
DDSURFACEDESC ddsd;
DDSURFACEDESC2 ddsd2;
IDirectDrawSurface *surf;
IDirectDrawSurface2 *surf2;
IDirectDrawSurface2 *surf3;
IDirectDrawSurface4 *surf4;
HRESULT hr;
IDirectDraw *dd1 = createDD();
IDirectDraw2 *dd2;
IDirectDraw3 *dd3;
IDirectDraw4 *dd4;
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
ddsd.dwWidth = 64;
ddsd.dwHeight = 64;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
memset(&ddsd2, 0, sizeof(ddsd2));
ddsd2.dwSize = sizeof(ddsd2);
ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
ddsd2.dwWidth = 64;
ddsd2.dwHeight = 64;
ddsd2.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
hr = IDirectDraw_CreateSurface(dd1, &ddsd, &surf, NULL);
ok(hr == DD_OK, "IDirectDraw_CreateSurface failed: 0x%08x\n", hr);
dctest_surf(surf, 1);
IDirectDrawSurface_Release(surf);
hr = IDirectDraw_QueryInterface(dd1, &IID_IDirectDraw2, (void **) &dd2);
ok(hr == DD_OK, "IDirectDraw_QueryInterface failed: 0x%08x\n", hr);
hr = IDirectDraw2_CreateSurface(dd2, &ddsd, &surf, NULL);
ok(hr == DD_OK, "IDirectDraw2_CreateSurface failed: 0x%08x\n", hr);
dctest_surf(surf, 1);
hr = IDirectDrawSurface_QueryInterface(surf, &IID_IDirectDrawSurface2, (void **) &surf2);
ok(hr == DD_OK, "IDirectDrawSurface_QueryInterface failed: 0x%08x\n", hr);
dctest_surf((IDirectDrawSurface *) surf2, 1);
IDirectDrawSurface2_Release(surf2);
IDirectDrawSurface_Release(surf);
IDirectDraw2_Release(dd2);
hr = IDirectDraw_QueryInterface(dd1, &IID_IDirectDraw3, (void **) &dd3);
ok(hr == DD_OK, "IDirectDraw_QueryInterface failed: 0x%08x\n", hr);
if(SUCCEEDED(hr))
{
hr = IDirectDraw3_CreateSurface(dd3, &ddsd, &surf, NULL);
ok(hr == DD_OK, "IDirectDraw3_CreateSurface failed: 0x%08x\n", hr);
dctest_surf(surf, 1);
hr = IDirectDrawSurface_QueryInterface(surf, &IID_IDirectDrawSurface3, (void **) &surf3);
ok(hr == DD_OK, "IDirectDrawSurface_QueryInterface failed: 0x%08x\n", hr);
dctest_surf((IDirectDrawSurface *) surf3, 1);
IDirectDrawSurface3_Release(surf3);
IDirectDrawSurface_Release(surf);
IDirectDraw3_Release(dd3);
}
hr = IDirectDraw_QueryInterface(dd1, &IID_IDirectDraw4, (void **) &dd4);
ok(hr == DD_OK, "IDirectDraw_QueryInterface failed: 0x%08x\n", hr);
surf = NULL;
hr = IDirectDraw4_CreateSurface(dd4, &ddsd2, &surf4, NULL);
ok(hr == DD_OK, "IDirectDraw4_CreateSurface failed: 0x%08x\n", hr);
dctest_surf((IDirectDrawSurface *) surf4, 2);
IDirectDrawSurface4_Release(surf4);
IDirectDraw4_Release(dd4);
IDirectDraw_Release(dd1);
}
START_TEST(surface)
{
IClassFactory *classfactory = NULL;
ULONG ref;
HRESULT hr;
HMODULE hmod = LoadLibrary("ddrawex.dll");
if(hmod == NULL) {
skip("Failed to load ddrawex.dll\n");
return;
}
pDllGetClassObject = (void*)GetProcAddress(hmod, "DllGetClassObject");
if(pDllGetClassObject == NULL) {
skip("Failed to get DllGetClassObject\n");
return;
}
hr = pDllGetClassObject(&CLSID_DirectDrawFactory, &IID_IClassFactory, (void **) &classfactory);
ok(hr == S_OK, "Failed to create a IClassFactory\n");
hr = IClassFactory_CreateInstance(classfactory, NULL, &IID_IDirectDrawFactory, (void **) &factory);
ok(hr == S_OK, "Failed to create a IDirectDrawFactory\n");
GetDCTest();
if(factory) {
ref = IDirectDrawFactory_Release(factory);
ok(ref == 0, "IDirectDrawFactory not cleanly released\n");
}
if(classfactory) {
ref = IClassFactory_Release(classfactory);
todo_wine ok(ref == 1, "IClassFactory refcount wrong, ref = %u\n", ref);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment