Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
1b4c55df
Commit
1b4c55df
authored
Jun 27, 2014
by
Henri Verbeet
Committed by
Alexandre Julliard
Jun 27, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ddraw/tests: Add some lost device tests.
parent
e6de1cbd
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
434 additions
and
2 deletions
+434
-2
ddraw1.c
dlls/ddraw/tests/ddraw1.c
+99
-1
ddraw2.c
dlls/ddraw/tests/ddraw2.c
+99
-1
ddraw4.c
dlls/ddraw/tests/ddraw4.c
+118
-0
ddraw7.c
dlls/ddraw/tests/ddraw7.c
+118
-0
No files found.
dlls/ddraw/tests/ddraw1.c
View file @
1b4c55df
...
...
@@ -459,7 +459,7 @@ static void fix_wndproc(HWND window, LONG_PTR proc)
static
HRESULT
CALLBACK
restore_callback
(
IDirectDrawSurface
*
surface
,
DDSURFACEDESC
*
desc
,
void
*
context
)
{
HRESULT
hr
=
IDirectDrawSurface_Restore
(
surface
);
ok
(
SUCCEEDED
(
hr
),
"Failed to restore surface, hr %#x.
\n
"
,
hr
);
ok
(
SUCCEEDED
(
hr
)
||
hr
==
DDERR_IMPLICITLYCREATED
,
"Failed to restore surface, hr %#x.
\n
"
,
hr
);
IDirectDrawSurface_Release
(
surface
);
return
DDENUMRET_OK
;
...
...
@@ -5478,6 +5478,103 @@ static void test_palette_alpha(void)
DestroyWindow
(
window
);
}
static
void
test_lost_device
(
void
)
{
IDirectDrawSurface
*
surface
;
DDSURFACEDESC
surface_desc
;
IDirectDraw
*
ddraw
;
ULONG
refcount
;
HWND
window
;
HRESULT
hr
;
BOOL
ret
;
window
=
CreateWindowA
(
"static"
,
"ddraw_test"
,
WS_OVERLAPPEDWINDOW
,
0
,
0
,
640
,
480
,
0
,
0
,
0
,
0
);
ddraw
=
create_ddraw
();
ok
(
!!
ddraw
,
"Failed to create a ddraw object.
\n
"
);
hr
=
IDirectDraw_SetCooperativeLevel
(
ddraw
,
window
,
DDSCL_EXCLUSIVE
|
DDSCL_FULLSCREEN
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set cooperative level, hr %#x.
\n
"
,
hr
);
memset
(
&
surface_desc
,
0
,
sizeof
(
surface_desc
));
surface_desc
.
dwSize
=
sizeof
(
surface_desc
);
surface_desc
.
dwFlags
=
DDSD_CAPS
|
DDSD_BACKBUFFERCOUNT
;
surface_desc
.
ddsCaps
.
dwCaps
=
DDSCAPS_PRIMARYSURFACE
|
DDSCAPS_COMPLEX
|
DDSCAPS_FLIP
;
surface_desc
.
dwBackBufferCount
=
1
;
hr
=
IDirectDraw_CreateSurface
(
ddraw
,
&
surface_desc
,
&
surface
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create surface, hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface_IsLost
(
surface
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface_Flip
(
surface
,
NULL
,
DDFLIP_WAIT
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
ret
=
SetForegroundWindow
(
GetDesktopWindow
());
ok
(
ret
,
"Failed to set foreground window.
\n
"
);
hr
=
IDirectDrawSurface_IsLost
(
surface
);
todo_wine
ok
(
hr
==
DDERR_SURFACELOST
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface_Flip
(
surface
,
NULL
,
DDFLIP_WAIT
);
todo_wine
ok
(
hr
==
DDERR_SURFACELOST
,
"Got unexpected hr %#x.
\n
"
,
hr
);
ret
=
SetForegroundWindow
(
window
);
ok
(
ret
,
"Failed to set foreground window.
\n
"
);
hr
=
IDirectDrawSurface_IsLost
(
surface
);
todo_wine
ok
(
hr
==
DDERR_SURFACELOST
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface_Flip
(
surface
,
NULL
,
DDFLIP_WAIT
);
todo_wine
ok
(
hr
==
DDERR_SURFACELOST
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
restore_surfaces
(
ddraw
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface_IsLost
(
surface
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface_Flip
(
surface
,
NULL
,
DDFLIP_WAIT
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDraw_SetCooperativeLevel
(
ddraw
,
window
,
DDSCL_NORMAL
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface_IsLost
(
surface
);
todo_wine
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface_Flip
(
surface
,
NULL
,
DDFLIP_WAIT
);
todo_wine
ok
(
hr
==
DDERR_NOEXCLUSIVEMODE
,
"Got unexpected hr %#x.
\n
"
,
hr
);
/* Trying to restore the primary will crash, probably because flippable
* surfaces can't exist in DDSCL_NORMAL. */
IDirectDrawSurface_Release
(
surface
);
memset
(
&
surface_desc
,
0
,
sizeof
(
surface_desc
));
surface_desc
.
dwSize
=
sizeof
(
surface_desc
);
surface_desc
.
dwFlags
=
DDSD_CAPS
;
surface_desc
.
ddsCaps
.
dwCaps
=
DDSCAPS_PRIMARYSURFACE
;
hr
=
IDirectDraw_CreateSurface
(
ddraw
,
&
surface_desc
,
&
surface
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create surface, hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface_IsLost
(
surface
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
ret
=
SetForegroundWindow
(
GetDesktopWindow
());
ok
(
ret
,
"Failed to set foreground window.
\n
"
);
hr
=
IDirectDrawSurface_IsLost
(
surface
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
ret
=
SetForegroundWindow
(
window
);
ok
(
ret
,
"Failed to set foreground window.
\n
"
);
hr
=
IDirectDrawSurface_IsLost
(
surface
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDraw_SetCooperativeLevel
(
ddraw
,
window
,
DDSCL_EXCLUSIVE
|
DDSCL_FULLSCREEN
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface_IsLost
(
surface
);
ok
(
hr
==
DDERR_SURFACELOST
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
restore_surfaces
(
ddraw
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface_IsLost
(
surface
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
IDirectDrawSurface_Release
(
surface
);
refcount
=
IDirectDraw_Release
(
ddraw
);
ok
(
!
refcount
,
"Got unexpected refcount %u.
\n
"
,
refcount
);
DestroyWindow
(
window
);
}
START_TEST
(
ddraw1
)
{
IDirectDraw
*
ddraw
;
...
...
@@ -5528,4 +5625,5 @@ START_TEST(ddraw1)
test_material
();
test_palette_gdi
();
test_palette_alpha
();
test_lost_device
();
}
dlls/ddraw/tests/ddraw2.c
View file @
1b4c55df
...
...
@@ -392,7 +392,7 @@ static void fix_wndproc(HWND window, LONG_PTR proc)
static
HRESULT
CALLBACK
restore_callback
(
IDirectDrawSurface
*
surface
,
DDSURFACEDESC
*
desc
,
void
*
context
)
{
HRESULT
hr
=
IDirectDrawSurface_Restore
(
surface
);
ok
(
SUCCEEDED
(
hr
),
"Failed to restore surface, hr %#x.
\n
"
,
hr
);
ok
(
SUCCEEDED
(
hr
)
||
hr
==
DDERR_IMPLICITLYCREATED
,
"Failed to restore surface, hr %#x.
\n
"
,
hr
);
IDirectDrawSurface_Release
(
surface
);
return
DDENUMRET_OK
;
...
...
@@ -6554,6 +6554,103 @@ static void test_palette_alpha(void)
DestroyWindow
(
window
);
}
static
void
test_lost_device
(
void
)
{
IDirectDrawSurface
*
surface
;
DDSURFACEDESC
surface_desc
;
IDirectDraw2
*
ddraw
;
ULONG
refcount
;
HWND
window
;
HRESULT
hr
;
BOOL
ret
;
window
=
CreateWindowA
(
"static"
,
"ddraw_test"
,
WS_OVERLAPPEDWINDOW
,
0
,
0
,
640
,
480
,
0
,
0
,
0
,
0
);
ddraw
=
create_ddraw
();
ok
(
!!
ddraw
,
"Failed to create a ddraw object.
\n
"
);
hr
=
IDirectDraw2_SetCooperativeLevel
(
ddraw
,
window
,
DDSCL_EXCLUSIVE
|
DDSCL_FULLSCREEN
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set cooperative level, hr %#x.
\n
"
,
hr
);
memset
(
&
surface_desc
,
0
,
sizeof
(
surface_desc
));
surface_desc
.
dwSize
=
sizeof
(
surface_desc
);
surface_desc
.
dwFlags
=
DDSD_CAPS
|
DDSD_BACKBUFFERCOUNT
;
surface_desc
.
ddsCaps
.
dwCaps
=
DDSCAPS_PRIMARYSURFACE
|
DDSCAPS_COMPLEX
|
DDSCAPS_FLIP
;
surface_desc
.
dwBackBufferCount
=
1
;
hr
=
IDirectDraw2_CreateSurface
(
ddraw
,
&
surface_desc
,
&
surface
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create surface, hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface_IsLost
(
surface
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface_Flip
(
surface
,
NULL
,
DDFLIP_WAIT
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
ret
=
SetForegroundWindow
(
GetDesktopWindow
());
ok
(
ret
,
"Failed to set foreground window.
\n
"
);
hr
=
IDirectDrawSurface_IsLost
(
surface
);
todo_wine
ok
(
hr
==
DDERR_SURFACELOST
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface_Flip
(
surface
,
NULL
,
DDFLIP_WAIT
);
todo_wine
ok
(
hr
==
DDERR_SURFACELOST
,
"Got unexpected hr %#x.
\n
"
,
hr
);
ret
=
SetForegroundWindow
(
window
);
ok
(
ret
,
"Failed to set foreground window.
\n
"
);
hr
=
IDirectDrawSurface_IsLost
(
surface
);
todo_wine
ok
(
hr
==
DDERR_SURFACELOST
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface_Flip
(
surface
,
NULL
,
DDFLIP_WAIT
);
todo_wine
ok
(
hr
==
DDERR_SURFACELOST
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
restore_surfaces
(
ddraw
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface_IsLost
(
surface
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface_Flip
(
surface
,
NULL
,
DDFLIP_WAIT
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDraw2_SetCooperativeLevel
(
ddraw
,
window
,
DDSCL_NORMAL
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface_IsLost
(
surface
);
ok
(
hr
==
DDERR_SURFACELOST
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface_Flip
(
surface
,
NULL
,
DDFLIP_WAIT
);
todo_wine
ok
(
hr
==
DDERR_SURFACELOST
,
"Got unexpected hr %#x.
\n
"
,
hr
);
/* Trying to restore the primary will crash, probably because flippable
* surfaces can't exist in DDSCL_NORMAL. */
IDirectDrawSurface_Release
(
surface
);
memset
(
&
surface_desc
,
0
,
sizeof
(
surface_desc
));
surface_desc
.
dwSize
=
sizeof
(
surface_desc
);
surface_desc
.
dwFlags
=
DDSD_CAPS
;
surface_desc
.
ddsCaps
.
dwCaps
=
DDSCAPS_PRIMARYSURFACE
;
hr
=
IDirectDraw2_CreateSurface
(
ddraw
,
&
surface_desc
,
&
surface
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create surface, hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface_IsLost
(
surface
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
ret
=
SetForegroundWindow
(
GetDesktopWindow
());
ok
(
ret
,
"Failed to set foreground window.
\n
"
);
hr
=
IDirectDrawSurface_IsLost
(
surface
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
ret
=
SetForegroundWindow
(
window
);
ok
(
ret
,
"Failed to set foreground window.
\n
"
);
hr
=
IDirectDrawSurface_IsLost
(
surface
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDraw2_SetCooperativeLevel
(
ddraw
,
window
,
DDSCL_EXCLUSIVE
|
DDSCL_FULLSCREEN
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface_IsLost
(
surface
);
ok
(
hr
==
DDERR_SURFACELOST
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
restore_surfaces
(
ddraw
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface_IsLost
(
surface
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
IDirectDrawSurface_Release
(
surface
);
refcount
=
IDirectDraw2_Release
(
ddraw
);
ok
(
!
refcount
,
"Got unexpected refcount %u.
\n
"
,
refcount
);
DestroyWindow
(
window
);
}
START_TEST
(
ddraw2
)
{
IDirectDraw2
*
ddraw
;
...
...
@@ -6610,4 +6707,5 @@ START_TEST(ddraw2)
test_material
();
test_palette_gdi
();
test_palette_alpha
();
test_lost_device
();
}
dlls/ddraw/tests/ddraw4.c
View file @
1b4c55df
...
...
@@ -7609,6 +7609,123 @@ static void test_vb_writeonly(void)
DestroyWindow
(
window
);
}
static
void
test_lost_device
(
void
)
{
IDirectDrawSurface4
*
surface
;
DDSURFACEDESC2
surface_desc
;
IDirectDraw4
*
ddraw
;
ULONG
refcount
;
HWND
window
;
HRESULT
hr
;
BOOL
ret
;
window
=
CreateWindowA
(
"static"
,
"ddraw_test"
,
WS_OVERLAPPEDWINDOW
,
0
,
0
,
640
,
480
,
0
,
0
,
0
,
0
);
ddraw
=
create_ddraw
();
ok
(
!!
ddraw
,
"Failed to create a ddraw object.
\n
"
);
hr
=
IDirectDraw4_SetCooperativeLevel
(
ddraw
,
window
,
DDSCL_EXCLUSIVE
|
DDSCL_FULLSCREEN
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set cooperative level, hr %#x.
\n
"
,
hr
);
memset
(
&
surface_desc
,
0
,
sizeof
(
surface_desc
));
surface_desc
.
dwSize
=
sizeof
(
surface_desc
);
surface_desc
.
dwFlags
=
DDSD_CAPS
|
DDSD_BACKBUFFERCOUNT
;
surface_desc
.
ddsCaps
.
dwCaps
=
DDSCAPS_PRIMARYSURFACE
|
DDSCAPS_COMPLEX
|
DDSCAPS_FLIP
;
surface_desc
.
dwBackBufferCount
=
1
;
hr
=
IDirectDraw4_CreateSurface
(
ddraw
,
&
surface_desc
,
&
surface
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create surface, hr %#x.
\n
"
,
hr
);
hr
=
IDirectDraw4_TestCooperativeLevel
(
ddraw
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface4_IsLost
(
surface
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface4_Flip
(
surface
,
NULL
,
DDFLIP_WAIT
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
ret
=
SetForegroundWindow
(
GetDesktopWindow
());
ok
(
ret
,
"Failed to set foreground window.
\n
"
);
hr
=
IDirectDraw4_TestCooperativeLevel
(
ddraw
);
todo_wine
ok
(
hr
==
DDERR_NOEXCLUSIVEMODE
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface4_IsLost
(
surface
);
todo_wine
ok
(
hr
==
DDERR_SURFACELOST
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface4_Flip
(
surface
,
NULL
,
DDFLIP_WAIT
);
todo_wine
ok
(
hr
==
DDERR_SURFACELOST
,
"Got unexpected hr %#x.
\n
"
,
hr
);
ret
=
SetForegroundWindow
(
window
);
ok
(
ret
,
"Failed to set foreground window.
\n
"
);
hr
=
IDirectDraw4_TestCooperativeLevel
(
ddraw
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface4_IsLost
(
surface
);
todo_wine
ok
(
hr
==
DDERR_SURFACELOST
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface4_Flip
(
surface
,
NULL
,
DDFLIP_WAIT
);
todo_wine
ok
(
hr
==
DDERR_SURFACELOST
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDraw4_RestoreAllSurfaces
(
ddraw
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDraw4_TestCooperativeLevel
(
ddraw
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface4_IsLost
(
surface
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface4_Flip
(
surface
,
NULL
,
DDFLIP_WAIT
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDraw4_SetCooperativeLevel
(
ddraw
,
window
,
DDSCL_NORMAL
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDraw4_TestCooperativeLevel
(
ddraw
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface4_IsLost
(
surface
);
ok
(
hr
==
DDERR_SURFACELOST
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface4_Flip
(
surface
,
NULL
,
DDFLIP_WAIT
);
todo_wine
ok
(
hr
==
DDERR_SURFACELOST
,
"Got unexpected hr %#x.
\n
"
,
hr
);
/* Trying to restore the primary will crash, probably because flippable
* surfaces can't exist in DDSCL_NORMAL. */
IDirectDrawSurface4_Release
(
surface
);
memset
(
&
surface_desc
,
0
,
sizeof
(
surface_desc
));
surface_desc
.
dwSize
=
sizeof
(
surface_desc
);
surface_desc
.
dwFlags
=
DDSD_CAPS
;
surface_desc
.
ddsCaps
.
dwCaps
=
DDSCAPS_PRIMARYSURFACE
;
hr
=
IDirectDraw4_CreateSurface
(
ddraw
,
&
surface_desc
,
&
surface
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create surface, hr %#x.
\n
"
,
hr
);
hr
=
IDirectDraw4_TestCooperativeLevel
(
ddraw
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface4_IsLost
(
surface
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
ret
=
SetForegroundWindow
(
GetDesktopWindow
());
ok
(
ret
,
"Failed to set foreground window.
\n
"
);
hr
=
IDirectDraw4_TestCooperativeLevel
(
ddraw
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface4_IsLost
(
surface
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
ret
=
SetForegroundWindow
(
window
);
ok
(
ret
,
"Failed to set foreground window.
\n
"
);
hr
=
IDirectDraw4_TestCooperativeLevel
(
ddraw
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface4_IsLost
(
surface
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDraw4_SetCooperativeLevel
(
ddraw
,
window
,
DDSCL_EXCLUSIVE
|
DDSCL_FULLSCREEN
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDraw4_TestCooperativeLevel
(
ddraw
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface4_IsLost
(
surface
);
ok
(
hr
==
DDERR_SURFACELOST
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDraw4_RestoreAllSurfaces
(
ddraw
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDraw4_TestCooperativeLevel
(
ddraw
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface4_IsLost
(
surface
);
todo_wine
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
IDirectDrawSurface4_Release
(
surface
);
refcount
=
IDirectDraw4_Release
(
ddraw
);
ok
(
!
refcount
,
"Got unexpected refcount %u.
\n
"
,
refcount
);
DestroyWindow
(
window
);
}
START_TEST
(
ddraw4
)
{
IDirectDraw4
*
ddraw
;
...
...
@@ -7672,4 +7789,5 @@ START_TEST(ddraw4)
test_palette_gdi
();
test_palette_alpha
();
test_vb_writeonly
();
test_lost_device
();
}
dlls/ddraw/tests/ddraw7.c
View file @
1b4c55df
...
...
@@ -7331,6 +7331,123 @@ static void test_vb_writeonly(void)
DestroyWindow
(
window
);
}
static
void
test_lost_device
(
void
)
{
IDirectDrawSurface7
*
surface
;
DDSURFACEDESC2
surface_desc
;
IDirectDraw7
*
ddraw
;
ULONG
refcount
;
HWND
window
;
HRESULT
hr
;
BOOL
ret
;
window
=
CreateWindowA
(
"static"
,
"ddraw_test"
,
WS_OVERLAPPEDWINDOW
,
0
,
0
,
640
,
480
,
0
,
0
,
0
,
0
);
ddraw
=
create_ddraw
();
ok
(
!!
ddraw
,
"Failed to create a ddraw object.
\n
"
);
hr
=
IDirectDraw7_SetCooperativeLevel
(
ddraw
,
window
,
DDSCL_EXCLUSIVE
|
DDSCL_FULLSCREEN
);
ok
(
SUCCEEDED
(
hr
),
"Failed to set cooperative level, hr %#x.
\n
"
,
hr
);
memset
(
&
surface_desc
,
0
,
sizeof
(
surface_desc
));
surface_desc
.
dwSize
=
sizeof
(
surface_desc
);
surface_desc
.
dwFlags
=
DDSD_CAPS
|
DDSD_BACKBUFFERCOUNT
;
surface_desc
.
ddsCaps
.
dwCaps
=
DDSCAPS_PRIMARYSURFACE
|
DDSCAPS_COMPLEX
|
DDSCAPS_FLIP
;
surface_desc
.
dwBackBufferCount
=
1
;
hr
=
IDirectDraw7_CreateSurface
(
ddraw
,
&
surface_desc
,
&
surface
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create surface, hr %#x.
\n
"
,
hr
);
hr
=
IDirectDraw7_TestCooperativeLevel
(
ddraw
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface7_IsLost
(
surface
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface7_Flip
(
surface
,
NULL
,
DDFLIP_WAIT
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
ret
=
SetForegroundWindow
(
GetDesktopWindow
());
ok
(
ret
,
"Failed to set foreground window.
\n
"
);
hr
=
IDirectDraw7_TestCooperativeLevel
(
ddraw
);
todo_wine
ok
(
hr
==
DDERR_NOEXCLUSIVEMODE
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface7_IsLost
(
surface
);
todo_wine
ok
(
hr
==
DDERR_SURFACELOST
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface7_Flip
(
surface
,
NULL
,
DDFLIP_WAIT
);
todo_wine
ok
(
hr
==
DDERR_SURFACELOST
,
"Got unexpected hr %#x.
\n
"
,
hr
);
ret
=
SetForegroundWindow
(
window
);
ok
(
ret
,
"Failed to set foreground window.
\n
"
);
hr
=
IDirectDraw7_TestCooperativeLevel
(
ddraw
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface7_IsLost
(
surface
);
todo_wine
ok
(
hr
==
DDERR_SURFACELOST
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface7_Flip
(
surface
,
NULL
,
DDFLIP_WAIT
);
todo_wine
ok
(
hr
==
DDERR_SURFACELOST
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDraw7_RestoreAllSurfaces
(
ddraw
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDraw7_TestCooperativeLevel
(
ddraw
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface7_IsLost
(
surface
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface7_Flip
(
surface
,
NULL
,
DDFLIP_WAIT
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDraw7_SetCooperativeLevel
(
ddraw
,
window
,
DDSCL_NORMAL
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDraw7_TestCooperativeLevel
(
ddraw
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface7_IsLost
(
surface
);
ok
(
hr
==
DDERR_SURFACELOST
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface7_Flip
(
surface
,
NULL
,
DDFLIP_WAIT
);
todo_wine
ok
(
hr
==
DDERR_SURFACELOST
,
"Got unexpected hr %#x.
\n
"
,
hr
);
/* Trying to restore the primary will crash, probably because flippable
* surfaces can't exist in DDSCL_NORMAL. */
IDirectDrawSurface7_Release
(
surface
);
memset
(
&
surface_desc
,
0
,
sizeof
(
surface_desc
));
surface_desc
.
dwSize
=
sizeof
(
surface_desc
);
surface_desc
.
dwFlags
=
DDSD_CAPS
;
surface_desc
.
ddsCaps
.
dwCaps
=
DDSCAPS_PRIMARYSURFACE
;
hr
=
IDirectDraw7_CreateSurface
(
ddraw
,
&
surface_desc
,
&
surface
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create surface, hr %#x.
\n
"
,
hr
);
hr
=
IDirectDraw7_TestCooperativeLevel
(
ddraw
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface7_IsLost
(
surface
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
ret
=
SetForegroundWindow
(
GetDesktopWindow
());
ok
(
ret
,
"Failed to set foreground window.
\n
"
);
hr
=
IDirectDraw7_TestCooperativeLevel
(
ddraw
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface7_IsLost
(
surface
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
ret
=
SetForegroundWindow
(
window
);
ok
(
ret
,
"Failed to set foreground window.
\n
"
);
hr
=
IDirectDraw7_TestCooperativeLevel
(
ddraw
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface7_IsLost
(
surface
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDraw7_SetCooperativeLevel
(
ddraw
,
window
,
DDSCL_EXCLUSIVE
|
DDSCL_FULLSCREEN
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDraw7_TestCooperativeLevel
(
ddraw
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface7_IsLost
(
surface
);
ok
(
hr
==
DDERR_SURFACELOST
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDraw7_RestoreAllSurfaces
(
ddraw
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDraw7_TestCooperativeLevel
(
ddraw
);
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface7_IsLost
(
surface
);
todo_wine
ok
(
hr
==
DD_OK
,
"Got unexpected hr %#x.
\n
"
,
hr
);
IDirectDrawSurface7_Release
(
surface
);
refcount
=
IDirectDraw7_Release
(
ddraw
);
ok
(
!
refcount
,
"Got unexpected refcount %u.
\n
"
,
refcount
);
DestroyWindow
(
window
);
}
START_TEST
(
ddraw7
)
{
HMODULE
module
=
GetModuleHandleA
(
"ddraw.dll"
);
...
...
@@ -7401,4 +7518,5 @@ START_TEST(ddraw7)
test_palette_gdi
();
test_palette_alpha
();
test_vb_writeonly
();
test_lost_device
();
}
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