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
5a6341d8
Commit
5a6341d8
authored
Aug 12, 2020
by
Jacek Caban
Committed by
Alexandre Julliard
Aug 12, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32/tests: Add an option to test current console.
Signed-off-by:
Jacek Caban
<
jacek@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
3d4be8e1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
71 additions
and
65 deletions
+71
-65
console.c
dlls/kernel32/tests/console.c
+71
-65
No files found.
dlls/kernel32/tests/console.c
View file @
5a6341d8
...
...
@@ -3872,14 +3872,9 @@ static void test_AllocConsole(void)
START_TEST
(
console
)
{
static
const
char
font_name
[]
=
"Lucida Console"
;
HANDLE
hConIn
,
hConOut
;
BOOL
ret
;
BOOL
ret
,
test_current
;
CONSOLE_SCREEN_BUFFER_INFO
sbi
;
LONG
err
;
HKEY
console_key
;
char
old_font
[
LF_FACESIZE
];
BOOL
delete
=
FALSE
;
DWORD
size
;
char
**
argv
;
int
argc
;
...
...
@@ -3902,62 +3897,67 @@ START_TEST(console)
return
;
}
/* be sure we have a clean console (and that's our own)
* FIXME: this will make the test fail (currently) if we don't run
* under X11
* Another solution would be to rerun the test under wineconsole with
* the curses backend
*/
test_current
=
argc
>=
3
&&
!
strcmp
(
argv
[
2
],
"--current"
);
/* ReadConsoleOutputW doesn't retrieve characters from the output buffer
* correctly for characters that don't have a glyph in the console font. So,
* we first set the console font to Lucida Console (which has a wider
* selection of glyphs available than the default raster fonts). We want
* to be able to restore the original font afterwards, so don't change
* if we can't read the original font.
*/
err
=
RegOpenKeyExA
(
HKEY_CURRENT_USER
,
"Console"
,
0
,
KEY_QUERY_VALUE
|
KEY_SET_VALUE
,
&
console_key
);
if
(
err
==
ERROR_SUCCESS
)
{
size
=
sizeof
(
old_font
);
err
=
RegQueryValueExA
(
console_key
,
"FaceName"
,
NULL
,
NULL
,
(
LPBYTE
)
old_font
,
&
size
);
if
(
err
==
ERROR_SUCCESS
||
err
==
ERROR_FILE_NOT_FOUND
)
if
(
!
test_current
)
{
static
const
char
font_name
[]
=
"Lucida Console"
;
HKEY
console_key
;
char
old_font
[
LF_FACESIZE
];
BOOL
delete
=
FALSE
;
LONG
err
;
/* ReadConsoleOutputW doesn't retrieve characters from the output buffer
* correctly for characters that don't have a glyph in the console font. So,
* we first set the console font to Lucida Console (which has a wider
* selection of glyphs available than the default raster fonts). We want
* to be able to restore the original font afterwards, so don't change
* if we can't read the original font.
*/
err
=
RegOpenKeyExA
(
HKEY_CURRENT_USER
,
"Console"
,
0
,
KEY_QUERY_VALUE
|
KEY_SET_VALUE
,
&
console_key
);
if
(
err
==
ERROR_SUCCESS
)
{
delete
=
(
err
==
ERROR_FILE_NOT_FOUND
);
err
=
RegSetValueExA
(
console_key
,
"FaceName"
,
0
,
REG_SZ
,
(
const
BYTE
*
)
font_name
,
sizeof
(
font_name
));
if
(
err
!=
ERROR_SUCCESS
)
trace
(
"Unable to change default console font, error %d
\n
"
,
err
);
size
=
sizeof
(
old_font
);
err
=
RegQueryValueExA
(
console_key
,
"FaceName"
,
NULL
,
NULL
,
(
LPBYTE
)
old_font
,
&
size
);
if
(
err
==
ERROR_SUCCESS
||
err
==
ERROR_FILE_NOT_FOUND
)
{
delete
=
(
err
==
ERROR_FILE_NOT_FOUND
);
err
=
RegSetValueExA
(
console_key
,
"FaceName"
,
0
,
REG_SZ
,
(
const
BYTE
*
)
font_name
,
sizeof
(
font_name
));
if
(
err
!=
ERROR_SUCCESS
)
trace
(
"Unable to change default console font, error %d
\n
"
,
err
);
}
else
{
trace
(
"Unable to query default console font, error %d
\n
"
,
err
);
RegCloseKey
(
console_key
);
console_key
=
NULL
;
}
}
else
{
trace
(
"Unable to query default console font, error %d
\n
"
,
err
);
RegCloseKey
(
console_key
);
trace
(
"Unable to open HKCU
\\
Console, error %d
\n
"
,
err
);
console_key
=
NULL
;
}
}
else
{
trace
(
"Unable to open HKCU
\\
Console, error %d
\n
"
,
err
);
console_key
=
NULL
;
}
/* Now detach and open a fresh console to play with */
FreeConsole
();
ok
(
AllocConsole
(),
"Couldn't alloc console
\n
"
);
/* Now detach and open a fresh console to play with */
FreeConsole
();
ok
(
AllocConsole
(),
"Couldn't alloc console
\n
"
);
/* Restore default console font if needed */
if
(
console_key
!=
NULL
)
{
if
(
delete
)
err
=
RegDeleteValueA
(
console_key
,
"FaceName"
);
else
err
=
RegSetValueExA
(
console_key
,
"FaceName"
,
0
,
REG_SZ
,
(
const
BYTE
*
)
old_font
,
strlen
(
old_font
)
+
1
);
ok
(
err
==
ERROR_SUCCESS
,
"Unable to restore default console font, error %d
\n
"
,
err
);
/* Restore default console font if needed */
if
(
console_key
!=
NULL
)
{
if
(
delete
)
err
=
RegDeleteValueA
(
console_key
,
"FaceName"
);
else
err
=
RegSetValueExA
(
console_key
,
"FaceName"
,
0
,
REG_SZ
,
(
const
BYTE
*
)
old_font
,
strlen
(
old_font
)
+
1
);
ok
(
err
==
ERROR_SUCCESS
,
"Unable to restore default console font, error %d
\n
"
,
err
);
}
}
hConIn
=
CreateFileA
(
"CONIN$"
,
GENERIC_READ
|
GENERIC_WRITE
,
0
,
NULL
,
OPEN_EXISTING
,
0
,
0
);
hConOut
=
CreateFileA
(
"CONOUT$"
,
GENERIC_READ
|
GENERIC_WRITE
,
0
,
NULL
,
OPEN_EXISTING
,
0
,
0
);
...
...
@@ -3993,19 +3993,22 @@ START_TEST(console)
/* will test all the scrolling operations */
testScroll
(
hConOut
,
sbi
.
dwSize
);
/* will test sb creation / modification / codepage handling */
testScreenBuffer
(
hConOut
);
if
(
!
test_current
)
testScreenBuffer
(
hConOut
);
/* Test waiting for a console handle */
testWaitForConsoleInput
(
hConIn
);
/* clear duplicated console font table */
CloseHandle
(
hConIn
);
CloseHandle
(
hConOut
);
FreeConsole
();
ok
(
AllocConsole
(),
"Couldn't alloc console
\n
"
);
hConIn
=
CreateFileA
(
"CONIN$"
,
GENERIC_READ
|
GENERIC_WRITE
,
0
,
NULL
,
OPEN_EXISTING
,
0
,
0
);
hConOut
=
CreateFileA
(
"CONOUT$"
,
GENERIC_READ
|
GENERIC_WRITE
,
0
,
NULL
,
OPEN_EXISTING
,
0
,
0
);
ok
(
hConIn
!=
INVALID_HANDLE_VALUE
,
"Opening ConIn
\n
"
);
ok
(
hConOut
!=
INVALID_HANDLE_VALUE
,
"Opening ConOut
\n
"
);
if
(
!
test_current
)
{
/* clear duplicated console font table */
CloseHandle
(
hConIn
);
CloseHandle
(
hConOut
);
FreeConsole
();
ok
(
AllocConsole
(),
"Couldn't alloc console
\n
"
);
hConIn
=
CreateFileA
(
"CONIN$"
,
GENERIC_READ
|
GENERIC_WRITE
,
0
,
NULL
,
OPEN_EXISTING
,
0
,
0
);
hConOut
=
CreateFileA
(
"CONOUT$"
,
GENERIC_READ
|
GENERIC_WRITE
,
0
,
NULL
,
OPEN_EXISTING
,
0
,
0
);
ok
(
hConIn
!=
INVALID_HANDLE_VALUE
,
"Opening ConIn
\n
"
);
ok
(
hConOut
!=
INVALID_HANDLE_VALUE
,
"Opening ConOut
\n
"
);
}
testCtrlHandler
();
/* still to be done: access rights & access on objects */
...
...
@@ -4043,7 +4046,10 @@ START_TEST(console)
test_SetConsoleFont
(
hConOut
);
test_GetConsoleScreenBufferInfoEx
(
hConOut
);
test_SetConsoleScreenBufferInfoEx
(
hConOut
);
test_AttachConsole
(
hConOut
);
test_AllocConsole
();
test_FreeConsole
();
if
(
!
test_current
)
{
test_AttachConsole
(
hConOut
);
test_AllocConsole
();
test_FreeConsole
();
}
}
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