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
d3a1737d
Commit
d3a1737d
authored
Nov 04, 2006
by
Detlef Riekenberg
Committed by
Alexandre Julliard
Nov 06, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winspool/tests: Add tests for EnumPorts.
parent
ecce2d89
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
100 additions
and
0 deletions
+100
-0
info.c
dlls/winspool.drv/tests/info.c
+100
-0
No files found.
dlls/winspool.drv/tests/info.c
View file @
d3a1737d
...
...
@@ -619,6 +619,105 @@ static void test_EnumMonitors(void)
}
/* for(level ... */
}
/* ########################### */
static
void
test_EnumPorts
(
void
)
{
DWORD
res
;
DWORD
level
;
LPBYTE
buffer
;
DWORD
cbBuf
;
DWORD
pcbNeeded
;
DWORD
pcReturned
;
/* valid levels are 1 and 2 */
for
(
level
=
0
;
level
<
4
;
level
++
)
{
cbBuf
=
0xdeadbeef
;
pcReturned
=
0xdeadbeef
;
SetLastError
(
0xdeadbeef
);
res
=
EnumPortsA
(
NULL
,
level
,
NULL
,
0
,
&
cbBuf
,
&
pcReturned
);
RETURN_ON_DEACTIVATED_SPOOLER
(
res
)
/* use only a short test, when we test with an invalid level */
if
(
!
level
||
(
level
>
2
))
{
/* NT: ERROR_INVALID_LEVEL, 9x: success */
ok
(
(
!
res
&&
(
GetLastError
()
==
ERROR_INVALID_LEVEL
))
||
(
res
&&
(
pcReturned
==
0
)),
"(%d) returned %d with %d and 0x%08x (expected '0' with "
\
"ERROR_INVALID_LEVEL or '!=0' and 0x0)
\n
"
,
level
,
res
,
GetLastError
(),
pcReturned
);
continue
;
}
/* Level 2 is not supported on NT 3.x */
if
(
!
res
&&
(
GetLastError
()
==
ERROR_INVALID_LEVEL
))
{
trace
(
"Level %d not supported, skipping tests
\n
"
,
level
);
continue
;
}
ok
((
!
res
)
&&
(
GetLastError
()
==
ERROR_INSUFFICIENT_BUFFER
),
"(%d) returned %d with %d (expected '0' with "
\
"ERROR_INSUFFICIENT_BUFFER)
\n
"
,
level
,
res
,
GetLastError
());
buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
cbBuf
*
2
);
if
(
buffer
==
NULL
)
continue
;
pcbNeeded
=
0xdeadbeef
;
SetLastError
(
0xdeadbeef
);
res
=
EnumPortsA
(
NULL
,
level
,
buffer
,
cbBuf
,
&
pcbNeeded
,
&
pcReturned
);
ok
(
res
,
"(%d) returned %d with %d (expected '!=0')
\n
"
,
level
,
res
,
GetLastError
());
ok
(
pcbNeeded
==
cbBuf
,
"(%d) returned %d (expected %d)
\n
"
,
level
,
pcbNeeded
,
cbBuf
);
/* ToDo: Compare the returned Data with the Registry / "win.ini",[Ports] here */
pcbNeeded
=
0xdeadbeef
;
pcReturned
=
0xdeadbeef
;
SetLastError
(
0xdeadbeef
);
res
=
EnumPortsA
(
NULL
,
level
,
buffer
,
cbBuf
+
1
,
&
pcbNeeded
,
&
pcReturned
);
ok
(
res
,
"(%d) returned %d with %d (expected '!=0')
\n
"
,
level
,
res
,
GetLastError
());
ok
(
pcbNeeded
==
cbBuf
,
"(%d) returned %d (expected %d)
\n
"
,
level
,
pcbNeeded
,
cbBuf
);
pcbNeeded
=
0xdeadbeef
;
SetLastError
(
0xdeadbeef
);
res
=
EnumPortsA
(
NULL
,
level
,
buffer
,
cbBuf
-
1
,
&
pcbNeeded
,
&
pcReturned
);
ok
(
!
res
&&
(
GetLastError
()
==
ERROR_INSUFFICIENT_BUFFER
),
"(%d) returned %d with %d (expected '0' with "
\
"ERROR_INSUFFICIENT_BUFFER)
\n
"
,
level
,
res
,
GetLastError
());
ok
(
pcbNeeded
==
cbBuf
,
"(%d) returned %d (expected %d)
\n
"
,
level
,
pcbNeeded
,
cbBuf
);
/*
Do not add this test:
res = EnumPortsA(NULL, level, NULL, cbBuf, &pcbNeeded, &pcReturned);
w2k+: RPC_X_NULL_REF_POINTER
NT3.5: ERROR_INVALID_USER_BUFFER
win9x: crash in winspool.drv
*/
SetLastError
(
0xdeadbeef
);
res
=
EnumPorts
(
NULL
,
level
,
buffer
,
cbBuf
,
NULL
,
&
pcReturned
);
/* NT: RPC_X_NULL_REF_POINTER (1780), 9x: success */
ok
(
(
!
res
&&
(
GetLastError
()
==
RPC_X_NULL_REF_POINTER
)
)
||
(
res
&&
(
GetLastError
()
==
ERROR_SUCCESS
)
),
"(%d) returned %d with %d (expected '0' with "
\
"RPC_X_NULL_REF_POINTER or '!=0' with NO_ERROR)
\n
"
,
level
,
res
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
res
=
EnumPorts
(
NULL
,
level
,
buffer
,
cbBuf
,
&
pcbNeeded
,
NULL
);
/* NT: RPC_X_NULL_REF_POINTER (1780), 9x: success */
ok
(
(
!
res
&&
(
GetLastError
()
==
RPC_X_NULL_REF_POINTER
)
)
||
(
res
&&
(
GetLastError
()
==
ERROR_SUCCESS
)
),
"(%d) returned %d with %d (expected '0' with "
\
"RPC_X_NULL_REF_POINTER or '!=0' with NO_ERROR)
\n
"
,
level
,
res
,
GetLastError
());
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
}
}
/* ########################### */
static
void
test_GetDefaultPrinter
(
void
)
{
...
...
@@ -1413,6 +1512,7 @@ START_TEST(info)
test_EnumForms
(
NULL
);
if
(
default_printer
)
test_EnumForms
(
default_printer
);
test_EnumMonitors
();
test_EnumPorts
();
test_GetDefaultPrinter
();
test_GetPrinterDriverDirectory
();
test_GetPrintProcessorDirectory
();
...
...
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