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
61fa9bb0
Commit
61fa9bb0
authored
Mar 31, 2009
by
Huw Davies
Committed by
Alexandre Julliard
Mar 31, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ole32/tests: Add some tests for stream data.
parent
d28d731b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
11 deletions
+64
-11
clipboard.c
dlls/ole32/tests/clipboard.c
+64
-11
No files found.
dlls/ole32/tests/clipboard.c
View file @
61fa9bb0
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
#define COBJMACROS
#define COBJMACROS
#include <stdarg.h>
#include <stdarg.h>
#include <stdio.h>
#include "windef.h"
#include "windef.h"
#include "winbase.h"
#include "winbase.h"
...
@@ -37,6 +38,15 @@
...
@@ -37,6 +38,15 @@
(fe).lindex=-1;\
(fe).lindex=-1;\
};
};
static
inline
char
*
dump_fmtetc
(
FORMATETC
*
fmt
)
{
static
char
buf
[
100
];
snprintf
(
buf
,
sizeof
(
buf
),
"cf %04x ptd %p aspect %x lindex %d tymed %x"
,
fmt
->
cfFormat
,
fmt
->
ptd
,
fmt
->
dwAspect
,
fmt
->
lindex
,
fmt
->
tymed
);
return
buf
;
}
typedef
struct
DataObjectImpl
{
typedef
struct
DataObjectImpl
{
const
IDataObjectVtbl
*
lpVtbl
;
const
IDataObjectVtbl
*
lpVtbl
;
LONG
ref
;
LONG
ref
;
...
@@ -61,9 +71,10 @@ typedef struct EnumFormatImpl {
...
@@ -61,9 +71,10 @@ typedef struct EnumFormatImpl {
static
BOOL
expect_DataObjectImpl_QueryGetData
=
TRUE
;
static
BOOL
expect_DataObjectImpl_QueryGetData
=
TRUE
;
static
ULONG
DataObjectImpl_GetData_calls
=
0
;
static
ULONG
DataObjectImpl_GetData_calls
=
0
;
static
ULONG
DataObjectImpl_GetDataHere_calls
=
0
;
static
ULONG
DataObjectImpl_EnumFormatEtc_calls
=
0
;
static
ULONG
DataObjectImpl_EnumFormatEtc_calls
=
0
;
static
UINT
cf_stream
,
cf_storage
,
cf_another
,
cf_onemore
;
static
UINT
cf_stream
,
cf_storage
,
cf_
global
,
cf_
another
,
cf_onemore
;
static
HRESULT
EnumFormatImpl_Create
(
FORMATETC
*
fmtetc
,
UINT
size
,
LPENUMFORMATETC
*
lplpformatetc
);
static
HRESULT
EnumFormatImpl_Create
(
FORMATETC
*
fmtetc
,
UINT
size
,
LPENUMFORMATETC
*
lplpformatetc
);
...
@@ -216,6 +227,8 @@ static HRESULT WINAPI DataObjectImpl_GetData(IDataObject* iface, FORMATETC *pfor
...
@@ -216,6 +227,8 @@ static HRESULT WINAPI DataObjectImpl_GetData(IDataObject* iface, FORMATETC *pfor
UINT
i
;
UINT
i
;
BOOL
foundFormat
=
FALSE
;
BOOL
foundFormat
=
FALSE
;
trace
(
"getdata: %s
\n
"
,
dump_fmtetc
(
pformatetc
));
DataObjectImpl_GetData_calls
++
;
DataObjectImpl_GetData_calls
++
;
if
(
pformatetc
->
lindex
!=
-
1
)
if
(
pformatetc
->
lindex
!=
-
1
)
...
@@ -231,7 +244,7 @@ static HRESULT WINAPI DataObjectImpl_GetData(IDataObject* iface, FORMATETC *pfor
...
@@ -231,7 +244,7 @@ static HRESULT WINAPI DataObjectImpl_GetData(IDataObject* iface, FORMATETC *pfor
pmedium
->
pUnkForRelease
=
(
LPUNKNOWN
)
iface
;
pmedium
->
pUnkForRelease
=
(
LPUNKNOWN
)
iface
;
IUnknown_AddRef
(
pmedium
->
pUnkForRelease
);
IUnknown_AddRef
(
pmedium
->
pUnkForRelease
);
if
(
pformatetc
->
cfFormat
==
CF_TEXT
)
if
(
pformatetc
->
cfFormat
==
CF_TEXT
||
pformatetc
->
cfFormat
==
cf_global
)
U
(
*
pmedium
).
hGlobal
=
This
->
text
;
U
(
*
pmedium
).
hGlobal
=
This
->
text
;
else
if
(
pformatetc
->
cfFormat
==
cf_stream
)
else
if
(
pformatetc
->
cfFormat
==
cf_stream
)
U
(
*
pmedium
).
pstm
=
This
->
stm
;
U
(
*
pmedium
).
pstm
=
This
->
stm
;
...
@@ -247,7 +260,9 @@ static HRESULT WINAPI DataObjectImpl_GetData(IDataObject* iface, FORMATETC *pfor
...
@@ -247,7 +260,9 @@ static HRESULT WINAPI DataObjectImpl_GetData(IDataObject* iface, FORMATETC *pfor
static
HRESULT
WINAPI
DataObjectImpl_GetDataHere
(
IDataObject
*
iface
,
FORMATETC
*
pformatetc
,
STGMEDIUM
*
pmedium
)
static
HRESULT
WINAPI
DataObjectImpl_GetDataHere
(
IDataObject
*
iface
,
FORMATETC
*
pformatetc
,
STGMEDIUM
*
pmedium
)
{
{
ok
(
0
,
"unexpected call
\n
"
);
trace
(
"getdatahere: %s
\n
"
,
dump_fmtetc
(
pformatetc
));
DataObjectImpl_GetDataHere_calls
++
;
return
E_NOTIMPL
;
return
E_NOTIMPL
;
}
}
...
@@ -257,6 +272,7 @@ static HRESULT WINAPI DataObjectImpl_QueryGetData(IDataObject* iface, FORMATETC
...
@@ -257,6 +272,7 @@ static HRESULT WINAPI DataObjectImpl_QueryGetData(IDataObject* iface, FORMATETC
UINT
i
;
UINT
i
;
BOOL
foundFormat
=
FALSE
;
BOOL
foundFormat
=
FALSE
;
trace
(
"querygetdata: %s
\n
"
,
dump_fmtetc
(
pformatetc
));
if
(
!
expect_DataObjectImpl_QueryGetData
)
if
(
!
expect_DataObjectImpl_QueryGetData
)
ok
(
0
,
"unexpected call to DataObjectImpl_QueryGetData
\n
"
);
ok
(
0
,
"unexpected call to DataObjectImpl_QueryGetData
\n
"
);
...
@@ -357,11 +373,12 @@ static HRESULT DataObjectImpl_CreateText(LPCSTR text, LPDATAOBJECT *lplpdataobj)
...
@@ -357,11 +373,12 @@ static HRESULT DataObjectImpl_CreateText(LPCSTR text, LPDATAOBJECT *lplpdataobj)
return
S_OK
;
return
S_OK
;
}
}
const
char
*
cmpl_stm_data
=
"complex stream"
;
const
char
*
cmpl_text_data
=
"complex text"
;
static
HRESULT
DataObjectImpl_CreateComplex
(
LPDATAOBJECT
*
lplpdataobj
)
static
HRESULT
DataObjectImpl_CreateComplex
(
LPDATAOBJECT
*
lplpdataobj
)
{
{
DataObjectImpl
*
obj
;
DataObjectImpl
*
obj
;
const
char
*
stm_data
=
"complex stream"
;
const
char
*
text_data
=
"complex text"
;
ILockBytes
*
lbs
;
ILockBytes
*
lbs
;
static
const
WCHAR
devname
[]
=
{
'm'
,
'y'
,
'd'
,
'e'
,
'v'
,
0
};
static
const
WCHAR
devname
[]
=
{
'm'
,
'y'
,
'd'
,
'e'
,
'v'
,
0
};
DEVMODEW
dm
;
DEVMODEW
dm
;
...
@@ -369,17 +386,17 @@ static HRESULT DataObjectImpl_CreateComplex(LPDATAOBJECT *lplpdataobj)
...
@@ -369,17 +386,17 @@ static HRESULT DataObjectImpl_CreateComplex(LPDATAOBJECT *lplpdataobj)
obj
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
DataObjectImpl
));
obj
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
DataObjectImpl
));
obj
->
lpVtbl
=
&
VT_DataObjectImpl
;
obj
->
lpVtbl
=
&
VT_DataObjectImpl
;
obj
->
ref
=
1
;
obj
->
ref
=
1
;
obj
->
text
=
GlobalAlloc
(
GMEM_MOVEABLE
,
strlen
(
text_data
)
+
1
);
obj
->
text
=
GlobalAlloc
(
GMEM_MOVEABLE
,
strlen
(
cmpl_
text_data
)
+
1
);
strcpy
(
GlobalLock
(
obj
->
text
),
text_data
);
strcpy
(
GlobalLock
(
obj
->
text
),
cmpl_
text_data
);
GlobalUnlock
(
obj
->
text
);
GlobalUnlock
(
obj
->
text
);
CreateStreamOnHGlobal
(
NULL
,
TRUE
,
&
obj
->
stm
);
CreateStreamOnHGlobal
(
NULL
,
TRUE
,
&
obj
->
stm
);
IStream_Write
(
obj
->
stm
,
stm_data
,
strlen
(
stm_data
),
NULL
);
IStream_Write
(
obj
->
stm
,
cmpl_stm_data
,
strlen
(
cmpl_
stm_data
),
NULL
);
CreateILockBytesOnHGlobal
(
NULL
,
TRUE
,
&
lbs
);
CreateILockBytesOnHGlobal
(
NULL
,
TRUE
,
&
lbs
);
StgCreateDocfileOnILockBytes
(
lbs
,
STGM_CREATE
|
STGM_SHARE_EXCLUSIVE
|
STGM_READWRITE
,
0
,
&
obj
->
stg
);
StgCreateDocfileOnILockBytes
(
lbs
,
STGM_CREATE
|
STGM_SHARE_EXCLUSIVE
|
STGM_READWRITE
,
0
,
&
obj
->
stg
);
ILockBytes_Release
(
lbs
);
ILockBytes_Release
(
lbs
);
obj
->
fmtetc_cnt
=
5
;
obj
->
fmtetc_cnt
=
8
;
/* zeroing here since FORMATETC has a hole in it, and it's confusing to have this uninitialised. */
/* zeroing here since FORMATETC has a hole in it, and it's confusing to have this uninitialised. */
obj
->
fmtetc
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
obj
->
fmtetc_cnt
*
sizeof
(
FORMATETC
));
obj
->
fmtetc
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
obj
->
fmtetc_cnt
*
sizeof
(
FORMATETC
));
InitFormatEtc
(
obj
->
fmtetc
[
0
],
CF_TEXT
,
TYMED_HGLOBAL
);
InitFormatEtc
(
obj
->
fmtetc
[
0
],
CF_TEXT
,
TYMED_HGLOBAL
);
...
@@ -399,8 +416,11 @@ static HRESULT DataObjectImpl_CreateComplex(LPDATAOBJECT *lplpdataobj)
...
@@ -399,8 +416,11 @@ static HRESULT DataObjectImpl_CreateComplex(LPDATAOBJECT *lplpdataobj)
lstrcpyW
((
WCHAR
*
)
obj
->
fmtetc
[
3
].
ptd
->
tdData
,
devname
);
lstrcpyW
((
WCHAR
*
)
obj
->
fmtetc
[
3
].
ptd
->
tdData
,
devname
);
memcpy
(
obj
->
fmtetc
[
3
].
ptd
->
tdData
+
sizeof
(
devname
),
&
dm
,
dm
.
dmSize
+
dm
.
dmDriverExtra
);
memcpy
(
obj
->
fmtetc
[
3
].
ptd
->
tdData
+
sizeof
(
devname
),
&
dm
,
dm
.
dmSize
+
dm
.
dmDriverExtra
);
InitFormatEtc
(
obj
->
fmtetc
[
4
],
cf_stream
,
0xfffff
);
InitFormatEtc
(
obj
->
fmtetc
[
4
],
cf_global
,
TYMED_HGLOBAL
);
obj
->
fmtetc
[
4
].
dwAspect
=
DVASPECT_ICON
;
InitFormatEtc
(
obj
->
fmtetc
[
5
],
cf_another
,
TYMED_HGLOBAL
);
InitFormatEtc
(
obj
->
fmtetc
[
6
],
cf_another
,
0xfffff
);
InitFormatEtc
(
obj
->
fmtetc
[
7
],
cf_another
,
0xfffff
);
obj
->
fmtetc
[
7
].
dwAspect
=
DVASPECT_ICON
;
*
lplpdataobj
=
(
LPDATAOBJECT
)
obj
;
*
lplpdataobj
=
(
LPDATAOBJECT
)
obj
;
return
S_OK
;
return
S_OK
;
...
@@ -533,6 +553,7 @@ static void test_enum_fmtetc(IDataObject *src)
...
@@ -533,6 +553,7 @@ static void test_enum_fmtetc(IDataObject *src)
ok
(
src
!=
NULL
,
"shouldn't be here
\n
"
);
ok
(
src
!=
NULL
,
"shouldn't be here
\n
"
);
hr
=
IEnumFORMATETC_Next
(
src_enum
,
1
,
&
src_fmt
,
NULL
);
hr
=
IEnumFORMATETC_Next
(
src_enum
,
1
,
&
src_fmt
,
NULL
);
ok
(
hr
==
S_OK
,
"%d: got %08x
\n
"
,
count
,
hr
);
ok
(
hr
==
S_OK
,
"%d: got %08x
\n
"
,
count
,
hr
);
trace
(
"%d: cf %04x aspect %x tymed %x
\n
"
,
count
,
fmt
.
cfFormat
,
fmt
.
dwAspect
,
fmt
.
tymed
);
ok
(
fmt
.
cfFormat
==
src_fmt
.
cfFormat
,
"%d: %04x %04x
\n
"
,
count
,
fmt
.
cfFormat
,
src_fmt
.
cfFormat
);
ok
(
fmt
.
cfFormat
==
src_fmt
.
cfFormat
,
"%d: %04x %04x
\n
"
,
count
,
fmt
.
cfFormat
,
src_fmt
.
cfFormat
);
ok
(
fmt
.
dwAspect
==
src_fmt
.
dwAspect
,
"%d: %08x %08x
\n
"
,
count
,
fmt
.
dwAspect
,
src_fmt
.
dwAspect
);
ok
(
fmt
.
dwAspect
==
src_fmt
.
dwAspect
,
"%d: %08x %08x
\n
"
,
count
,
fmt
.
dwAspect
,
src_fmt
.
dwAspect
);
ok
(
fmt
.
lindex
==
src_fmt
.
lindex
,
"%d: %08x %08x
\n
"
,
count
,
fmt
.
lindex
,
src_fmt
.
lindex
);
ok
(
fmt
.
lindex
==
src_fmt
.
lindex
,
"%d: %08x %08x
\n
"
,
count
,
fmt
.
lindex
,
src_fmt
.
lindex
);
...
@@ -673,6 +694,36 @@ static void test_cf_dataobject(IDataObject *data)
...
@@ -673,6 +694,36 @@ static void test_cf_dataobject(IDataObject *data)
}
}
}
}
}
}
else
if
(
cf
==
cf_stream
)
{
HGLOBAL
h
;
void
*
ptr
;
DWORD
size
;
DataObjectImpl_GetDataHere_calls
=
0
;
h
=
GetClipboardData
(
cf
);
ok
(
DataObjectImpl_GetDataHere_calls
==
1
,
"got %d
\n
"
,
DataObjectImpl_GetDataHere_calls
);
ptr
=
GlobalLock
(
h
);
size
=
GlobalSize
(
h
);
ok
(
size
==
strlen
(
cmpl_stm_data
),
"expected %d got %d
\n
"
,
strlen
(
cmpl_stm_data
),
size
);
ok
(
!
memcmp
(
ptr
,
cmpl_stm_data
,
size
),
"mismatch
\n
"
);
GlobalUnlock
(
h
);
}
else
if
(
cf
==
cf_global
)
{
HGLOBAL
h
;
void
*
ptr
;
DWORD
size
;
DataObjectImpl_GetDataHere_calls
=
0
;
h
=
GetClipboardData
(
cf
);
ok
(
DataObjectImpl_GetDataHere_calls
==
0
,
"got %d
\n
"
,
DataObjectImpl_GetDataHere_calls
);
ptr
=
GlobalLock
(
h
);
size
=
GlobalSize
(
h
);
ok
(
size
==
strlen
(
cmpl_text_data
)
+
1
,
"expected %d got %d
\n
"
,
strlen
(
cmpl_text_data
)
+
1
,
size
);
ok
(
!
memcmp
(
ptr
,
cmpl_text_data
,
size
),
"mismatch
\n
"
);
GlobalUnlock
(
h
);
}
}
while
(
cf
);
}
while
(
cf
);
CloseClipboard
();
CloseClipboard
();
ok
(
found_dataobject
,
"didn't find cf_dataobject
\n
"
);
ok
(
found_dataobject
,
"didn't find cf_dataobject
\n
"
);
...
@@ -688,6 +739,7 @@ static void test_set_clipboard(void)
...
@@ -688,6 +739,7 @@ static void test_set_clipboard(void)
cf_stream
=
RegisterClipboardFormatA
(
"stream format"
);
cf_stream
=
RegisterClipboardFormatA
(
"stream format"
);
cf_storage
=
RegisterClipboardFormatA
(
"storage format"
);
cf_storage
=
RegisterClipboardFormatA
(
"storage format"
);
cf_global
=
RegisterClipboardFormatA
(
"global format"
);
cf_another
=
RegisterClipboardFormatA
(
"another format"
);
cf_another
=
RegisterClipboardFormatA
(
"another format"
);
cf_onemore
=
RegisterClipboardFormatA
(
"one more format"
);
cf_onemore
=
RegisterClipboardFormatA
(
"one more format"
);
...
@@ -779,6 +831,7 @@ static void test_set_clipboard(void)
...
@@ -779,6 +831,7 @@ static void test_set_clipboard(void)
ok
(
h
==
NULL
,
"got %p
\n
"
,
h
);
ok
(
h
==
NULL
,
"got %p
\n
"
,
h
);
CloseClipboard
();
CloseClipboard
();
trace
(
"setting complex
\n
"
);
hr
=
OleSetClipboard
(
data_cmpl
);
hr
=
OleSetClipboard
(
data_cmpl
);
ok
(
hr
==
S_OK
,
"failed to set clipboard to complex data, hr = 0x%08x
\n
"
,
hr
);
ok
(
hr
==
S_OK
,
"failed to set clipboard to complex data, hr = 0x%08x
\n
"
,
hr
);
test_cf_dataobject
(
data_cmpl
);
test_cf_dataobject
(
data_cmpl
);
...
...
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