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
9b1060d0
Commit
9b1060d0
authored
Jul 05, 2011
by
Andrew Nguyen
Committed by
Alexandre Julliard
Jul 06, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dinput: Add tests for IDirectInput::EnumDevices and add a parameter check.
parent
324c76f3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
84 additions
and
0 deletions
+84
-0
dinput_main.c
dlls/dinput/dinput_main.c
+6
-0
dinput.c
dlls/dinput/tests/dinput.c
+78
-0
No files found.
dlls/dinput/dinput_main.c
View file @
9b1060d0
...
...
@@ -325,6 +325,9 @@ static HRESULT WINAPI IDirectInputAImpl_EnumDevices(
lpCallback
,
pvRef
,
dwFlags
);
_dump_EnumDevices_dwFlags
(
dwFlags
);
if
(
!
lpCallback
)
return
DIERR_INVALIDPARAM
;
for
(
i
=
0
;
i
<
NB_DINPUT_DEVICES
;
i
++
)
{
if
(
!
dinput_devices
[
i
]
->
enum_deviceA
)
continue
;
for
(
j
=
0
,
r
=
-
1
;
r
!=
0
;
j
++
)
{
...
...
@@ -356,6 +359,9 @@ static HRESULT WINAPI IDirectInputWImpl_EnumDevices(
lpCallback
,
pvRef
,
dwFlags
);
_dump_EnumDevices_dwFlags
(
dwFlags
);
if
(
!
lpCallback
)
return
DIERR_INVALIDPARAM
;
for
(
i
=
0
;
i
<
NB_DINPUT_DEVICES
;
i
++
)
{
if
(
!
dinput_devices
[
i
]
->
enum_deviceW
)
continue
;
for
(
j
=
0
,
r
=
-
1
;
r
!=
0
;
j
++
)
{
...
...
dlls/dinput/tests/dinput.c
View file @
9b1060d0
...
...
@@ -168,6 +168,83 @@ static void test_CreateDevice(void)
IDirectInput_Release
(
pDI
);
}
struct
enum_devices_test
{
unsigned
int
device_count
;
BOOL
return_value
;
};
static
BOOL
CALLBACK
enum_devices_callback
(
const
DIDEVICEINSTANCEA
*
instance
,
void
*
context
)
{
struct
enum_devices_test
*
enum_test
=
context
;
enum_test
->
device_count
++
;
return
enum_test
->
return_value
;
}
static
void
test_EnumDevices
(
void
)
{
IDirectInputA
*
pDI
;
HRESULT
hr
;
struct
enum_devices_test
enum_test
,
enum_test_return
;
hr
=
DirectInputCreateA
(
hInstance
,
DIRECTINPUT_VERSION
,
&
pDI
,
NULL
);
if
(
FAILED
(
hr
))
{
win_skip
(
"Failed to instantiate a IDirectInputA instance: 0x%08x
\n
"
,
hr
);
return
;
}
hr
=
IDirectInput_EnumDevices
(
pDI
,
0
,
NULL
,
NULL
,
0
);
ok
(
hr
==
DIERR_INVALIDPARAM
,
"IDirectInput_EnumDevices returned 0x%08x
\n
"
,
hr
);
hr
=
IDirectInput_EnumDevices
(
pDI
,
0
,
NULL
,
NULL
,
~
0u
);
ok
(
hr
==
DIERR_INVALIDPARAM
,
"IDirectInput_EnumDevices returned 0x%08x
\n
"
,
hr
);
/* Test crashes on Wine. */
if
(
0
)
{
hr
=
IDirectInput_EnumDevices
(
pDI
,
0
,
enum_devices_callback
,
NULL
,
~
0u
);
ok
(
hr
==
DIERR_INVALIDPARAM
,
"IDirectInput_EnumDevices returned 0x%08x
\n
"
,
hr
);
}
hr
=
IDirectInput_EnumDevices
(
pDI
,
0xdeadbeef
,
NULL
,
NULL
,
0
);
ok
(
hr
==
DIERR_INVALIDPARAM
,
"IDirectInput_EnumDevices returned 0x%08x
\n
"
,
hr
);
hr
=
IDirectInput_EnumDevices
(
pDI
,
0xdeadbeef
,
NULL
,
NULL
,
~
0u
);
ok
(
hr
==
DIERR_INVALIDPARAM
,
"IDirectInput_EnumDevices returned 0x%08x
\n
"
,
hr
);
hr
=
IDirectInput_EnumDevices
(
pDI
,
0xdeadbeef
,
enum_devices_callback
,
NULL
,
0
);
todo_wine
ok
(
hr
==
DIERR_INVALIDPARAM
,
"IDirectInput_EnumDevices returned 0x%08x
\n
"
,
hr
);
hr
=
IDirectInput_EnumDevices
(
pDI
,
0xdeadbeef
,
enum_devices_callback
,
NULL
,
~
0u
);
todo_wine
ok
(
hr
==
DIERR_INVALIDPARAM
,
"IDirectInput_EnumDevices returned 0x%08x
\n
"
,
hr
);
enum_test
.
device_count
=
0
;
enum_test
.
return_value
=
DIENUM_CONTINUE
;
hr
=
IDirectInput_EnumDevices
(
pDI
,
0
,
enum_devices_callback
,
&
enum_test
,
0
);
ok
(
hr
==
DI_OK
,
"IDirectInput_EnumDevices returned 0x%08x
\n
"
,
hr
);
ok
(
enum_test
.
device_count
!=
0
,
"Device count is %u
\n
"
,
enum_test
.
device_count
);
/* Enumeration only stops with an explicit DIENUM_STOP. */
enum_test_return
.
device_count
=
0
;
enum_test_return
.
return_value
=
42
;
hr
=
IDirectInput_EnumDevices
(
pDI
,
0
,
enum_devices_callback
,
&
enum_test_return
,
0
);
ok
(
hr
==
DI_OK
,
"IDirectInput_EnumDevices returned 0x%08x
\n
"
,
hr
);
ok
(
enum_test_return
.
device_count
==
enum_test
.
device_count
,
"Device count is %u vs. %u
\n
"
,
enum_test_return
.
device_count
,
enum_test
.
device_count
);
enum_test
.
device_count
=
0
;
enum_test
.
return_value
=
DIENUM_STOP
;
hr
=
IDirectInput_EnumDevices
(
pDI
,
0
,
enum_devices_callback
,
&
enum_test
,
0
);
ok
(
hr
==
DI_OK
,
"IDirectInput_EnumDevices returned 0x%08x
\n
"
,
hr
);
ok
(
enum_test
.
device_count
==
1
,
"Device count is %u
\n
"
,
enum_test
.
device_count
);
IDirectInput_Release
(
pDI
);
}
static
void
test_Initialize
(
void
)
{
IDirectInputA
*
pDI
;
...
...
@@ -251,6 +328,7 @@ START_TEST(dinput)
CoInitialize
(
NULL
);
test_QueryInterface
();
test_CreateDevice
();
test_EnumDevices
();
test_Initialize
();
test_RunControlPanel
();
CoUninitialize
();
...
...
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