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
4236c470
Commit
4236c470
authored
Oct 05, 2017
by
Nikolay Sivov
Committed by
Alexandre Julliard
Oct 05, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dwrite/tests: Some more tests for in-memory loader.
Signed-off-by:
Nikolay Sivov
<
nsivov@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
94892721
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
84 additions
and
15 deletions
+84
-15
font.c
dlls/dwrite/tests/font.c
+84
-15
No files found.
dlls/dwrite/tests/font.c
View file @
4236c470
...
...
@@ -7591,12 +7591,60 @@ static void test_object_lifetime(void)
ok
(
ref
==
0
,
"factory not released, %u
\n
"
,
ref
);
}
struct
testowner_object
{
IUnknown
IUnknown_iface
;
LONG
ref
;
};
static
inline
struct
testowner_object
*
impl_from_IUnknown
(
IUnknown
*
iface
)
{
return
CONTAINING_RECORD
(
iface
,
struct
testowner_object
,
IUnknown_iface
);
}
static
HRESULT
WINAPI
testowner_QueryInterface
(
IUnknown
*
iface
,
REFIID
riid
,
void
**
obj
)
{
if
(
IsEqualIID
(
riid
,
&
IID_IUnknown
))
{
*
obj
=
iface
;
IUnknown_AddRef
(
iface
);
return
S_OK
;
}
*
obj
=
NULL
;
return
E_NOINTERFACE
;
}
static
ULONG
WINAPI
testowner_AddRef
(
IUnknown
*
iface
)
{
struct
testowner_object
*
object
=
impl_from_IUnknown
(
iface
);
return
InterlockedIncrement
(
&
object
->
ref
);
}
static
ULONG
WINAPI
testowner_Release
(
IUnknown
*
iface
)
{
struct
testowner_object
*
object
=
impl_from_IUnknown
(
iface
);
return
InterlockedDecrement
(
&
object
->
ref
);
}
static
const
IUnknownVtbl
testownervtbl
=
{
testowner_QueryInterface
,
testowner_AddRef
,
testowner_Release
,
};
static
void
testowner_init
(
struct
testowner_object
*
object
)
{
object
->
IUnknown_iface
.
lpVtbl
=
&
testownervtbl
;
object
->
ref
=
1
;
}
static
void
test_inmemory_file_loader
(
void
)
{
IDWriteFontFileStream
*
stream
,
*
stream2
,
*
stream3
;
IDWriteFontFileLoader
*
loader
,
*
loader2
;
IDWriteInMemoryFontFileLoader
*
inmemory
;
struct
testowner_object
ownerobject
;
IDWriteFontFile
*
file
,
*
file2
;
IDWriteFontFileStream
*
stream
;
IDWriteFontFace
*
fontface
;
IDWriteFactory5
*
factory5
;
IDWriteFactory
*
factory
;
...
...
@@ -7616,15 +7664,18 @@ static void test_inmemory_file_loader(void)
return
;
}
EXPECT_REF
(
factory5
,
1
);
hr
=
IDWriteFactory5_CreateInMemoryFontFileLoader
(
factory5
,
&
loader
);
todo_wine
ok
(
hr
==
S_OK
,
"got %#x
\n
"
,
hr
);
EXPECT_REF
(
factory5
,
1
);
if
(
FAILED
(
hr
))
{
IDWriteFactory5_Release
(
factory5
);
return
;
}
testowner_init
(
&
ownerobject
);
fontface
=
create_fontface
((
IDWriteFactory
*
)
factory5
);
hr
=
IDWriteFactory5_CreateInMemoryFontFileLoader
(
factory5
,
&
loader2
);
...
...
@@ -7635,6 +7686,7 @@ todo_wine
hr
=
IDWriteFontFileLoader_QueryInterface
(
loader
,
&
IID_IDWriteInMemoryFontFileLoader
,
(
void
**
)
&
inmemory
);
ok
(
hr
==
S_OK
,
"got %#x
\n
"
,
hr
);
IDWriteFontFileLoader_Release
(
loader
);
EXPECT_REF
(
inmemory
,
1
);
/* Use whole font blob to construct in-memory file. */
count
=
1
;
...
...
@@ -7658,21 +7710,28 @@ todo_wine
hr
=
IDWriteFontFileStream_ReadFileFragment
(
stream
,
&
data
,
0
,
file_size
,
&
context
);
ok
(
hr
==
S_OK
,
"got %#x
\n
"
,
hr
);
/* Not registered yet. */
hr
=
IDWriteInMemoryFontFileLoader_CreateInMemoryFontFileReference
(
inmemory
,
(
IDWriteFactory
*
)
factory5
,
data
,
file_size
,
NULL
,
&
file
);
ok
(
hr
==
E_INVALIDARG
,
"got %#x
\n
"
,
hr
);
hr
=
IDWriteFactory5_RegisterFontFileLoader
(
factory5
,
(
IDWriteFontFileLoader
*
)
inmemory
);
ok
(
hr
==
S_OK
,
"got %#x
\n
"
,
hr
);
EXPECT_REF
(
inmemory
,
2
);
EXPECT_REF
(
&
ownerobject
.
IUnknown_iface
,
1
);
hr
=
IDWriteInMemoryFontFileLoader_CreateInMemoryFontFileReference
(
inmemory
,
(
IDWriteFactory
*
)
factory5
,
data
,
file_size
,
NULL
,
&
file
);
file_size
,
&
ownerobject
.
IUnknown_iface
,
&
file
);
ok
(
hr
==
S_OK
,
"got %#x
\n
"
,
hr
);
EXPECT_REF
(
&
ownerobject
.
IUnknown_iface
,
2
);
EXPECT_REF
(
inmemory
,
3
);
hr
=
IDWriteInMemoryFontFileLoader_CreateInMemoryFontFileReference
(
inmemory
,
(
IDWriteFactory
*
)
factory5
,
data
,
file_size
,
NULL
,
&
file2
);
file_size
,
&
ownerobject
.
IUnknown_iface
,
&
file2
);
ok
(
hr
==
S_OK
,
"got %#x
\n
"
,
hr
);
ok
(
file2
!=
file
,
"got unexpected file
\n
"
);
EXPECT_REF
(
&
ownerobject
.
IUnknown_iface
,
3
);
EXPECT_REF
(
inmemory
,
4
);
/* Check in-memory reference key format. */
hr
=
IDWriteFontFile_GetReferenceKey
(
file
,
&
key
,
&
key_size
);
...
...
@@ -7687,32 +7746,42 @@ todo_wine
ok
(
key
&&
*
(
DWORD
*
)
key
==
2
,
"got wrong ref key
\n
"
);
ok
(
key_size
==
4
,
"ref key size %u
\n
"
,
key_size
);
/* Release file and index 1, create new one to see if index is reused. */
IDWriteFontFile_Release
(
file
);
EXPECT_REF
(
inmemory
,
4
);
hr
=
IDWriteInMemoryFontFileLoader_CreateStreamFromKey
(
inmemory
,
key
,
key_size
,
&
stream2
);
ok
(
hr
==
S_OK
,
"Failed to create a stream, hr %#x.
\n
"
,
hr
);
EXPECT_REF
(
stream2
,
1
);
EXPECT_REF
(
inmemory
,
4
);
hr
=
IDWriteInMemoryFontFileLoader_CreateInMemoryFontFileReference
(
inmemory
,
(
IDWriteFactory
*
)
factory5
,
data
,
file_size
,
NULL
,
&
file
);
ok
(
hr
==
S_OK
,
"got %#x
\n
"
,
hr
);
ok
(
file2
!=
file
,
"got unexpected file
\n
"
);
hr
=
IDWriteInMemoryFontFileLoader_CreateStreamFromKey
(
inmemory
,
key
,
key_size
,
&
stream3
);
ok
(
hr
==
S_OK
,
"Failed to create a stream, hr %#x.
\n
"
,
hr
);
hr
=
IDWriteFontFile_GetReferenceKey
(
file
,
&
key
,
&
key_size
);
ok
(
hr
==
S_OK
,
"got %#x
\n
"
,
hr
);
ok
(
stream2
!=
stream3
,
"Unexpected stream.
\n
"
);
ok
(
key
&&
*
(
DWORD
*
)
key
==
3
,
"got wrong ref key
\n
"
);
ok
(
key_size
==
4
,
"ref key size %u
\n
"
,
key_size
);
IDWriteFontFileStream_Release
(
stream2
);
IDWriteFontFileStream_Release
(
stream3
);
/* Release file at index 1, create new one to see if index is reused. */
EXPECT_REF
(
&
ownerobject
.
IUnknown_iface
,
3
);
IDWriteFontFile_Release
(
file
);
EXPECT_REF
(
&
ownerobject
.
IUnknown_iface
,
3
);
EXPECT_REF
(
&
ownerobject
.
IUnknown_iface
,
3
);
IDWriteFontFile_Release
(
file2
);
EXPECT_REF
(
&
ownerobject
.
IUnknown_iface
,
3
);
hr
=
IDWriteFactory5_UnregisterFontFileLoader
(
factory5
,
(
IDWriteFontFileLoader
*
)
inmemory
);
ok
(
hr
==
S_OK
,
"got %#x
\n
"
,
hr
);
EXPECT_REF
(
&
ownerobject
.
IUnknown_iface
,
3
);
IDWriteFontFileStream_ReleaseFileFragment
(
stream
,
context
);
IDWriteFontFileStream_Release
(
stream
);
IDWriteFontFace_Release
(
fontface
);
IDWriteInMemoryFontFileLoader_Release
(
inmemory
);
EXPECT_REF
(
&
ownerobject
.
IUnknown_iface
,
3
);
ref
=
IDWriteInMemoryFontFileLoader_Release
(
inmemory
);
ok
(
ref
==
0
,
"loader not released, %u.
\n
"
,
ref
);
EXPECT_REF
(
&
ownerobject
.
IUnknown_iface
,
1
);
IDWriteFontFace_Release
(
fontface
);
ref
=
IDWriteFactory5_Release
(
factory5
);
ok
(
ref
==
0
,
"factory not released, %u
\n
"
,
ref
);
}
...
...
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