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
0b9b1cbf
Commit
0b9b1cbf
authored
Mar 15, 2019
by
Zhiyi Zhang
Committed by
Alexandre Julliard
Mar 18, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
setupapi/tests: Add SetupDiOpenDeviceInfo() tests.
Signed-off-by:
Zhiyi Zhang
<
zzhang@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
17d58c93
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
148 additions
and
0 deletions
+148
-0
devinst.c
dlls/setupapi/tests/devinst.c
+148
-0
No files found.
dlls/setupapi/tests/devinst.c
View file @
0b9b1cbf
...
...
@@ -737,6 +737,153 @@ static void test_get_device_instance_id(void)
SetupDiDestroyDeviceInfoList
(
set
);
}
static
void
test_open_device_info
(
void
)
{
SP_DEVINFO_DATA
device
=
{
sizeof
(
device
)};
CHAR
id
[
MAX_DEVICE_ID_LEN
+
2
];
HDEVINFO
set
;
DWORD
i
=
0
;
BOOL
ret
;
set
=
SetupDiCreateDeviceInfoList
(
&
guid
,
NULL
);
ok
(
set
!=
INVALID_HANDLE_VALUE
,
"Failed to create device info, error %#x.
\n
"
,
GetLastError
());
/* Open non-existent device */
SetLastError
(
0xdeadbeef
);
ret
=
SetupDiOpenDeviceInfoA
(
set
,
"Root
\\
LEGACY_BOGUS
\\
FFFF"
,
NULL
,
0
,
&
device
);
ok
(
GetLastError
()
==
ERROR_NO_SUCH_DEVINST
,
"Got unexpected error %#x.
\n
"
,
GetLastError
());
ok
(
!
ret
,
"Expected failure.
\n
"
);
check_device_info
(
set
,
0
,
NULL
,
NULL
);
/* Open unregistered device */
ret
=
SetupDiCreateDeviceInfoA
(
set
,
"Root
\\
LEGACY_BOGUS
\\
1000"
,
&
guid
,
NULL
,
NULL
,
0
,
&
device
);
ok
(
ret
,
"Failed to create device, error %#x.
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
ret
=
SetupDiOpenDeviceInfoA
(
set
,
"Root
\\
LEGACY_BOGUS
\\
1000"
,
NULL
,
0
,
&
device
);
ok
(
GetLastError
()
==
ERROR_NO_SUCH_DEVINST
,
"Got unexpected error %#x.
\n
"
,
GetLastError
());
ok
(
!
ret
,
"Expected failure.
\n
"
);
check_device_info
(
set
,
0
,
&
guid
,
"Root
\\
LEGACY_BOGUS
\\
1000"
);
check_device_info
(
set
,
1
,
NULL
,
NULL
);
/* Open registered device */
ret
=
SetupDiCreateDeviceInfoA
(
set
,
"Root
\\
LEGACY_BOGUS
\\
1001"
,
&
guid
,
NULL
,
NULL
,
0
,
&
device
);
ok
(
ret
,
"Failed to create device, error %#x.
\n
"
,
GetLastError
());
ret
=
SetupDiRegisterDeviceInfo
(
set
,
&
device
,
0
,
NULL
,
NULL
,
NULL
);
ok
(
ret
,
"Failed to register device, error %#x.
\n
"
,
GetLastError
());
check_device_info
(
set
,
0
,
&
guid
,
"Root
\\
LEGACY_BOGUS
\\
1000"
);
check_device_info
(
set
,
1
,
&
guid
,
"Root
\\
LEGACY_BOGUS
\\
1001"
);
check_device_info
(
set
,
2
,
NULL
,
NULL
);
SetLastError
(
0xdeadbeef
);
ret
=
SetupDiOpenDeviceInfoA
(
set
,
"Root
\\
LEGACY_BOGUS
\\
1001"
,
NULL
,
0
,
&
device
);
ok
(
GetLastError
()
==
NO_ERROR
,
"Got unexpected error %#x.
\n
"
,
GetLastError
());
ok
(
ret
,
"Failed to open device info
\n
"
);
ret
=
SetupDiGetDeviceInstanceIdA
(
set
,
&
device
,
id
,
sizeof
(
id
),
NULL
);
ok
(
ret
,
"Got unexpected error %#x.
\n
"
,
GetLastError
());
ok
(
!
strcasecmp
(
id
,
"Root
\\
LEGACY_BOGUS
\\
1001"
),
"Got unexpected id %s.
\n
"
,
id
);
check_device_info
(
set
,
0
,
&
guid
,
"Root
\\
LEGACY_BOGUS
\\
1000"
);
check_device_info
(
set
,
1
,
&
guid
,
"Root
\\
LEGACY_BOGUS
\\
1001"
);
check_device_info
(
set
,
2
,
NULL
,
NULL
);
/* Open registered device in an empty device info set */
SetupDiDestroyDeviceInfoList
(
set
);
set
=
SetupDiCreateDeviceInfoList
(
&
guid
,
NULL
);
ok
(
set
!=
INVALID_HANDLE_VALUE
,
"Failed to create device info list, error %#x.
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
ret
=
SetupDiOpenDeviceInfoA
(
set
,
"Root
\\
LEGACY_BOGUS
\\
1001"
,
NULL
,
0
,
&
device
);
ok
(
GetLastError
()
==
NO_ERROR
,
"Got unexpected error %#x.
\n
"
,
GetLastError
());
ok
(
ret
,
"Failed to open device info
\n
"
);
ret
=
SetupDiGetDeviceInstanceIdA
(
set
,
&
device
,
id
,
sizeof
(
id
),
NULL
);
ok
(
ret
,
"Got unexpected error %#x.
\n
"
,
GetLastError
());
ok
(
!
strcasecmp
(
id
,
"Root
\\
LEGACY_BOGUS
\\
1001"
),
"Got unexpected id %s.
\n
"
,
id
);
check_device_info
(
set
,
0
,
&
guid
,
"Root
\\
LEGACY_BOGUS
\\
1001"
);
check_device_info
(
set
,
1
,
NULL
,
NULL
);
/* Open registered device again */
SetLastError
(
0xdeadbeef
);
ret
=
SetupDiOpenDeviceInfoA
(
set
,
"Root
\\
LEGACY_BOGUS
\\
1001"
,
NULL
,
0
,
&
device
);
ok
(
GetLastError
()
==
NO_ERROR
,
"Got unexpected error %#x.
\n
"
,
GetLastError
());
ok
(
ret
,
"Failed to open device info
\n
"
);
ret
=
SetupDiGetDeviceInstanceIdA
(
set
,
&
device
,
id
,
sizeof
(
id
),
NULL
);
ok
(
ret
,
"Got unexpected error %#x.
\n
"
,
GetLastError
());
ok
(
!
strcasecmp
(
id
,
"Root
\\
LEGACY_BOGUS
\\
1001"
),
"Got unexpected id %s.
\n
"
,
id
);
check_device_info
(
set
,
0
,
&
guid
,
"Root
\\
LEGACY_BOGUS
\\
1001"
);
check_device_info
(
set
,
1
,
NULL
,
NULL
);
/* Open registered device in a new device info set with wrong GUID */
SetupDiDestroyDeviceInfoList
(
set
);
set
=
SetupDiCreateDeviceInfoList
(
&
guid2
,
NULL
);
ok
(
set
!=
INVALID_HANDLE_VALUE
,
"Failed to create device info list, error %#x.
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
ret
=
SetupDiOpenDeviceInfoA
(
set
,
"Root
\\
LEGACY_BOGUS
\\
1001"
,
NULL
,
0
,
&
device
);
ok
(
GetLastError
()
==
ERROR_CLASS_MISMATCH
,
"Got unexpected error %#x.
\n
"
,
GetLastError
());
ok
(
!
ret
,
"Expected failure.
\n
"
);
check_device_info
(
set
,
0
,
NULL
,
NULL
);
/* Open registered device in a new device info set with NULL GUID */
SetupDiDestroyDeviceInfoList
(
set
);
set
=
SetupDiCreateDeviceInfoList
(
NULL
,
NULL
);
ok
(
set
!=
INVALID_HANDLE_VALUE
,
"Failed to create device info list, error %#x.
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
ret
=
SetupDiOpenDeviceInfoA
(
set
,
"Root
\\
LEGACY_BOGUS
\\
1001"
,
NULL
,
0
,
&
device
);
ok
(
GetLastError
()
==
NO_ERROR
,
"Got unexpected error %#x.
\n
"
,
GetLastError
());
ok
(
ret
,
"Failed to open device info
\n
"
);
check_device_info
(
set
,
0
,
&
guid
,
"Root
\\
LEGACY_BOGUS
\\
1001"
);
check_device_info
(
set
,
1
,
NULL
,
NULL
);
SetupDiDestroyDeviceInfoList
(
set
);
set
=
SetupDiCreateDeviceInfoList
(
&
guid
,
NULL
);
ok
(
set
!=
INVALID_HANDLE_VALUE
,
"Failed to create device info list, error %#x.
\n
"
,
GetLastError
());
/* NULL set */
SetLastError
(
0xdeadbeef
);
ret
=
SetupDiOpenDeviceInfoA
(
NULL
,
"Root
\\
LEGACY_BOGUS
\\
1001"
,
NULL
,
0
,
&
device
);
ok
(
GetLastError
()
==
ERROR_INVALID_HANDLE
,
"Got unexpected error %#x.
\n
"
,
GetLastError
());
ok
(
!
ret
,
"Expected failure.
\n
"
);
/* NULL instance id */
SetLastError
(
0xdeadbeef
);
ret
=
SetupDiOpenDeviceInfoA
(
set
,
NULL
,
NULL
,
0
,
&
device
);
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"Got unexpected error %#x.
\n
"
,
GetLastError
());
ok
(
!
ret
,
"Expected failure.
\n
"
);
check_device_info
(
set
,
0
,
NULL
,
NULL
);
/* Invalid SP_DEVINFO_DATA cbSize, device will be added despite failure */
SetLastError
(
0xdeadbeef
);
device
.
cbSize
=
0
;
ret
=
SetupDiOpenDeviceInfoA
(
set
,
"Root
\\
LEGACY_BOGUS
\\
1001"
,
NULL
,
0
,
&
device
);
device
.
cbSize
=
sizeof
(
device
);
ok
(
GetLastError
()
==
ERROR_INVALID_USER_BUFFER
,
"Got unexpected error %#x.
\n
"
,
GetLastError
());
ok
(
!
ret
,
"Expected failure.
\n
"
);
check_device_info
(
set
,
0
,
&
guid
,
"Root
\\
LEGACY_BOGUS
\\
1001"
);
check_device_info
(
set
,
1
,
NULL
,
NULL
);
SetupDiDestroyDeviceInfoList
(
set
);
set
=
SetupDiCreateDeviceInfoList
(
&
guid
,
NULL
);
ok
(
set
!=
INVALID_HANDLE_VALUE
,
"Failed to create device info list, error %#x.
\n
"
,
GetLastError
());
/* NULL device */
SetLastError
(
0xdeadbeef
);
ret
=
SetupDiOpenDeviceInfoA
(
set
,
"Root
\\
LEGACY_BOGUS
\\
1001"
,
NULL
,
0
,
NULL
);
ok
(
GetLastError
()
==
NO_ERROR
,
"Got unexpected error %#x.
\n
"
,
GetLastError
());
ok
(
ret
,
"Failed to open device info
\n
"
);
check_device_info
(
set
,
0
,
&
guid
,
"Root
\\
LEGACY_BOGUS
\\
1001"
);
check_device_info
(
set
,
1
,
NULL
,
NULL
);
/* Clean up */
SetupDiDestroyDeviceInfoList
(
set
);
set
=
SetupDiGetClassDevsA
(
&
guid
,
NULL
,
NULL
,
0
);
while
(
SetupDiEnumDeviceInfo
(
set
,
i
++
,
&
device
))
{
ret
=
SetupDiRemoveDevice
(
set
,
&
device
);
ok
(
ret
,
"Failed to remove device, error %#x.
\n
"
,
GetLastError
());
}
SetupDiDestroyDeviceInfoList
(
set
);
}
static
void
test_register_device_info
(
void
)
{
SP_DEVINFO_DATA
device
=
{
0
};
...
...
@@ -1725,6 +1872,7 @@ START_TEST(devinst)
test_device_info
();
test_device_property
();
test_get_device_instance_id
();
test_open_device_info
();
test_register_device_info
();
test_device_iface
();
test_device_iface_detail
();
...
...
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