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
5d96c5aa
Commit
5d96c5aa
authored
Sep 11, 2020
by
Jacek Caban
Committed by
Alexandre Julliard
Sep 11, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
conhost/tests: Add WriteConsole tests.
Signed-off-by:
Jacek Caban
<
jacek@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
ab6056d6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
241 additions
and
2 deletions
+241
-2
conhost.c
programs/conhost/conhost.c
+2
-2
tty.c
programs/conhost/tests/tty.c
+239
-0
No files found.
programs/conhost/conhost.c
View file @
5d96c5aa
...
...
@@ -159,9 +159,9 @@ static struct screen_buffer *create_screen_buffer( struct console *console, int
screen_buffer
->
max_width
=
80
;
screen_buffer
->
max_height
=
25
;
screen_buffer
->
win
.
left
=
0
;
screen_buffer
->
win
.
right
=
screen_buffer
->
max_width
-
1
;
screen_buffer
->
win
.
right
=
min
(
screen_buffer
->
max_width
-
1
,
width
-
1
)
;
screen_buffer
->
win
.
top
=
0
;
screen_buffer
->
win
.
bottom
=
screen_buffer
->
max_height
-
1
;
screen_buffer
->
win
.
bottom
=
min
(
screen_buffer
->
max_height
-
1
,
height
-
1
)
;
screen_buffer
->
font
.
width
=
0
;
screen_buffer
->
font
.
height
=
0
;
screen_buffer
->
font
.
weight
=
FW_NORMAL
;
...
...
programs/conhost/tests/tty.c
View file @
5d96c5aa
...
...
@@ -151,8 +151,10 @@ enum req_type
REQ_SCROLL
,
REQ_SET_ACTIVE
,
REQ_SET_CURSOR
,
REQ_SET_OUTPUT_MODE
,
REQ_SET_TITLE
,
REQ_WRITE_CHARACTERS
,
REQ_WRITE_CONSOLE
,
REQ_WRITE_OUTPUT
,
};
...
...
@@ -164,6 +166,7 @@ struct pseudoconsole_req
WCHAR
string
[
1
];
COORD
coord
;
HANDLE
handle
;
DWORD
mode
;
struct
{
COORD
coord
;
...
...
@@ -331,6 +334,18 @@ static void child_fill_character(WCHAR ch, DWORD count, int x, int y)
ok
(
ret
,
"WriteFile failed: %u
\n
"
,
GetLastError
());
}
static
void
child_set_output_mode
(
DWORD
mode
)
{
struct
pseudoconsole_req
req
;
DWORD
count
;
BOOL
ret
;
req
.
type
=
REQ_SET_OUTPUT_MODE
;
req
.
u
.
mode
=
mode
;
ret
=
WriteFile
(
child_pipe
,
&
req
,
sizeof
(
req
),
&
count
,
NULL
);
ok
(
ret
,
"WriteFile failed: %u
\n
"
,
GetLastError
());
}
static
void
expect_input
(
unsigned
int
event_type
,
INPUT_RECORD
*
record
)
{
struct
pseudoconsole_req
req
=
{
REQ_GET_INPUT
};
...
...
@@ -436,6 +451,218 @@ static void expect_char_key_(unsigned int line, WCHAR ch)
expect_key_pressed_
(
line
,
ch
,
ch
,
vk
,
ctrl
);
}
static
void
test_write_console
(
void
)
{
child_string_request
(
REQ_WRITE_CONSOLE
,
L"abc"
);
skip_hide_cursor
();
expect_output_sequence
(
"abc"
);
skip_sequence
(
"
\x1b
[?25h"
);
/* show cursor */
child_string_request
(
REQ_WRITE_CONSOLE
,
L"
\t
t"
);
skip_hide_cursor
();
if
(
!
skip_sequence
(
"
\x1b
[3C"
))
expect_output_sequence
(
" "
);
expect_output_sequence
(
"t"
);
skip_sequence
(
"
\x1b
[?25h"
);
/* show cursor */
expect_empty_output
();
child_string_request
(
REQ_WRITE_CONSOLE
,
L"x
\r
r"
);
expect_hide_cursor
();
expect_output_sequence
(
"
\r
r abc tx"
);
if
(
!
skip_sequence
(
"
\x1b
[9D"
))
expect_output_sequence
(
"
\x1b
[4;2H"
);
/* set cursor */
expect_output_sequence
(
"
\x1b
[?25h"
);
/* show cursor */
expect_empty_output
();
child_string_request
(
REQ_WRITE_CONSOLE
,
L"yz
\r\n
"
);
skip_hide_cursor
();
expect_output_sequence
(
"yz
\r\n
"
);
skip_sequence
(
"
\x1b
[?25h"
);
/* show cursor */
expect_empty_output
();
child_string_request
(
REQ_WRITE_CONSOLE
,
L"abc
\r\n
123
\r\n
cde
\r
"
);
skip_hide_cursor
();
expect_output_sequence
(
"abc
\r\n
123
\r\n
cde
\r
"
);
skip_sequence
(
"
\x1b
[?25h"
);
/* show cursor */
expect_empty_output
();
child_set_cursor
(
0
,
39
);
expect_hide_cursor
();
expect_output_sequence
(
"
\x1b
[40;1H"
);
/* set cursor */
expect_output_sequence
(
"
\x1b
[?25h"
);
/* show cursor */
expect_empty_output
();
child_string_request
(
REQ_WRITE_CONSOLE
,
L"yz
\r\n
"
);
skip_hide_cursor
();
expect_output_sequence
(
"yz
\r
"
);
if
(
skip_sequence
(
"
\x1b
[?25h"
))
/* show cursor */
expect_output_sequence
(
"
\x1b
[?25l"
);
/* hide cursor */
expect_output_sequence
(
"
\n
"
);
/* next line */
if
(
skip_sequence
(
"
\x1b
[30X"
))
/* erase the line */
{
expect_output_sequence
(
"
\x1b
[30C"
);
/* move cursor to the end of the line */
expect_output_sequence
(
"
\r
"
);
}
skip_sequence
(
"
\x1b
[?25h"
);
/* show cursor */
expect_empty_output
();
child_string_request
(
REQ_WRITE_CONSOLE
,
L""
);
expect_empty_output
();
child_string_request
(
REQ_WRITE_CONSOLE
,
L"ab
\n
"
);
skip_hide_cursor
();
expect_output_sequence
(
"ab"
);
if
(
skip_sequence
(
"
\x1b
[?25h"
))
/* show cursor */
expect_output_sequence
(
"
\x1b
[?25l"
);
/* hide cursor */
expect_output_sequence
(
"
\r\n
"
);
/* next line */
if
(
skip_sequence
(
"
\x1b
[30X"
))
/* erase the line */
{
expect_output_sequence
(
"
\x1b
[30C"
);
/* move cursor to the end of the line */
expect_output_sequence
(
"
\r
"
);
}
skip_sequence
(
"
\x1b
[?25h"
);
/* show cursor */
expect_empty_output
();
child_set_cursor
(
28
,
10
);
expect_hide_cursor
();
expect_output_sequence
(
"
\x1b
[11;29H"
);
/* set cursor */
expect_output_sequence
(
"
\x1b
[?25h"
);
/* show cursor */
expect_empty_output
();
child_string_request
(
REQ_WRITE_CONSOLE
,
L"xy"
);
skip_hide_cursor
();
expect_output_sequence
(
"xy"
);
if
(
!
skip_sequence
(
"
\b
"
))
expect_output_sequence
(
"
\r\n
"
);
skip_sequence
(
"
\x1b
[?25h"
);
/* show cursor */
expect_empty_output
();
child_set_cursor
(
28
,
10
);
fetch_console_output
();
if
(
!
skip_sequence
(
"
\b
"
))
{
expect_hide_cursor
();
expect_output_sequence
(
"
\x1b
[11;29H"
);
/* set cursor */
expect_output_sequence
(
"
\x1b
[?25h"
);
/* show cursor */
}
expect_empty_output
();
child_string_request
(
REQ_WRITE_CONSOLE
,
L"abc"
);
skip_hide_cursor
();
expect_output_sequence
(
"
\r
ab"
);
expect_output_sequence
(
"
\r\n
c"
);
if
(
expect_erase_line
(
29
))
expect_output_sequence
(
"
\x1b
[12;2H"
);
/* set cursor */
skip_sequence
(
"
\x1b
[?25h"
);
/* show cursor */
expect_empty_output
();
child_set_cursor
(
28
,
39
);
expect_hide_cursor
();
expect_output_sequence
(
"
\x1b
[40;29H"
);
/* set cursor */
expect_output_sequence
(
"
\x1b
[?25h"
);
/* show cursor */
expect_empty_output
();
child_string_request
(
REQ_WRITE_CONSOLE
,
L"abc"
);
skip_hide_cursor
();
expect_output_sequence
(
"ab"
);
skip_sequence
(
"
\x1b
[40;29H"
);
/* set cursor */
if
(
skip_sequence
(
"
\x1b
[?25h"
))
/* show cursor */
expect_output_sequence
(
"
\x1b
[?25l"
);
/* hide cursor */
else
skip_sequence
(
"
\b
"
);
expect_output_sequence
(
"
\r\n
c"
);
if
(
skip_sequence
(
"
\x1b
[29X"
))
/* erase the line */
{
expect_output_sequence
(
"
\x1b
[29C"
);
/* move cursor to the end of the line */
expect_output_sequence
(
"
\x1b
[40;2H"
);
/* set cursor */
}
skip_sequence
(
"
\x1b
[?25h"
);
/* show cursor */
expect_empty_output
();
child_set_cursor
(
28
,
39
);
skip_hide_cursor
();
if
(
!
skip_sequence
(
"
\x1b
[27C"
))
expect_output_sequence
(
"
\x1b
[40;29H"
);
/* set cursor */
skip_sequence
(
"
\x1b
[?25h"
);
/* show cursor */
expect_empty_output
();
child_string_request
(
REQ_WRITE_CONSOLE
,
L"XY"
);
skip_hide_cursor
();
expect_output_sequence
(
"XY"
);
skip_sequence
(
"
\x1b
[40;29H"
);
/* set cursor */
if
(
skip_sequence
(
"
\x1b
[?25h"
))
/* show cursor */
expect_output_sequence
(
"
\x1b
[?25l"
);
/* hide cursor */
if
(
!
skip_sequence
(
"
\b
"
))
{
expect_output_sequence
(
"
\r\n
"
);
expect_output_sequence
(
"
\x1b
[30X"
);
/* erase the line */
expect_output_sequence
(
"
\x1b
[30C"
);
/* move cursor to the end of the line */
expect_output_sequence
(
"
\r
"
);
/* set cursor */
}
skip_sequence
(
"
\x1b
[?25h"
);
/* show cursor */
expect_empty_output
();
child_string_request
(
REQ_WRITE_CONSOLE
,
L"
\n
"
);
skip_hide_cursor
();
if
(
!
skip_sequence
(
"
\r\n
"
))
{
expect_output_sequence
(
"
\n
"
);
expect_output_sequence
(
"
\x1b
[30X"
);
/* erase the line */
expect_output_sequence
(
"
\x1b
[30C"
);
/* move cursor to the end of the line */
expect_output_sequence
(
"
\r
"
);
/* set cursor */
}
skip_sequence
(
"
\x1b
[?25h"
);
/* show cursor */
expect_empty_output
();
child_set_output_mode
(
ENABLE_PROCESSED_OUTPUT
);
child_set_cursor
(
28
,
11
);
expect_hide_cursor
();
expect_output_sequence
(
"
\x1b
[12;29H"
);
/* set cursor */
skip_sequence
(
"
\x1b
[?25h"
);
/* show cursor */
child_string_request
(
REQ_WRITE_CONSOLE
,
L"xyz1234"
);
skip_hide_cursor
();
expect_output_sequence
(
"43
\b
"
);
skip_sequence
(
"
\x1b
[?25h"
);
/* show cursor */
expect_empty_output
();
child_set_cursor
(
28
,
11
);
skip_hide_cursor
();
expect_output_sequence
(
"
\b
"
);
/* backspace */
skip_sequence
(
"
\x1b
[?25h"
);
/* show cursor */
child_string_request
(
REQ_WRITE_CONSOLE
,
L"xyz123"
);
expect_hide_cursor
();
expect_output_sequence
(
"23"
);
if
(
!
skip_sequence
(
"
\x1b
[2D"
))
expect_output_sequence
(
"
\x1b
[12;29H"
);
/* set cursor */
expect_output_sequence
(
"
\x1b
[?25h"
);
/* show cursor */
expect_empty_output
();
child_set_cursor
(
28
,
11
);
child_string_request
(
REQ_WRITE_CONSOLE
,
L"abcdef
\n\r
123456789012345678901234567890xyz"
);
expect_hide_cursor
();
if
(
skip_sequence
(
"
\x1b
[?25h"
))
expect_hide_cursor
();
expect_output_sequence
(
"
\r
ef
\r\n
"
);
expect_output_sequence
(
"xyz456789012345678901234567890"
);
if
(
!
skip_sequence
(
"
\x1b
[27D"
))
expect_output_sequence
(
"
\x1b
[13;4H"
);
/* set cursor */
expect_output_sequence
(
"
\x1b
[?25h"
);
/* show cursor */
expect_empty_output
();
child_set_cursor
(
28
,
11
);
expect_hide_cursor
();
expect_output_sequence
(
"
\x1b
[12;29H"
);
/* set cursor */
expect_output_sequence
(
"
\x1b
[?25h"
);
/* show cursor */
child_string_request
(
REQ_WRITE_CONSOLE
,
L"AB
\r\n
"
);
skip_hide_cursor
();
expect_output_sequence
(
"AB
\r\n
"
);
skip_sequence
(
"
\x1b
[?25h"
);
/* show cursor */
expect_empty_output
();
child_set_output_mode
(
ENABLE_PROCESSED_OUTPUT
|
ENABLE_WRAP_AT_EOL_OUTPUT
);
}
static
void
test_tty_output
(
void
)
{
CHAR_INFO
char_info_buf
[
2048
],
char_info
;
...
...
@@ -670,6 +897,8 @@ static void test_tty_output(void)
expect_output_sequence
(
"
\x1b
[?25h"
);
/* show cursor */
expect_empty_output
();
test_write_console
();
sb
=
child_create_screen_buffer
();
child_set_active
(
sb
);
expect_hide_cursor
();
...
...
@@ -916,6 +1145,11 @@ static void child_process(HANDLE pipe)
ok
(
ret
,
"SetConsoleCursorPosition failed: %u
\n
"
,
GetLastError
());
break
;
case
REQ_SET_OUTPUT_MODE
:
ret
=
SetConsoleMode
(
output
,
req
->
u
.
mode
);
ok
(
ret
,
"SetConsoleMode failed: %u
\n
"
,
GetLastError
());
break
;
case
REQ_SET_TITLE
:
ret
=
SetConsoleTitleW
(
req
->
u
.
string
);
ok
(
ret
,
"SetConsoleTitleW failed: %u
\n
"
,
GetLastError
());
...
...
@@ -928,6 +1162,11 @@ static void child_process(HANDLE pipe)
ok
(
ret
,
"WriteConsoleOutputCharacterW failed: %u
\n
"
,
GetLastError
());
break
;
case
REQ_WRITE_CONSOLE
:
ret
=
WriteConsoleW
(
output
,
req
->
u
.
string
,
lstrlenW
(
req
->
u
.
string
),
NULL
,
NULL
);
ok
(
ret
,
"SetConsoleTitleW failed: %u
\n
"
,
GetLastError
());
break
;
case
REQ_WRITE_OUTPUT
:
{
SMALL_RECT
region
=
req
->
u
.
write_output
.
region
;
...
...
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