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
1e5cd8fa
Commit
1e5cd8fa
authored
Jul 28, 2020
by
Jacek Caban
Committed by
Alexandre Julliard
Jul 28, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32/tests: Add more console output reading tests.
Signed-off-by:
Jacek Caban
<
jacek@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
f6fb372a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
175 additions
and
3 deletions
+175
-3
console.c
dlls/kernel32/tests/console.c
+173
-3
console.c
dlls/kernelbase/console.c
+2
-0
No files found.
dlls/kernel32/tests/console.c
View file @
1e5cd8fa
...
...
@@ -2244,12 +2244,21 @@ static void set_region(SMALL_RECT *region, unsigned int left, unsigned int top,
}
#define check_region(a,b,c,d,e) check_region_(__LINE__,a,b,c,d,e)
static
void
check_region_
(
unsigned
int
line
,
const
SMALL_RECT
*
region
,
unsigned
int
left
,
unsigned
int
top
,
unsigned
int
right
,
unsigned
int
bottom
)
static
void
check_region_
(
unsigned
int
line
,
const
SMALL_RECT
*
region
,
unsigned
int
left
,
unsigned
int
top
,
int
right
,
int
bottom
)
{
ok_
(
__FILE__
,
line
)(
region
->
Left
==
left
,
"Left = %u, expected %u
\n
"
,
region
->
Left
,
left
);
ok_
(
__FILE__
,
line
)(
region
->
Top
==
top
,
"Top = %u, expected %u
\n
"
,
region
->
Top
,
top
);
ok_
(
__FILE__
,
line
)(
region
->
Right
==
right
,
"Right = %u, expected %u
\n
"
,
region
->
Right
,
right
);
ok_
(
__FILE__
,
line
)(
region
->
Bottom
==
bottom
,
"Bottom = %u, expected %u
\n
"
,
region
->
Bottom
,
bottom
);
/* In multiple places returned region depends on Windows versions: some return right < left, others leave it untouched */
if
(
right
>=
0
)
ok_
(
__FILE__
,
line
)(
region
->
Right
==
right
,
"Right = %u, expected %u
\n
"
,
region
->
Right
,
right
);
else
ok_
(
__FILE__
,
line
)(
region
->
Right
==
-
right
||
region
->
Right
==
region
->
Left
-
1
,
"Right = %u, expected %d
\n
"
,
region
->
Right
,
right
);
if
(
bottom
>=
0
)
ok_
(
__FILE__
,
line
)(
region
->
Bottom
==
bottom
,
"Bottom = %u, expected %u
\n
"
,
region
->
Bottom
,
bottom
);
else
ok_
(
__FILE__
,
line
)(
region
->
Bottom
==
-
bottom
||
region
->
Bottom
==
region
->
Top
-
1
,
"Bottom = %u, expected %d
\n
"
,
region
->
Bottom
,
bottom
);
}
static
void
test_WriteConsoleOutput
(
HANDLE
console
)
...
...
@@ -2634,6 +2643,12 @@ static void test_ReadConsoleOutputCharacterA(HANDLE output_handle)
ret
=
ReadConsoleOutputCharacterA
(
output_handle
,
&
read
,
1
,
origin
,
&
count
);
ok
(
ret
==
TRUE
,
"Expected ReadConsoleOutputCharacterA to return TRUE, got %d
\n
"
,
ret
);
ok
(
count
==
1
,
"Expected count to be 1, got %u
\n
"
,
count
);
count
=
0xdeadbeef
;
origin
.
X
=
200
;
ret
=
ReadConsoleOutputCharacterA
(
output_handle
,
&
read
,
1
,
origin
,
&
count
);
ok
(
ret
==
TRUE
,
"Expected ReadConsoleOutputCharacterA to return TRUE, got %d
\n
"
,
ret
);
ok
(
count
==
0
,
"Expected count to be 0, got %u
\n
"
,
count
);
}
static
void
test_ReadConsoleOutputCharacterW
(
HANDLE
output_handle
)
...
...
@@ -2718,6 +2733,12 @@ static void test_ReadConsoleOutputCharacterW(HANDLE output_handle)
ret
=
ReadConsoleOutputCharacterW
(
output_handle
,
&
read
,
1
,
origin
,
&
count
);
ok
(
ret
==
TRUE
,
"Expected ReadConsoleOutputCharacterW to return TRUE, got %d
\n
"
,
ret
);
ok
(
count
==
1
,
"Expected count to be 1, got %u
\n
"
,
count
);
count
=
0xdeadbeef
;
origin
.
X
=
200
;
ret
=
ReadConsoleOutputCharacterW
(
output_handle
,
&
read
,
1
,
origin
,
&
count
);
ok
(
ret
==
TRUE
,
"Expected ReadConsoleOutputCharacterW to return TRUE, got %d
\n
"
,
ret
);
ok
(
count
==
0
,
"Expected count to be 0, got %u
\n
"
,
count
);
}
static
void
test_ReadConsoleOutputAttribute
(
HANDLE
output_handle
)
...
...
@@ -2801,6 +2822,154 @@ static void test_ReadConsoleOutputAttribute(HANDLE output_handle)
ret
=
ReadConsoleOutputAttribute
(
output_handle
,
&
attr
,
1
,
origin
,
&
count
);
ok
(
ret
==
TRUE
,
"Expected ReadConsoleOutputAttribute to return TRUE, got %d
\n
"
,
ret
);
ok
(
count
==
1
,
"Expected count to be 1, got %u
\n
"
,
count
);
count
=
0xdeadbeef
;
origin
.
X
=
200
;
ret
=
ReadConsoleOutputAttribute
(
output_handle
,
&
attr
,
1
,
origin
,
&
count
);
ok
(
ret
==
TRUE
,
"Expected ReadConsoleOutputAttribute to return TRUE, got %d
\n
"
,
ret
);
ok
(
count
==
0
,
"Expected count to be 1, got %u
\n
"
,
count
);
}
static
void
test_ReadConsoleOutput
(
HANDLE
console
)
{
CONSOLE_SCREEN_BUFFER_INFO
info
;
CHAR_INFO
char_info_buf
[
2048
];
SMALL_RECT
region
;
COORD
size
,
coord
;
DWORD
count
;
WCHAR
ch
;
BOOL
ret
;
if
(
skip_nt
)
return
;
ret
=
GetConsoleScreenBufferInfo
(
console
,
&
info
);
ok
(
ret
,
"GetConsoleScreenBufferInfo failed: %u
\n
"
,
GetLastError
());
size
.
X
=
23
;
size
.
Y
=
17
;
coord
.
X
=
2
;
coord
.
Y
=
3
;
set_region
(
&
region
,
10
,
7
,
15
,
11
);
ret
=
ReadConsoleOutputW
(
console
,
char_info_buf
,
size
,
coord
,
&
region
);
ok
(
ret
,
"ReadConsoleOutputW failed: %u
\n
"
,
GetLastError
());
check_region
(
&
region
,
10
,
7
,
15
,
11
);
size
.
X
=
23
;
size
.
Y
=
17
;
coord
.
X
=
2
;
coord
.
Y
=
3
;
set_region
(
&
region
,
200
,
7
,
15
,
211
);
ret
=
ReadConsoleOutputW
(
console
,
char_info_buf
,
size
,
coord
,
&
region
);
ok
(
!
ret
&&
GetLastError
()
==
ERROR_NOT_ENOUGH_MEMORY
,
"ReadConsoleOutputW returned: %x(%u)
\n
"
,
ret
,
GetLastError
());
check_region
(
&
region
,
200
,
7
,
15
,
211
);
size
.
X
=
23
;
size
.
Y
=
17
;
coord
.
X
=
2
;
coord
.
Y
=
3
;
set_region
(
&
region
,
200
,
7
,
211
,
8
);
ret
=
ReadConsoleOutputW
(
console
,
char_info_buf
,
size
,
coord
,
&
region
);
ok
((
!
ret
&&
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
||
GetLastError
()
==
ERROR_INVALID_FUNCTION
))
||
broken
(
ret
/* win8 */
),
"ReadConsoleOutputW returned: %x %u
\n
"
,
ret
,
GetLastError
());
if
(
!
ret
&&
GetLastError
()
==
ERROR_INVALID_PARAMETER
)
check_region
(
&
region
,
200
,
7
,
-
211
,
-
8
);
size
.
X
=
23
;
size
.
Y
=
17
;
coord
.
X
=
2
;
coord
.
Y
=
3
;
set_region
(
&
region
,
10
,
7
,
9
,
11
);
ret
=
ReadConsoleOutputW
(
console
,
char_info_buf
,
size
,
coord
,
&
region
);
ok
((
!
ret
&&
(
GetLastError
()
==
ERROR_INVALID_FUNCTION
||
GetLastError
()
==
ERROR_NOT_ENOUGH_MEMORY
))
||
broken
(
ret
/* win8 */
),
"ReadConsoleOutputW returned: %x(%u)
\n
"
,
ret
,
GetLastError
());
check_region
(
&
region
,
10
,
7
,
9
,
-
11
);
size
.
X
=
23
;
size
.
Y
=
17
;
coord
.
X
=
2
;
coord
.
Y
=
3
;
set_region
(
&
region
,
10
,
7
,
11
,
6
);
ret
=
ReadConsoleOutputW
(
console
,
char_info_buf
,
size
,
coord
,
&
region
);
ok
((
!
ret
&&
(
GetLastError
()
==
ERROR_INVALID_FUNCTION
||
GetLastError
()
==
ERROR_NOT_ENOUGH_MEMORY
))
||
broken
(
ret
/* win8 */
),
"ReadConsoleOutputW returned: %x(%u)
\n
"
,
ret
,
GetLastError
());
check_region
(
&
region
,
10
,
7
,
-
11
,
6
);
size
.
X
=
2
;
size
.
Y
=
17
;
coord
.
X
=
2
;
coord
.
Y
=
3
;
set_region
(
&
region
,
10
,
7
,
15
,
11
);
ret
=
ReadConsoleOutputW
(
console
,
char_info_buf
,
size
,
coord
,
&
region
);
ok
((
!
ret
&&
(
GetLastError
()
==
ERROR_INVALID_FUNCTION
||
GetLastError
()
==
ERROR_NOT_ENOUGH_MEMORY
))
||
broken
(
ret
/* win8 */
),
"ReadConsoleOutputW returned: %x(%u)
\n
"
,
ret
,
GetLastError
());
check_region
(
&
region
,
10
,
7
,
-
15
,
-
11
);
size
.
X
=
23
;
size
.
Y
=
3
;
coord
.
X
=
2
;
coord
.
Y
=
3
;
set_region
(
&
region
,
10
,
7
,
15
,
11
);
ret
=
ReadConsoleOutputW
(
console
,
char_info_buf
,
size
,
coord
,
&
region
);
ok
((
!
ret
&&
(
GetLastError
()
==
ERROR_INVALID_FUNCTION
||
GetLastError
()
==
ERROR_NOT_ENOUGH_MEMORY
))
||
broken
(
ret
/* win8 */
),
"ReadConsoleOutputW returned: %x(%u)
\n
"
,
ret
,
GetLastError
());
check_region
(
&
region
,
10
,
7
,
-
15
,
6
);
size
.
X
=
6
;
size
.
Y
=
17
;
coord
.
X
=
2
;
coord
.
Y
=
3
;
set_region
(
&
region
,
10
,
7
,
15
,
11
);
ret
=
ReadConsoleOutputW
(
console
,
char_info_buf
,
size
,
coord
,
&
region
);
ok
(
ret
,
"ReadConsoleOutputW failed: %u
\n
"
,
GetLastError
());
check_region
(
&
region
,
10
,
7
,
13
,
11
);
size
.
X
=
6
;
size
.
Y
=
17
;
coord
.
X
=
2
;
coord
.
Y
=
3
;
set_region
(
&
region
,
10
,
7
,
15
,
11
);
ret
=
ReadConsoleOutputW
((
HANDLE
)
0xdeadbeef
,
char_info_buf
,
size
,
coord
,
&
region
);
ok
(
!
ret
&&
GetLastError
()
==
ERROR_INVALID_HANDLE
,
"ReadConsoleOutputW returned: %x(%u)
\n
"
,
ret
,
GetLastError
());
if
(
!
skip_nt
)
check_region
(
&
region
,
10
,
7
,
13
,
11
);
size
.
X
=
16
;
size
.
Y
=
7
;
coord
.
X
=
2
;
coord
.
Y
=
3
;
set_region
(
&
region
,
10
,
7
,
15
,
11
);
ret
=
ReadConsoleOutputW
(
console
,
char_info_buf
,
size
,
coord
,
&
region
);
ok
(
ret
,
"ReadConsoleOutputW failed: %u
\n
"
,
GetLastError
());
check_region
(
&
region
,
10
,
7
,
15
,
10
);
size
.
X
=
16
;
size
.
Y
=
7
;
coord
.
X
=
2
;
coord
.
Y
=
3
;
set_region
(
&
region
,
info
.
dwSize
.
X
-
2
,
7
,
info
.
dwSize
.
X
+
2
,
7
);
ret
=
ReadConsoleOutputW
(
console
,
char_info_buf
,
size
,
coord
,
&
region
);
ok
(
ret
||
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"ReadConsoleOutputW failed: %u
\n
"
,
GetLastError
());
if
(
ret
)
check_region
(
&
region
,
info
.
dwSize
.
X
-
2
,
7
,
info
.
dwSize
.
X
-
1
,
7
);
coord
.
X
=
2
;
coord
.
Y
=
3
;
ret
=
WriteConsoleOutputCharacterW
(
console
,
L"xyz"
,
3
,
coord
,
&
count
);
ok
(
ret
,
"WriteConsoleOutputCharacterW failed: %u
\n
"
,
GetLastError
());
ok
(
count
==
3
,
"count = %u
\n
"
,
count
);
memset
(
char_info_buf
,
0xc0
,
sizeof
(
char_info_buf
));
size
.
X
=
16
;
size
.
Y
=
7
;
coord
.
X
=
5
;
coord
.
Y
=
6
;
set_region
(
&
region
,
2
,
3
,
5
,
3
);
ret
=
ReadConsoleOutputW
(
console
,
char_info_buf
,
size
,
coord
,
&
region
);
ok
(
ret
,
"ReadConsoleOutputW failed: %u
\n
"
,
GetLastError
());
check_region
(
&
region
,
2
,
3
,
5
,
3
);
ch
=
char_info_buf
[
coord
.
Y
*
size
.
X
+
coord
.
X
].
Char
.
UnicodeChar
;
ok
(
ch
==
'x'
,
"unexpected char %c/%x
\n
"
,
ch
,
ch
);
ch
=
char_info_buf
[
coord
.
Y
*
size
.
X
+
coord
.
X
+
1
].
Char
.
UnicodeChar
;
ok
(
ch
==
'y'
,
"unexpected char %c/%x
\n
"
,
ch
,
ch
);
ch
=
char_info_buf
[
coord
.
Y
*
size
.
X
+
coord
.
X
+
2
].
Char
.
UnicodeChar
;
ok
(
ch
==
'z'
,
"unexpected char %c/%x
\n
"
,
ch
,
ch
);
}
static
void
test_ReadConsole
(
void
)
...
...
@@ -3759,6 +3928,7 @@ START_TEST(console)
test_ReadConsoleOutputCharacterA
(
hConOut
);
test_ReadConsoleOutputCharacterW
(
hConOut
);
test_ReadConsoleOutputAttribute
(
hConOut
);
test_ReadConsoleOutput
(
hConOut
);
test_GetCurrentConsoleFont
(
hConOut
);
test_GetCurrentConsoleFontEx
(
hConOut
);
test_GetConsoleFontSize
(
hConOut
);
...
...
dlls/kernelbase/console.c
View file @
1e5cd8fa
...
...
@@ -914,6 +914,8 @@ BOOL WINAPI DECLSPEC_HOTPATCH ReadConsoleOutputW( HANDLE handle, CHAR_INFO *buff
}
width
=
min
(
region
->
Right
-
region
->
Left
+
1
,
size
.
X
-
coord
.
X
);
height
=
min
(
region
->
Bottom
-
region
->
Top
+
1
,
size
.
Y
-
coord
.
Y
);
region
->
Right
=
region
->
Left
+
width
-
1
;
region
->
Bottom
=
region
->
Top
+
height
-
1
;
count
=
sizeof
(
*
result
)
+
width
*
height
*
sizeof
(
*
buffer
);
if
(
!
(
result
=
HeapAlloc
(
GetProcessHeap
(),
0
,
count
)))
...
...
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