Commit 1b3c8aaf authored by André Hentschel's avatar André Hentschel Committed by Alexandre Julliard

d3drm/tests: Add refcount testing.

parent 5aa43a2b
...@@ -16,7 +16,9 @@ ...@@ -16,7 +16,9 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include "d3drm.h" #define COBJMACROS
#include <d3drm.h>
#include <initguid.h>
#include "wine/test.h" #include "wine/test.h"
...@@ -24,6 +26,13 @@ static HMODULE d3drm_handle = 0; ...@@ -24,6 +26,13 @@ static HMODULE d3drm_handle = 0;
static HRESULT (WINAPI * pDirect3DRMCreate)(LPDIRECT3DRM* ppDirect3DRM); static HRESULT (WINAPI * pDirect3DRMCreate)(LPDIRECT3DRM* ppDirect3DRM);
#define CHECK_REFCOUNT(obj,rc) \
{ \
int rc_new = rc; \
int count = get_refcount( (IUnknown *)obj ); \
ok(count == rc_new, "Invalid refcount. Expected %d got %d\n", rc_new, count); \
}
#define D3DRM_GET_PROC(func) \ #define D3DRM_GET_PROC(func) \
p ## func = (void*)GetProcAddress(d3drm_handle, #func); \ p ## func = (void*)GetProcAddress(d3drm_handle, #func); \
if(!p ## func) { \ if(!p ## func) { \
...@@ -47,6 +56,12 @@ static BOOL InitFunctionPtrs(void) ...@@ -47,6 +56,12 @@ static BOOL InitFunctionPtrs(void)
return TRUE; return TRUE;
} }
static int get_refcount(IUnknown *object)
{
IUnknown_AddRef( object );
return IUnknown_Release( object );
}
static char data_bad_version[] = static char data_bad_version[] =
"xof 0302txt 0064\n" "xof 0302txt 0064\n"
"Header Object\n" "Header Object\n"
...@@ -236,11 +251,13 @@ static void test_Frame(void) ...@@ -236,11 +251,13 @@ static void test_Frame(void)
hr = IDirect3DRM_CreateFrame(pD3DRM, NULL, &pFrameC); hr = IDirect3DRM_CreateFrame(pD3DRM, NULL, &pFrameC);
ok(hr == D3DRM_OK, "Cannot get IDirect3DRMFrame interface (hr = %x)\n", hr); ok(hr == D3DRM_OK, "Cannot get IDirect3DRMFrame interface (hr = %x)\n", hr);
CHECK_REFCOUNT(pFrameC, 1);
pFrameTmp = (void*)0xdeadbeef; pFrameTmp = (void*)0xdeadbeef;
hr = IDirect3DRMFrame_GetParent(pFrameC, &pFrameTmp); hr = IDirect3DRMFrame_GetParent(pFrameC, &pFrameTmp);
todo_wine ok(hr == D3DRM_OK, "Cannot get parent frame (hr = %x)\n", hr); todo_wine ok(hr == D3DRM_OK, "Cannot get parent frame (hr = %x)\n", hr);
todo_wine ok(pFrameTmp == NULL, "pFrameTmp = %p\n", pFrameTmp); todo_wine ok(pFrameTmp == NULL, "pFrameTmp = %p\n", pFrameTmp);
CHECK_REFCOUNT(pFrameC, 1);
pArray = NULL; pArray = NULL;
hr = IDirect3DRMFrame_GetChildren(pFrameC, &pArray); hr = IDirect3DRMFrame_GetChildren(pFrameC, &pArray);
...@@ -264,6 +281,8 @@ static void test_Frame(void) ...@@ -264,6 +281,8 @@ static void test_Frame(void)
hr = IDirect3DRMFrame_AddChild(pFrameP1, pFrameC); hr = IDirect3DRMFrame_AddChild(pFrameP1, pFrameC);
todo_wine ok(hr == D3DRM_OK, "Cannot add child frame (hr = %x)\n", hr); todo_wine ok(hr == D3DRM_OK, "Cannot add child frame (hr = %x)\n", hr);
CHECK_REFCOUNT(pFrameP1, 1);
todo_wine CHECK_REFCOUNT(pFrameC, 2);
pArray = NULL; pArray = NULL;
hr = IDirect3DRMFrame_GetChildren(pFrameP1, &pArray); hr = IDirect3DRMFrame_GetChildren(pFrameP1, &pArray);
...@@ -279,6 +298,7 @@ static void test_Frame(void) ...@@ -279,6 +298,7 @@ static void test_Frame(void)
hr = IDirect3DRMFrame_GetParent(pFrameC, &pFrameTmp); hr = IDirect3DRMFrame_GetParent(pFrameC, &pFrameTmp);
todo_wine ok(hr == D3DRM_OK, "Cannot get parent frame (hr = %x)\n", hr); todo_wine ok(hr == D3DRM_OK, "Cannot get parent frame (hr = %x)\n", hr);
todo_wine ok(pFrameTmp == pFrameP1, "pFrameTmp = %p\n", pFrameTmp); todo_wine ok(pFrameTmp == pFrameP1, "pFrameTmp = %p\n", pFrameTmp);
todo_wine CHECK_REFCOUNT(pFrameP1, 2);
/* Add child to second parent */ /* Add child to second parent */
hr = IDirect3DRM_CreateFrame(pD3DRM, NULL, &pFrameP2); hr = IDirect3DRM_CreateFrame(pD3DRM, NULL, &pFrameP2);
...@@ -286,6 +306,7 @@ static void test_Frame(void) ...@@ -286,6 +306,7 @@ static void test_Frame(void)
hr = IDirect3DRMFrame_AddChild(pFrameP2, pFrameC); hr = IDirect3DRMFrame_AddChild(pFrameP2, pFrameC);
todo_wine ok(hr == D3DRM_OK, "Cannot add child frame (hr = %x)\n", hr); todo_wine ok(hr == D3DRM_OK, "Cannot add child frame (hr = %x)\n", hr);
todo_wine CHECK_REFCOUNT(pFrameC, 2);
pArray = NULL; pArray = NULL;
hr = IDirect3DRMFrame_GetChildren(pFrameP2, &pArray); hr = IDirect3DRMFrame_GetChildren(pFrameP2, &pArray);
...@@ -311,10 +332,13 @@ static void test_Frame(void) ...@@ -311,10 +332,13 @@ static void test_Frame(void)
hr = IDirect3DRMFrame_GetParent(pFrameC, &pFrameTmp); hr = IDirect3DRMFrame_GetParent(pFrameC, &pFrameTmp);
todo_wine ok(hr == D3DRM_OK, "Cannot get parent frame (hr = %x)\n", hr); todo_wine ok(hr == D3DRM_OK, "Cannot get parent frame (hr = %x)\n", hr);
todo_wine ok(pFrameTmp == pFrameP2, "pFrameTmp = %p\n", pFrameTmp); todo_wine ok(pFrameTmp == pFrameP2, "pFrameTmp = %p\n", pFrameTmp);
todo_wine CHECK_REFCOUNT(pFrameP2, 2);
todo_wine CHECK_REFCOUNT(pFrameC, 2);
/* Add child again */ /* Add child again */
hr = IDirect3DRMFrame_AddChild(pFrameP2, pFrameC); hr = IDirect3DRMFrame_AddChild(pFrameP2, pFrameC);
todo_wine ok(hr == D3DRM_OK, "Cannot add child frame (hr = %x)\n", hr); todo_wine ok(hr == D3DRM_OK, "Cannot add child frame (hr = %x)\n", hr);
todo_wine CHECK_REFCOUNT(pFrameC, 2);
pArray = NULL; pArray = NULL;
hr = IDirect3DRMFrame_GetChildren(pFrameP2, &pArray); hr = IDirect3DRMFrame_GetChildren(pFrameP2, &pArray);
...@@ -329,6 +353,7 @@ static void test_Frame(void) ...@@ -329,6 +353,7 @@ static void test_Frame(void)
/* Delete child */ /* Delete child */
hr = IDirect3DRMFrame_DeleteChild(pFrameP2, pFrameC); hr = IDirect3DRMFrame_DeleteChild(pFrameP2, pFrameC);
todo_wine ok(hr == D3DRM_OK, "Cannot delete child frame (hr = %x)\n", hr); todo_wine ok(hr == D3DRM_OK, "Cannot delete child frame (hr = %x)\n", hr);
CHECK_REFCOUNT(pFrameC, 1);
pArray = NULL; pArray = NULL;
hr = IDirect3DRMFrame_GetChildren(pFrameP2, &pArray); hr = IDirect3DRMFrame_GetChildren(pFrameP2, &pArray);
......
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