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
4be3d64d
Commit
4be3d64d
authored
Feb 20, 2006
by
Detlef Riekenberg
Committed by
Alexandre Julliard
Feb 20, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winspool/tests: Add some tests for SetDefaultPrinterA/W.
parent
e267ccfe
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
106 additions
and
0 deletions
+106
-0
info.c
dlls/winspool/tests/info.c
+106
-0
No files found.
dlls/winspool/tests/info.c
View file @
4be3d64d
...
...
@@ -35,6 +35,7 @@ static char env_win9x_case[] = "windowS 4.0";
static
HANDLE
hwinspool
;
static
FARPROC
pGetDefaultPrinterA
;
static
FARPROC
pSetDefaultPrinterA
;
/* report common behavior only once */
static
DWORD
report_deactivated_spooler
=
1
;
...
...
@@ -584,10 +585,114 @@ static void test_OpenPrinter(void)
}
static
void
test_SetDefaultPrinter
(
void
)
{
DWORD
res
;
LPSTR
default_printer
;
DWORD
size
=
DEFAULT_PRINTER_SIZE
;
CHAR
buffer
[
DEFAULT_PRINTER_SIZE
];
CHAR
org_value
[
DEFAULT_PRINTER_SIZE
];
if
(
!
pSetDefaultPrinterA
)
return
;
/* only supported on win2k and above */
default_printer
=
find_default_printer
();
/* backup the original value */
org_value
[
0
]
=
'\0'
;
SetLastError
(
MAGIC_DEAD
);
res
=
GetProfileStringA
(
"windows"
,
"device"
,
NULL
,
org_value
,
size
);
/* first part: with the default Printer */
SetLastError
(
MAGIC_DEAD
);
res
=
pSetDefaultPrinterA
(
"no_printer_with_this_name"
);
RETURN_ON_DEACTIVATED_SPOOLER
(
res
)
/* spooler is running or we have no spooler here*/
/* Not implemented in wine */
if
(
!
res
&&
(
GetLastError
()
==
ERROR_CALL_NOT_IMPLEMENTED
))
{
trace
(
"SetDefaultPrinterA() not implemented yet.
\n
"
);
return
;
}
ok
(
!
res
&&
(
GetLastError
()
==
ERROR_INVALID_PRINTER_NAME
),
"returned %ld with %ld (expected '0' with "
\
"ERROR_INVALID_PRINTER_NAME)
\n
"
,
res
,
GetLastError
());
WriteProfileStringA
(
"windows"
,
"device"
,
org_value
);
SetLastError
(
MAGIC_DEAD
);
res
=
pSetDefaultPrinterA
(
""
);
ok
(
res
||
(
!
res
&&
(
GetLastError
()
==
ERROR_INVALID_PRINTER_NAME
)),
"returned %ld with %ld (expected '!=0' or '0' with "
\
"ERROR_INVALID_PRINTER_NAME)
\n
"
,
res
,
GetLastError
());
WriteProfileStringA
(
"windows"
,
"device"
,
org_value
);
SetLastError
(
MAGIC_DEAD
);
res
=
pSetDefaultPrinterA
(
NULL
);
ok
(
res
||
(
!
res
&&
(
GetLastError
()
==
ERROR_INVALID_PRINTER_NAME
)),
"returned %ld with %ld (expected '!=0' or '0' with "
\
"ERROR_INVALID_PRINTER_NAME)
\n
"
,
res
,
GetLastError
());
WriteProfileStringA
(
"windows"
,
"device"
,
org_value
);
SetLastError
(
MAGIC_DEAD
);
res
=
pSetDefaultPrinterA
(
default_printer
);
ok
(
res
||
(
!
res
&&
(
GetLastError
()
==
ERROR_INVALID_PRINTER_NAME
)),
"returned %ld with %ld (expected '!=0' or '0' with "
\
"ERROR_INVALID_PRINTER_NAME)
\n
"
,
res
,
GetLastError
());
/* second part: always without a default Printer */
WriteProfileStringA
(
"windows"
,
"device"
,
NULL
);
SetLastError
(
MAGIC_DEAD
);
res
=
pSetDefaultPrinterA
(
"no_printer_with_this_name"
);
ok
(
!
res
&&
(
GetLastError
()
==
ERROR_INVALID_PRINTER_NAME
),
"returned %ld with %ld (expected '0' with "
\
"ERROR_INVALID_PRINTER_NAME)
\n
"
,
res
,
GetLastError
());
WriteProfileStringA
(
"windows"
,
"device"
,
NULL
);
SetLastError
(
MAGIC_DEAD
);
res
=
pSetDefaultPrinterA
(
""
);
/* we get ERROR_INVALID_PRINTER_NAME when no printer is installed */
ok
(
res
||
(
!
res
&&
(
GetLastError
()
==
ERROR_INVALID_PRINTER_NAME
)),
"returned %ld with %ld (expected '!=0' or '0' with "
\
"ERROR_INVALID_PRINTER_NAME)
\n
"
,
res
,
GetLastError
());
WriteProfileStringA
(
"windows"
,
"device"
,
NULL
);
SetLastError
(
MAGIC_DEAD
);
res
=
pSetDefaultPrinterA
(
NULL
);
/* we get ERROR_INVALID_PRINTER_NAME when no printer is installed */
ok
(
res
||
(
!
res
&&
(
GetLastError
()
==
ERROR_INVALID_PRINTER_NAME
)),
"returned %ld with %ld (expected '!=0' or '0' with "
\
"ERROR_INVALID_PRINTER_NAME)
\n
"
,
res
,
GetLastError
());
WriteProfileStringA
(
"windows"
,
"device"
,
NULL
);
SetLastError
(
MAGIC_DEAD
);
res
=
pSetDefaultPrinterA
(
default_printer
);
ok
(
res
||
(
!
res
&&
(
GetLastError
()
==
ERROR_INVALID_PRINTER_NAME
)),
"returned %ld with %ld (expected '!=0' or '0' with "
\
"ERROR_INVALID_PRINTER_NAME)
\n
"
,
res
,
GetLastError
());
/* restore the original value */
res
=
pSetDefaultPrinterA
(
default_printer
);
/* the nice way */
WriteProfileStringA
(
"windows"
,
"device"
,
org_value
);
/* the old way */
buffer
[
0
]
=
'\0'
;
SetLastError
(
MAGIC_DEAD
);
res
=
GetProfileStringA
(
"windows"
,
"device"
,
NULL
,
buffer
,
size
);
ok
(
!
lstrcmpA
(
org_value
,
buffer
),
"'%s' (expected '%s')
\n
"
,
buffer
,
org_value
);
}
START_TEST
(
info
)
{
hwinspool
=
GetModuleHandleA
(
"winspool.drv"
);
pGetDefaultPrinterA
=
(
void
*
)
GetProcAddress
(
hwinspool
,
"GetDefaultPrinterA"
);
pSetDefaultPrinterA
=
(
void
*
)
GetProcAddress
(
hwinspool
,
"SetDefaultPrinterA"
);
find_default_printer
();
...
...
@@ -595,4 +700,5 @@ START_TEST(info)
test_GetDefaultPrinter
();
test_GetPrinterDriverDirectory
();
test_OpenPrinter
();
test_SetDefaultPrinter
();
}
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