Henri Verbeet : dxgi: Add a test for DXGID3D10CreateDevice().

Alexandre Julliard julliard at winehq.org
Tue Nov 18 09:27:13 CST 2008


Module: wine
Branch: master
Commit: 1dea8291fb4187fe5ca392d2ba41d75e81efdc38
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=1dea8291fb4187fe5ca392d2ba41d75e81efdc38

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Tue Nov 18 09:27:58 2008 +0100

dxgi: Add a test for DXGID3D10CreateDevice().

---

 configure                   |    9 +++
 configure.ac                |    1 +
 dlls/dxgi/tests/Makefile.in |   13 +++++
 dlls/dxgi/tests/device.c    |  127 +++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 150 insertions(+), 0 deletions(-)

diff --git a/configure b/configure
index af1a5a2..5845633 100755
--- a/configure
+++ b/configure
@@ -24802,6 +24802,14 @@ dlls/dxgi/Makefile: dlls/dxgi/Makefile.in dlls/Makedll.rules"
 ac_config_files="$ac_config_files dlls/dxgi/Makefile"
 
 ALL_MAKEFILES="$ALL_MAKEFILES \\
+	dlls/dxgi/tests/Makefile"
+test "x$enable_dxgi_tests" != xno && ALL_TEST_DIRS="$ALL_TEST_DIRS \\
+	dxgi/tests"
+ALL_MAKEFILE_DEPENDS="$ALL_MAKEFILE_DEPENDS
+dlls/dxgi/tests/Makefile: dlls/dxgi/tests/Makefile.in dlls/Maketest.rules"
+ac_config_files="$ac_config_files dlls/dxgi/tests/Makefile"
+
+ALL_MAKEFILES="$ALL_MAKEFILES \\
 	dlls/dxguid/Makefile"
 test "x$enable_dxguid" != xno && ALL_IMPLIB_DIRS="$ALL_IMPLIB_DIRS \\
 	dxguid"
@@ -28159,6 +28167,7 @@ do
     "dlls/dxerr8/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/dxerr8/Makefile" ;;
     "dlls/dxerr9/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/dxerr9/Makefile" ;;
     "dlls/dxgi/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/dxgi/Makefile" ;;
+    "dlls/dxgi/tests/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/dxgi/tests/Makefile" ;;
     "dlls/dxguid/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/dxguid/Makefile" ;;
     "dlls/faultrep/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/faultrep/Makefile" ;;
     "dlls/fusion/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/fusion/Makefile" ;;
diff --git a/configure.ac b/configure.ac
index 71c2a45..19acfd6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1840,6 +1840,7 @@ WINE_CONFIG_MAKEFILE([dlls/dxdiagn/Makefile],[dlls/Makedll.rules],[dlls],[ALL_DL
 WINE_CONFIG_MAKEFILE([dlls/dxerr8/Makefile],[dlls/Makeimplib.rules],[dlls],[ALL_IMPLIB_DIRS])
 WINE_CONFIG_MAKEFILE([dlls/dxerr9/Makefile],[dlls/Makeimplib.rules],[dlls],[ALL_IMPLIB_DIRS])
 WINE_CONFIG_MAKEFILE([dlls/dxgi/Makefile],[dlls/Makedll.rules],[dlls],[ALL_DLL_DIRS])
+WINE_CONFIG_MAKEFILE([dlls/dxgi/tests/Makefile],[dlls/Maketest.rules],[dlls],[ALL_TEST_DIRS])
 WINE_CONFIG_MAKEFILE([dlls/dxguid/Makefile],[dlls/Makeimplib.rules],[dlls],[ALL_IMPLIB_DIRS])
 WINE_CONFIG_MAKEFILE([dlls/faultrep/Makefile],[dlls/Makedll.rules],[dlls],[ALL_DLL_DIRS])
 WINE_CONFIG_MAKEFILE([dlls/fusion/Makefile],[dlls/Makedll.rules],[dlls],[ALL_DLL_DIRS])
diff --git a/dlls/dxgi/tests/Makefile.in b/dlls/dxgi/tests/Makefile.in
new file mode 100644
index 0000000..1020225
--- /dev/null
+++ b/dlls/dxgi/tests/Makefile.in
@@ -0,0 +1,13 @@
+TOPSRCDIR = @top_srcdir@
+TOPOBJDIR = ../../..
+SRCDIR    = @srcdir@
+VPATH     = @srcdir@
+TESTDLL   = dxgi.dll
+IMPORTS   = dxgi kernel32
+
+CTESTS = \
+	device.c \
+
+ at MAKE_TEST_RULES@
+
+ at DEPENDENCIES@  # everything below this line is overwritten by make depend
diff --git a/dlls/dxgi/tests/device.c b/dlls/dxgi/tests/device.c
new file mode 100644
index 0000000..7f22bb4
--- /dev/null
+++ b/dlls/dxgi/tests/device.c
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2008 Henri Verbeet for CodeWeavers
+ *
+ * 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 "initguid.h"
+#include "d3d10.h"
+#include "wine/test.h"
+
+HRESULT WINAPI DXGID3D10CreateDevice(HMODULE d3d10core, IDXGIFactory *factory,
+        IDXGIAdapter *adapter, UINT flags, DWORD arg5, void **device);
+
+static IDXGIDevice *create_device(HMODULE d3d10core)
+{
+    IDXGIDevice *dxgi_device = NULL;
+    IDXGIFactory *factory = NULL;
+    IDXGIAdapter *adapter = NULL;
+    IUnknown *device = NULL;
+    HRESULT hr;
+
+    hr = CreateDXGIFactory(&IID_IDXGIFactory, (void *)&factory);
+    ok(SUCCEEDED(hr), "CreateDXGIFactory failed, hr %#x\n", hr);
+    if (FAILED(hr)) goto cleanup;
+
+    hr = IDXGIFactory_EnumAdapters(factory, 0, &adapter);
+    ok(SUCCEEDED(hr), "EnumAdapters failed, hr %#x\n", hr);
+    if (FAILED(hr)) goto cleanup;
+
+    hr = DXGID3D10CreateDevice(d3d10core, factory, adapter, 0, 0, (void **)&device);
+    if (FAILED(hr))
+    {
+        HMODULE d3d10ref;
+
+        trace("Failed to create a HW device, trying REF\n");
+        IDXGIAdapter_Release(adapter);
+        adapter = NULL;
+
+        d3d10ref = LoadLibraryA("d3d10ref.dll");
+        if (!d3d10ref)
+        {
+            trace("d3d10ref.dll not available, unable to create a REF device\n");
+            goto cleanup;
+        }
+
+        hr = IDXGIFactory_CreateSoftwareAdapter(factory, d3d10ref, &adapter);
+        FreeLibrary(d3d10ref);
+        ok(SUCCEEDED(hr), "CreateSoftwareAdapter failed, hr %#x\n", hr);
+        if (FAILED(hr)) goto cleanup;
+
+        hr = DXGID3D10CreateDevice(d3d10core, factory, adapter, 0, 0, (void **)&device);
+        ok(SUCCEEDED(hr), "Failed to create a REF device, hr %#x\n", hr);
+        if (FAILED(hr)) goto cleanup;
+    }
+
+    hr = IUnknown_QueryInterface(device, &IID_IDXGIDevice, (void **)&dxgi_device);
+    ok(SUCCEEDED(hr), "Created device does not implement IDXGIDevice\n");
+    IUnknown_Release(device);
+
+cleanup:
+    if (adapter) IDXGIAdapter_Release(adapter);
+    if (factory) IDXGIFactory_Release(factory);
+
+    return dxgi_device;
+}
+
+static void test_device_interfaces(IDXGIDevice *device)
+{
+    IUnknown *obj;
+    HRESULT hr;
+
+    if (SUCCEEDED(hr = IDXGIDevice_QueryInterface(device, &IID_IUnknown, (void **)&obj)))
+        IUnknown_Release(obj);
+    ok(SUCCEEDED(hr), "IDXGIDevice does not implement IUnknown\n");
+
+    if (SUCCEEDED(hr = IDXGIDevice_QueryInterface(device, &IID_IDXGIObject, (void **)&obj)))
+        IUnknown_Release(obj);
+    ok(SUCCEEDED(hr), "IDXGIDevice does not implement IDXGIObject\n");
+
+    if (SUCCEEDED(hr = IDXGIDevice_QueryInterface(device, &IID_IDXGIDevice, (void **)&obj)))
+        IUnknown_Release(obj);
+    ok(SUCCEEDED(hr), "IDXGIDevice does not implement IDXGIDevice\n");
+
+    if (SUCCEEDED(hr = IDXGIDevice_QueryInterface(device, &IID_ID3D10Device, (void **)&obj)))
+        IUnknown_Release(obj);
+    ok(SUCCEEDED(hr), "IDXGIDevice does not implement ID3D10Device\n");
+}
+
+START_TEST(device)
+{
+    HMODULE d3d10core = LoadLibraryA("d3d10core.dll");
+    IDXGIDevice *device;
+    ULONG refcount;
+
+    if (!d3d10core)
+    {
+        win_skip("d3d10core.dll not available, skipping tests\n");
+        return;
+    }
+
+    device = create_device(d3d10core);
+    if (!device)
+    {
+        skip("Failed to create device, skipping tests\n");
+        FreeLibrary(d3d10core);
+        return;
+    }
+
+    test_device_interfaces(device);
+
+    refcount = IDXGIDevice_Release(device);
+    ok(!refcount, "Device has %u references left\n", refcount);
+    FreeLibrary(d3d10core);
+}




More information about the wine-cvs mailing list