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
ada2543e
Commit
ada2543e
authored
May 19, 2021
by
Nikolay Sivov
Committed by
Alexandre Julliard
May 19, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dwrite/tests: Add some tests for HitTestTextRange().
Signed-off-by:
Nikolay Sivov
<
nsivov@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
837660e0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
106 additions
and
0 deletions
+106
-0
layout.c
dlls/dwrite/tests/layout.c
+106
-0
No files found.
dlls/dwrite/tests/layout.c
View file @
ada2543e
...
...
@@ -6384,6 +6384,111 @@ static void test_layout_range_length(void)
IDWriteFactory_Release
(
factory
);
}
static
void
test_HitTestTextRange
(
void
)
{
DWRITE_HIT_TEST_METRICS
metrics
[
10
];
IDWriteInlineObject
*
inlineobj
;
DWRITE_LINE_METRICS
line
;
IDWriteTextFormat
*
format
;
IDWriteTextLayout
*
layout
;
DWRITE_TEXT_RANGE
range
;
IDWriteFactory
*
factory
;
unsigned
int
count
;
HRESULT
hr
;
factory
=
create_factory
();
hr
=
IDWriteFactory_CreateTextFormat
(
factory
,
L"Tahoma"
,
NULL
,
DWRITE_FONT_WEIGHT_NORMAL
,
DWRITE_FONT_STYLE_NORMAL
,
DWRITE_FONT_STRETCH_NORMAL
,
10
.
0
f
,
L"ru"
,
&
format
);
ok
(
hr
==
S_OK
,
"Failed to create text format, hr %#x.
\n
"
,
hr
);
hr
=
IDWriteFactory_CreateTextLayout
(
factory
,
L"string"
,
6
,
format
,
100
.
0
f
,
100
.
0
f
,
&
layout
);
ok
(
hr
==
S_OK
,
"Failed to create text layout, hr %#x.
\n
"
,
hr
);
/* Start index exceeding layout text length, dummy range returned. */
count
=
0
;
hr
=
IDWriteTextLayout_HitTestTextRange
(
layout
,
7
,
10
,
0
.
0
f
,
0
.
0
f
,
metrics
,
ARRAY_SIZE
(
metrics
),
&
count
);
todo_wine
ok
(
hr
==
S_OK
,
"Unexpected hr %#x.
\n
"
,
hr
);
if
(
SUCCEEDED
(
hr
))
{
ok
(
count
==
1
,
"Unexpected metrics count %u.
\n
"
,
count
);
ok
(
metrics
[
0
].
textPosition
==
6
&&
metrics
[
0
].
length
==
0
,
"Unexpected metrics range %u, %u.
\n
"
,
metrics
[
0
].
textPosition
,
metrics
[
0
].
length
);
ok
(
!!
metrics
[
0
].
isText
,
"Expected text range.
\n
"
);
}
/* Length exceeding layout text length, trimmed. */
count
=
0
;
hr
=
IDWriteTextLayout_HitTestTextRange
(
layout
,
0
,
10
,
0
.
0
f
,
0
.
0
f
,
metrics
,
ARRAY_SIZE
(
metrics
),
&
count
);
todo_wine
ok
(
hr
==
S_OK
,
"Unexpected hr %#x.
\n
"
,
hr
);
if
(
SUCCEEDED
(
hr
))
{
ok
(
count
==
1
,
"Unexpected metrics count %u.
\n
"
,
count
);
ok
(
metrics
[
0
].
textPosition
==
0
&&
metrics
[
0
].
length
==
6
,
"Unexpected metrics range %u, %u.
\n
"
,
metrics
[
0
].
textPosition
,
metrics
[
0
].
length
);
ok
(
!!
metrics
[
0
].
isText
,
"Expected text range.
\n
"
);
}
/* Change font size for second half. */
range
.
startPosition
=
3
;
range
.
length
=
3
;
hr
=
IDWriteTextLayout_SetFontSize
(
layout
,
20
.
0
f
,
range
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#x.
\n
"
,
hr
);
count
=
0
;
hr
=
IDWriteTextLayout_HitTestTextRange
(
layout
,
0
,
6
,
0
.
0
f
,
0
.
0
f
,
metrics
,
ARRAY_SIZE
(
metrics
),
&
count
);
todo_wine
ok
(
hr
==
S_OK
,
"Unexpected hr %#x.
\n
"
,
hr
);
if
(
SUCCEEDED
(
hr
))
{
ok
(
count
==
1
,
"Unexpected metrics count %u.
\n
"
,
count
);
ok
(
metrics
[
0
].
textPosition
==
0
&&
metrics
[
0
].
length
==
6
,
"Unexpected metrics range %u, %u.
\n
"
,
metrics
[
0
].
textPosition
,
metrics
[
0
].
length
);
ok
(
!!
metrics
[
0
].
isText
,
"Expected text range.
\n
"
);
hr
=
IDWriteTextLayout_GetLineMetrics
(
layout
,
&
line
,
1
,
&
count
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#x.
\n
"
,
hr
);
ok
(
line
.
height
==
metrics
[
0
].
height
,
"Unexpected range height.
\n
"
);
}
/* With inline object. */
hr
=
IDWriteFactory_CreateEllipsisTrimmingSign
(
factory
,
format
,
&
inlineobj
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDWriteTextLayout_SetInlineObject
(
layout
,
inlineobj
,
range
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#x.
\n
"
,
hr
);
count
=
0
;
hr
=
IDWriteTextLayout_HitTestTextRange
(
layout
,
0
,
6
,
0
.
0
f
,
0
.
0
f
,
metrics
,
ARRAY_SIZE
(
metrics
),
&
count
);
todo_wine
ok
(
hr
==
S_OK
,
"Unexpected hr %#x.
\n
"
,
hr
);
if
(
SUCCEEDED
(
hr
))
{
ok
(
count
==
2
,
"Unexpected metrics count %u.
\n
"
,
count
);
ok
(
metrics
[
0
].
textPosition
==
0
&&
metrics
[
0
].
length
==
3
,
"Unexpected metrics range %u, %u.
\n
"
,
metrics
[
0
].
textPosition
,
metrics
[
0
].
length
);
ok
(
!!
metrics
[
0
].
isText
,
"Expected text range.
\n
"
);
ok
(
metrics
[
1
].
textPosition
==
3
&&
metrics
[
1
].
length
==
3
,
"Unexpected metrics range %u, %u.
\n
"
,
metrics
[
1
].
textPosition
,
metrics
[
1
].
length
);
ok
(
!
metrics
[
1
].
isText
,
"Unexpected text range.
\n
"
);
}
count
=
0
;
hr
=
IDWriteTextLayout_HitTestTextRange
(
layout
,
7
,
10
,
0
.
0
f
,
0
.
0
f
,
metrics
,
ARRAY_SIZE
(
metrics
),
&
count
);
todo_wine
ok
(
hr
==
S_OK
,
"Unexpected hr %#x.
\n
"
,
hr
);
if
(
SUCCEEDED
(
hr
))
{
ok
(
count
==
1
,
"Unexpected metrics count %u.
\n
"
,
count
);
ok
(
metrics
[
0
].
textPosition
==
6
&&
metrics
[
0
].
length
==
0
,
"Unexpected metrics range %u, %u.
\n
"
,
metrics
[
0
].
textPosition
,
metrics
[
0
].
length
);
ok
(
!
metrics
[
0
].
isText
,
"Unexpected text range.
\n
"
);
}
IDWriteInlineObject_Release
(
inlineobj
);
IDWriteTextLayout_Release
(
layout
);
IDWriteTextFormat_Release
(
format
);
IDWriteFactory_Release
(
factory
);
}
START_TEST
(
layout
)
{
IDWriteFactory
*
factory
;
...
...
@@ -6438,6 +6543,7 @@ START_TEST(layout)
test_automatic_font_axes
();
test_text_format_axes
();
test_layout_range_length
();
test_HitTestTextRange
();
IDWriteFactory_Release
(
factory
);
}
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