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
0a1f9bec
Commit
0a1f9bec
authored
Aug 17, 2016
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
user32/tests: Add tests for clipboard global memory handles.
The GMEM_FIXED tests are based on a patch by Rafał Harabień. Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
295061a2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
127 additions
and
0 deletions
+127
-0
clipboard.c
dlls/user32/tests/clipboard.c
+127
-0
No files found.
dlls/user32/tests/clipboard.c
View file @
0a1f9bec
...
@@ -682,6 +682,132 @@ static void test_messages(void)
...
@@ -682,6 +682,132 @@ static void test_messages(void)
DeleteCriticalSection
(
&
clipboard_cs
);
DeleteCriticalSection
(
&
clipboard_cs
);
}
}
static
BOOL
is_moveable
(
HANDLE
handle
)
{
void
*
ptr
=
GlobalLock
(
handle
);
if
(
ptr
)
GlobalUnlock
(
handle
);
return
ptr
&&
ptr
!=
handle
;
}
static
BOOL
is_fixed
(
HANDLE
handle
)
{
void
*
ptr
=
GlobalLock
(
handle
);
if
(
ptr
)
GlobalUnlock
(
handle
);
return
ptr
&&
ptr
==
handle
;
}
static
BOOL
is_freed
(
HANDLE
handle
)
{
void
*
ptr
=
GlobalLock
(
handle
);
if
(
ptr
)
GlobalUnlock
(
handle
);
return
!
ptr
;
}
static
UINT
format_id
;
static
void
test_handles
(
HWND
hwnd
)
{
HGLOBAL
h
,
htext
,
htext2
;
BOOL
r
;
HANDLE
data
;
DWORD
process
;
BOOL
is_owner
=
(
GetWindowThreadProcessId
(
hwnd
,
&
process
)
&&
process
==
GetCurrentProcessId
());
trace
(
"hwnd %p
\n
"
,
hwnd
);
htext
=
create_text
();
htext2
=
create_text
();
r
=
OpenClipboard
(
hwnd
);
ok
(
r
,
"gle %d
\n
"
,
GetLastError
()
);
r
=
EmptyClipboard
();
ok
(
r
,
"gle %d
\n
"
,
GetLastError
()
);
h
=
SetClipboardData
(
CF_TEXT
,
htext
);
ok
(
h
==
htext
,
"got %p
\n
"
,
h
);
ok
(
is_moveable
(
h
),
"expected moveable mem %p
\n
"
,
h
);
h
=
SetClipboardData
(
format_id
,
htext2
);
ok
(
h
==
htext2
,
"got %p
\n
"
,
h
);
ok
(
is_moveable
(
h
),
"expected moveable mem %p
\n
"
,
h
);
data
=
GetClipboardData
(
CF_TEXT
);
ok
(
data
==
htext
,
"wrong data %p
\n
"
,
data
);
ok
(
is_moveable
(
data
),
"expected moveable mem %p
\n
"
,
data
);
data
=
GetClipboardData
(
format_id
);
ok
(
data
==
htext2
,
"wrong data %p, cf %08x
\n
"
,
data
,
format_id
);
ok
(
is_moveable
(
data
),
"expected moveable mem %p
\n
"
,
data
);
r
=
CloseClipboard
();
ok
(
r
,
"gle %d
\n
"
,
GetLastError
()
);
/* data handles are still valid */
ok
(
is_moveable
(
htext
),
"expected moveable mem %p
\n
"
,
htext
);
ok
(
is_moveable
(
htext2
),
"expected moveable mem %p
\n
"
,
htext
);
r
=
OpenClipboard
(
hwnd
);
ok
(
r
,
"gle %d
\n
"
,
GetLastError
()
);
/* and now they are freed, unless we are the owner */
if
(
!
is_owner
)
{
todo_wine
ok
(
is_freed
(
htext
),
"expected freed mem %p
\n
"
,
htext
);
todo_wine
ok
(
is_freed
(
htext2
),
"expected freed mem %p
\n
"
,
htext
);
data
=
GetClipboardData
(
CF_TEXT
);
todo_wine
ok
(
is_fixed
(
data
),
"expected fixed mem %p
\n
"
,
data
);
data
=
GetClipboardData
(
CF_OEMTEXT
);
todo_wine
ok
(
is_fixed
(
data
),
"expected fixed mem %p
\n
"
,
data
);
data
=
GetClipboardData
(
CF_UNICODETEXT
);
todo_wine
ok
(
is_fixed
(
data
),
"expected fixed mem %p
\n
"
,
data
);
data
=
GetClipboardData
(
format_id
);
todo_wine
ok
(
is_fixed
(
data
),
"expected fixed mem %p
\n
"
,
data
);
}
else
{
ok
(
is_moveable
(
htext
),
"expected moveable mem %p
\n
"
,
htext
);
ok
(
is_moveable
(
htext2
),
"expected moveable mem %p
\n
"
,
htext
);
data
=
GetClipboardData
(
CF_TEXT
);
ok
(
data
==
htext
,
"wrong data %p
\n
"
,
data
);
data
=
GetClipboardData
(
format_id
);
ok
(
data
==
htext2
,
"wrong data %p, cf %08x
\n
"
,
data
,
format_id
);
}
r
=
EmptyClipboard
();
ok
(
r
,
"gle %d
\n
"
,
GetLastError
()
);
/* w2003, w2008 don't seem to free the data here */
ok
(
is_freed
(
htext
)
||
broken
(
!
is_freed
(
htext
)),
"expected freed mem %p
\n
"
,
htext
);
ok
(
is_freed
(
htext2
)
||
broken
(
!
is_freed
(
htext2
)),
"expected freed mem %p
\n
"
,
htext
);
r
=
CloseClipboard
();
ok
(
r
,
"gle %d
\n
"
,
GetLastError
()
);
}
static
DWORD
WINAPI
test_handles_thread
(
void
*
arg
)
{
trace
(
"running from different thread
\n
"
);
test_handles
(
(
HWND
)
arg
);
return
0
;
}
static
void
test_data_handles
(
void
)
{
HWND
hwnd
=
CreateWindowA
(
"static"
,
NULL
,
WS_POPUP
,
0
,
0
,
10
,
10
,
0
,
0
,
0
,
NULL
);
format_id
=
RegisterClipboardFormatA
(
"my_cool_clipboard_format"
);
ok
(
hwnd
!=
0
,
"window creation failed
\n
"
);
test_handles
(
0
);
test_handles
(
GetDesktopWindow
()
);
test_handles
(
hwnd
);
run_thread
(
test_handles_thread
,
hwnd
,
__LINE__
);
DestroyWindow
(
hwnd
);
}
START_TEST
(
clipboard
)
START_TEST
(
clipboard
)
{
{
HMODULE
mod
=
GetModuleHandleA
(
"user32"
);
HMODULE
mod
=
GetModuleHandleA
(
"user32"
);
...
@@ -693,4 +819,5 @@ START_TEST(clipboard)
...
@@ -693,4 +819,5 @@ START_TEST(clipboard)
test_ClipboardOwner
();
test_ClipboardOwner
();
test_synthesized
();
test_synthesized
();
test_messages
();
test_messages
();
test_data_handles
();
}
}
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