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
439d5852
Commit
439d5852
authored
Feb 01, 2010
by
Huw Davies
Committed by
Alexandre Julliard
Feb 01, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
oleaut32: Add tests to explore the lifetime of font handles.
parent
ad9843fa
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
150 additions
and
0 deletions
+150
-0
olefont.c
dlls/oleaut32/tests/olefont.c
+150
-0
No files found.
dlls/oleaut32/tests/olefont.c
View file @
439d5852
...
@@ -836,6 +836,155 @@ static void test_returns(void)
...
@@ -836,6 +836,155 @@ static void test_returns(void)
IFont_Release
(
pFont
);
IFont_Release
(
pFont
);
}
}
static
void
test_hfont_lifetime
(
void
)
{
IFont
*
font
;
FONTDESC
fontdesc
;
HRESULT
hr
;
HFONT
hfont
,
first_hfont
=
NULL
;
CY
size
;
DWORD
obj_type
;
int
i
;
fontdesc
.
cbSizeofstruct
=
sizeof
(
fontdesc
);
fontdesc
.
lpstrName
=
arial_font
;
fontdesc
.
cySize
.
int64
=
12
*
10000
;
/* 12 pt */
fontdesc
.
sWeight
=
FW_NORMAL
;
fontdesc
.
sCharset
=
ANSI_CHARSET
;
fontdesc
.
fItalic
=
FALSE
;
fontdesc
.
fUnderline
=
FALSE
;
fontdesc
.
fStrikethrough
=
FALSE
;
hr
=
pOleCreateFontIndirect
(
&
fontdesc
,
&
IID_IFont
,
(
void
**
)
&
font
);
ok_ole_success
(
hr
,
"OleCreateFontIndirect"
);
hr
=
IFont_get_hFont
(
font
,
&
hfont
);
ok_ole_success
(
hr
,
"get_hFont"
);
/* show that if the font is updated the old hfont is deleted when the
new font is realized */
for
(
i
=
0
;
i
<
100
;
i
++
)
{
HFONT
last_hfont
=
hfont
;
size
.
int64
=
(
i
+
10
)
*
20000
;
obj_type
=
GetObjectType
(
hfont
);
ok
(
obj_type
==
OBJ_FONT
,
"got obj type %d
\n
"
,
obj_type
);
hr
=
IFont_put_Size
(
font
,
size
);
ok_ole_success
(
hr
,
"put_Size"
);
/* put_Size doesn't cause the new font to be realized */
obj_type
=
GetObjectType
(
last_hfont
);
ok
(
obj_type
==
OBJ_FONT
,
"got obj type %d
\n
"
,
obj_type
);
hr
=
IFont_get_hFont
(
font
,
&
hfont
);
ok_ole_success
(
hr
,
"get_hFont"
);
obj_type
=
GetObjectType
(
last_hfont
);
todo_wine
ok
(
obj_type
==
0
,
"%d: got obj type %d
\n
"
,
i
,
obj_type
);
}
/* now show that if we take a reference on the hfont, it persists
until the font object is released */
for
(
i
=
0
;
i
<
100
;
i
++
)
{
size
.
int64
=
(
i
+
10
)
*
20000
;
obj_type
=
GetObjectType
(
hfont
);
ok
(
obj_type
==
OBJ_FONT
,
"got obj type %d
\n
"
,
obj_type
);
hr
=
IFont_put_Size
(
font
,
size
);
ok_ole_success
(
hr
,
"put_Size"
);
hr
=
IFont_get_hFont
(
font
,
&
hfont
);
ok_ole_success
(
hr
,
"get_hFont"
);
hr
=
IFont_AddRefHfont
(
font
,
hfont
);
ok_ole_success
(
hr
,
"AddRefHfont"
);
if
(
i
==
0
)
first_hfont
=
hfont
;
obj_type
=
GetObjectType
(
first_hfont
);
ok
(
obj_type
==
OBJ_FONT
,
"got obj type %d
\n
"
,
obj_type
);
}
IFont_Release
(
font
);
obj_type
=
GetObjectType
(
first_hfont
);
ok
(
obj_type
==
0
,
"got obj type %d
\n
"
,
obj_type
);
/* An AddRefHfont followed by a ReleaseHfont means the font doesn't not persist
through re-realization */
hr
=
pOleCreateFontIndirect
(
&
fontdesc
,
&
IID_IFont
,
(
void
**
)
&
font
);
ok_ole_success
(
hr
,
"OleCreateFontIndirect"
);
hr
=
IFont_get_hFont
(
font
,
&
hfont
);
ok_ole_success
(
hr
,
"get_hFont"
);
for
(
i
=
0
;
i
<
100
;
i
++
)
{
HFONT
last_hfont
=
hfont
;
size
.
int64
=
(
i
+
10
)
*
20000
;
obj_type
=
GetObjectType
(
hfont
);
ok
(
obj_type
==
OBJ_FONT
,
"got obj type %d
\n
"
,
obj_type
);
hr
=
IFont_put_Size
(
font
,
size
);
ok_ole_success
(
hr
,
"put_Size"
);
/* put_Size doesn't cause the new font to be realized */
obj_type
=
GetObjectType
(
last_hfont
);
ok
(
obj_type
==
OBJ_FONT
,
"got obj type %d
\n
"
,
obj_type
);
hr
=
IFont_get_hFont
(
font
,
&
hfont
);
ok_ole_success
(
hr
,
"get_hFont"
);
hr
=
IFont_AddRefHfont
(
font
,
hfont
);
ok_ole_success
(
hr
,
"AddRefHfont"
);
hr
=
IFont_ReleaseHfont
(
font
,
hfont
);
ok_ole_success
(
hr
,
"ReleaseHfont"
);
obj_type
=
GetObjectType
(
last_hfont
);
todo_wine
ok
(
obj_type
==
0
,
"%d: got obj type %d
\n
"
,
i
,
obj_type
);
}
/* Interestingly if we release a non-existent reference on the hfont, it persists
until the font object is released */
for
(
i
=
0
;
i
<
100
;
i
++
)
{
size
.
int64
=
(
i
+
10
)
*
20000
;
obj_type
=
GetObjectType
(
hfont
);
ok
(
obj_type
==
OBJ_FONT
,
"got obj type %d
\n
"
,
obj_type
);
hr
=
IFont_put_Size
(
font
,
size
);
ok_ole_success
(
hr
,
"put_Size"
);
hr
=
IFont_get_hFont
(
font
,
&
hfont
);
ok_ole_success
(
hr
,
"get_hFont"
);
hr
=
IFont_ReleaseHfont
(
font
,
hfont
);
ok_ole_success
(
hr
,
"ReleaseHfont"
);
if
(
i
==
0
)
first_hfont
=
hfont
;
obj_type
=
GetObjectType
(
first_hfont
);
ok
(
obj_type
==
OBJ_FONT
,
"got obj type %d
\n
"
,
obj_type
);
}
IFont_Release
(
font
);
obj_type
=
GetObjectType
(
first_hfont
);
ok
(
obj_type
==
0
,
"got obj type %d
\n
"
,
obj_type
);
}
START_TEST
(
olefont
)
START_TEST
(
olefont
)
{
{
hOleaut32
=
GetModuleHandleA
(
"oleaut32.dll"
);
hOleaut32
=
GetModuleHandleA
(
"oleaut32.dll"
);
...
@@ -869,4 +1018,5 @@ START_TEST(olefont)
...
@@ -869,4 +1018,5 @@ START_TEST(olefont)
test_ReleaseHfont
();
test_ReleaseHfont
();
test_AddRefHfont
();
test_AddRefHfont
();
test_returns
();
test_returns
();
test_hfont_lifetime
();
}
}
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