Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
73abda63
Commit
73abda63
authored
May 19, 2009
by
Luke Benstead
Committed by
Alexandre Julliard
May 20, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ddraw: Add tests for DirectDrawSurface reference counting.
parent
abc68c1c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
114 additions
and
0 deletions
+114
-0
dsurface.c
dlls/ddraw/tests/dsurface.c
+114
-0
No files found.
dlls/ddraw/tests/dsurface.c
View file @
73abda63
...
...
@@ -26,6 +26,7 @@
#include <assert.h>
#include "wine/test.h"
#include "ddraw.h"
#include "d3d.h"
#include "unknwn.h"
static
LPDIRECTDRAW
lpDD
=
NULL
;
...
...
@@ -966,6 +967,118 @@ static void GetDDInterface_7(void)
IDirectDrawSurface7_Release
(
dsurface7
);
}
static
ULONG
getRefcount
(
IUnknown
*
iface
)
{
IUnknown_AddRef
(
iface
);
return
IUnknown_Release
(
iface
);
}
static
void
IFaceRefCount
(
void
)
{
LPDIRECTDRAWSURFACE
surf
;
DDSURFACEDESC
surface
;
HRESULT
ret
;
IDirectDrawSurface2
*
surf2
;
IDirectDrawSurface2
*
surf2a
;
IDirectDrawSurface4
*
surf4
;
IDirectDrawSurface7
*
surf7a
;
IDirectDrawSurface7
*
surf7b
;
IDirect3DTexture
*
tex
;
IDirect3DTexture2
*
tex2
;
IDirectDrawGammaControl
*
gamma
;
ULONG
ref
;
/* Create a surface */
ZeroMemory
(
&
surface
,
sizeof
(
surface
));
surface
.
dwSize
=
sizeof
(
surface
);
surface
.
dwFlags
=
DDSD_CAPS
;
surface
.
ddsCaps
.
dwCaps
=
DDSCAPS_PRIMARYSURFACE
;
ret
=
IDirectDraw_CreateSurface
(
lpDD
,
&
surface
,
&
surf
,
NULL
);
if
(
ret
!=
DD_OK
)
{
ok
(
FALSE
,
"Could not create surface, skipping test
\n
"
);
return
;
}
ref
=
getRefcount
((
IUnknown
*
)
surf
);
ok
(
ref
==
1
,
"Refcount is %u, expected 1
\n
"
,
ref
);
/* Check the ref count is one */
IDirectDrawSurface_QueryInterface
(
surf
,
&
IID_IDirectDrawSurface2
,
(
void
**
)
&
surf2
);
ref
=
getRefcount
((
IUnknown
*
)
surf
);
todo_wine
ok
(
ref
==
1
,
"Refcount is %u, expected 1
\n
"
,
ref
);
/* Check the ref count is one */
ref
=
getRefcount
((
IUnknown
*
)
surf2
);
todo_wine
ok
(
ref
==
1
,
"Refcount is %u, expected 1
\n
"
,
ref
);
/* This should also be one */
IDirectDrawSurface_QueryInterface
(
surf
,
&
IID_IDirectDrawSurface2
,
(
void
**
)
&
surf2a
);
ref
=
getRefcount
((
IUnknown
*
)
surf2
);
todo_wine
ok
(
ref
==
2
,
"Refcount is %u, expected 2
\n
"
,
ref
);
/* Surf2's refcount should be 2 now, but surf should be 1 */
ref
=
getRefcount
((
IUnknown
*
)
surf
);
todo_wine
ok
(
ref
==
1
,
"Refcount is %u, expected 1
\n
"
,
ref
);
IDirectDrawSurface_QueryInterface
(
surf
,
&
IID_IDirectDrawSurface4
,
(
void
**
)
&
surf4
);
ref
=
getRefcount
((
IUnknown
*
)
surf4
);
todo_wine
ok
(
ref
==
1
,
"Refcount is %u, expected 1
\n
"
,
ref
);
IDirectDrawSurface_QueryInterface
(
surf
,
&
IID_IDirectDrawSurface7
,
(
void
**
)
&
surf7a
);
ref
=
getRefcount
((
IUnknown
*
)
surf7a
);
todo_wine
ok
(
ref
==
1
,
"Refcount is %u, expected 1
\n
"
,
ref
);
IDirectDrawSurface_QueryInterface
(
surf
,
&
IID_IDirectDrawSurface7
,
(
void
**
)
&
surf7b
);
ref
=
getRefcount
((
IUnknown
*
)
surf7b
);
todo_wine
ok
(
ref
==
2
,
"Refcount is %u, expected 2
\n
"
,
ref
);
/* IDirect3DTexture interface (unlike the others) alters the original IDirectDrawSurface ref count */
IDirectDrawSurface_QueryInterface
(
surf
,
&
IID_IDirect3DTexture
,
(
void
**
)
&
tex
);
ref
=
getRefcount
((
IUnknown
*
)
tex
);
todo_wine
ok
(
ref
==
2
,
"Refcount is %u, expected 2
\n
"
,
ref
);
ref
=
getRefcount
((
IUnknown
*
)
surf
);
todo_wine
ok
(
ref
==
2
,
"Refcount is %u, expected 2
\n
"
,
ref
);
IDirectDrawSurface_QueryInterface
(
surf
,
&
IID_IDirect3DTexture2
,
(
void
**
)
&
tex2
);
ref
=
getRefcount
((
IUnknown
*
)
tex
);
todo_wine
ok
(
ref
==
3
,
"Refcount is %u, expected 3
\n
"
,
ref
);
ref
=
getRefcount
((
IUnknown
*
)
tex2
);
todo_wine
ok
(
ref
==
3
,
"Refcount is %u, expected 3
\n
"
,
ref
);
ref
=
getRefcount
((
IUnknown
*
)
surf
);
todo_wine
ok
(
ref
==
3
,
"Refcount is %u, expected 3
\n
"
,
ref
);
IDirectDrawSurface_QueryInterface
(
surf
,
&
IID_IDirectDrawGammaControl
,
(
void
**
)
&
gamma
);
ref
=
getRefcount
((
IUnknown
*
)
gamma
);
todo_wine
ok
(
ref
==
1
,
"Refcount is %u, expected 1
\n
"
,
ref
);
ref
=
IDirect3DTexture2_Release
(
tex2
);
/* Release the texture */
todo_wine
ok
(
ref
==
2
,
"Refcount is %u, expected 2
\n
"
,
ref
);
ref
=
getRefcount
((
IUnknown
*
)
surf
);
todo_wine
ok
(
ref
==
2
,
"Refcount is %u, expected 2
\n
"
,
ref
);
ref
=
IDirect3DTexture_Release
(
tex
);
/* Release the texture */
todo_wine
ok
(
ref
==
1
,
"Refcount is %u, expected 1
\n
"
,
ref
);
ref
=
getRefcount
((
IUnknown
*
)
surf
);
todo_wine
ok
(
ref
==
1
,
"Refcount is %u, expected 1
\n
"
,
ref
);
ref
=
IDirectDrawGammaControl_Release
(
gamma
);
/* Release the gamma control */
todo_wine
ok
(
ref
==
0
,
"Refcount is %u, expected 0
\n
"
,
ref
);
ref
=
IDirectDrawSurface2_Release
(
surf2
);
/* Release one of the 2 surf2 interfaces */
todo_wine
ok
(
ref
==
1
,
"Refcount is %u, expected 1
\n
"
,
ref
);
ref
=
IDirectDrawSurface2_Release
(
surf2a
);
/* Release the other */
todo_wine
ok
(
ref
==
0
,
"Refcount is %u, expected 0
\n
"
,
ref
);
ref
=
IDirectDrawSurface4_Release
(
surf4
);
todo_wine
ok
(
ref
==
0
,
"Refcount is %u, expected 0
\n
"
,
ref
);
ref
=
IDirectDrawSurface7_Release
(
surf7a
);
todo_wine
ok
(
ref
==
1
,
"Refcount is %u, expected 1
\n
"
,
ref
);
ref
=
IDirectDrawSurface7_Release
(
surf7b
);
todo_wine
ok
(
ref
==
0
,
"Refcount is %u, expected 0
\n
"
,
ref
);
ref
=
IDirectDrawSurface_Release
(
surf
);
ok
(
ref
==
0
,
"Refcount is %u, expected 0
\n
"
,
ref
);
}
#define MAXEXPECTED 8
/* Can match up to 8 expected surfaces */
struct
enumstruct
{
...
...
@@ -2908,6 +3021,7 @@ START_TEST(dsurface)
GetDDInterface_2
();
GetDDInterface_4
();
GetDDInterface_7
();
IFaceRefCount
();
EnumTest
();
AttachmentTest
();
AttachmentTest7
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment