D3D9: [1/2] Reorganise the vertexdeclaration tests

H. Verbeet hverbeet at gmail.com
Mon Feb 6 17:27:00 CST 2006


Reorganise the vertexdeclaration tests in order to make it easier to
add a test for IDirect3DVertexDeclaration9_GetDeclaration.

Changelog:
  - Split the test for getting and setting vertexdeclaration into one
for creating the declaration and one for the actual getting and
setting.
  - Add traces for when creating the device or vertexdeclaration fails.
-------------- next part --------------
diff --git a/dlls/d3d9/tests/vertexdeclaration.c b/dlls/d3d9/tests/vertexdeclaration.c
index 5118b55..1d8b0ec 100644
--- a/dlls/d3d9/tests/vertexdeclaration.c
+++ b/dlls/d3d9/tests/vertexdeclaration.c
@@ -55,23 +55,25 @@ static int get_refcount(IUnknown *object
     return IUnknown_Release(object);
 }
 
-static void test_get_set_vertex_declaration(IDirect3DDevice9 *device_ptr)
+static IDirect3DVertexDeclaration9 *test_create_vertex_declaration(IDirect3DDevice9 *device_ptr, D3DVERTEXELEMENT9 *vertex_decl)
 {
-    static D3DVERTEXELEMENT9 simple_decl[] = {
-        { 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
-        D3DDECL_END()};
-    
     IDirect3DVertexDeclaration9 *decl_ptr = 0;
+    HRESULT hret = 0;
+
+    hret = IDirect3DDevice9_CreateVertexDeclaration(device_ptr, vertex_decl, &decl_ptr);
+    ok(hret == D3D_OK && decl_ptr != NULL, "CreateVertexDeclaration returned: hret 0x%lx, decl_ptr %p. "
+        "Expected hret 0x%lx, decl_ptr != %p. Aborting.\n", hret, decl_ptr, D3D_OK, NULL);
+
+    return decl_ptr;
+}
+
+static void test_get_set_vertex_declaration(IDirect3DDevice9 *device_ptr, IDirect3DVertexDeclaration9 *decl_ptr)
+{
     IDirect3DVertexDeclaration9 *current_decl_ptr = 0;
     HRESULT hret = 0;
     int decl_refcount = 0;
     int i = 0;
     
-    hret = IDirect3DDevice9_CreateVertexDeclaration(device_ptr, simple_decl, &decl_ptr);
-    ok(hret == D3D_OK && decl_ptr != NULL, "CreateVertexDeclaration returned: hret 0x%lx, decl_ptr %p. "
-        "Expected hret 0x%lx, decl_ptr != %p. Aborting.\n", hret, decl_ptr, D3D_OK, NULL);
-    if (hret != D3D_OK || decl_ptr == NULL) return;
-    
     /* SetVertexDeclaration should not touch the declaration's refcount. */
     i = get_refcount((IUnknown *)decl_ptr);
     hret = IDirect3DDevice9_SetVertexDeclaration(device_ptr, decl_ptr);
@@ -90,7 +92,11 @@ static void test_get_set_vertex_declarat
 
 START_TEST(vertexdeclaration)
 {
-    IDirect3DDevice9 *device_ptr;
+    static D3DVERTEXELEMENT9 simple_decl[] = {
+        { 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
+        D3DDECL_END()};
+    IDirect3DDevice9 *device_ptr = 0;
+    IDirect3DVertexDeclaration9 *decl_ptr = 0;
 
     d3d9_handle = LoadLibraryA("d3d9.dll");
     if (!d3d9_handle)
@@ -100,7 +106,18 @@ START_TEST(vertexdeclaration)
     }
 
     device_ptr = init_d3d9();
-    if (!device_ptr) return;
-    
-    test_get_set_vertex_declaration(device_ptr);
+    if (!device_ptr)
+    {
+        trace("Failed to initialise d3d9, aborting test.\n");
+        return;
+    }
+
+    decl_ptr = test_create_vertex_declaration(device_ptr, simple_decl);
+    if (!decl_ptr)
+    {
+        trace("Failed to create a vertex declaration, aborting test.\n");
+        return;
+    }
+
+    test_get_set_vertex_declaration(device_ptr, decl_ptr);
 }




More information about the wine-patches mailing list