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
abea10fa
Commit
abea10fa
authored
May 14, 2014
by
Vincent Povirk
Committed by
Alexandre Julliard
May 19, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
user32/tests: Add test for SendMessage race condition.
parent
d7f82725
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
165 additions
and
0 deletions
+165
-0
win.c
dlls/user32/tests/win.c
+165
-0
No files found.
dlls/user32/tests/win.c
View file @
abea10fa
...
...
@@ -7533,6 +7533,170 @@ static void test_window_without_child_style(void)
DestroyWindow
(
hwnd
);
}
struct
smresult_thread_data
{
HWND
main_hwnd
;
HWND
thread_hwnd
;
HANDLE
thread_started
;
HANDLE
thread_got_wm_app
;
HANDLE
main_in_wm_app_1
;
HANDLE
thread_replied
;
};
static
LRESULT
WINAPI
smresult_wndproc
(
HWND
hwnd
,
UINT
msg
,
WPARAM
wparam
,
LPARAM
lparam
)
{
switch
(
msg
)
{
case
WM_APP
:
{
struct
smresult_thread_data
*
data
=
(
struct
smresult_thread_data
*
)
lparam
;
ok
(
hwnd
==
data
->
thread_hwnd
,
"unexpected hwnd %p
\n
"
,
hwnd
);
SendNotifyMessageA
(
data
->
main_hwnd
,
WM_APP
+
1
,
0
,
lparam
);
/* Don't return until the main thread is processing our sent message. */
ok
(
WaitForSingleObject
(
data
->
main_in_wm_app_1
,
INFINITE
)
==
WAIT_OBJECT_0
,
"WaitForSingleObject failed
\n
"
);
/* Break the PeekMessage loop so we can notify the main thread after we return. */
SetEvent
(
data
->
thread_got_wm_app
);
return
0x240408ea
;
}
case
WM_APP
+
1
:
{
struct
smresult_thread_data
*
data
=
(
struct
smresult_thread_data
*
)
lparam
;
LRESULT
res
;
ok
(
hwnd
==
data
->
main_hwnd
,
"unexpected hwnd %p
\n
"
,
hwnd
);
/* Ask the thread to reply to our WM_APP message. */
SetEvent
(
data
->
main_in_wm_app_1
);
/* Wait until the thread has sent a reply. */
ok
(
WaitForSingleObject
(
data
->
thread_replied
,
INFINITE
)
==
WAIT_OBJECT_0
,
"WaitForSingleObject failed
\n
"
);
/* Send another message while we have a reply queued for the current one. */
res
=
SendMessageA
(
data
->
thread_hwnd
,
WM_APP
+
2
,
0
,
lparam
);
todo_wine
ok
(
res
==
0x449b0190
,
"unexpected result %lx
\n
"
,
res
);
return
0
;
}
case
WM_APP
+
2
:
{
struct
smresult_thread_data
*
data
=
(
struct
smresult_thread_data
*
)
lparam
;
ok
(
hwnd
==
data
->
thread_hwnd
,
"unexpected hwnd %p
\n
"
,
hwnd
);
/* Don't return until we know the main thread is processing sent messages. */
SendMessageA
(
data
->
main_hwnd
,
WM_NULL
,
0
,
0
);
return
0x449b0190
;
}
case
WM_CLOSE
:
PostQuitMessage
(
0
);
break
;
}
return
DefWindowProcA
(
hwnd
,
msg
,
wparam
,
lparam
);
}
static
DWORD
WINAPI
smresult_thread_proc
(
void
*
param
)
{
MSG
msg
;
struct
smresult_thread_data
*
data
=
param
;
data
->
thread_hwnd
=
CreateWindowExA
(
0
,
"SmresultClass"
,
"window caption text"
,
WS_OVERLAPPEDWINDOW
,
100
,
100
,
200
,
200
,
0
,
0
,
0
,
NULL
);
ok
(
data
->
thread_hwnd
!=
0
,
"Failed to create overlapped window
\n
"
);
SetEvent
(
data
->
thread_started
);
/* Loop until we've processed WM_APP. */
while
(
WaitForSingleObject
(
data
->
thread_got_wm_app
,
0
)
!=
WAIT_OBJECT_0
)
{
if
(
PeekMessageA
(
&
msg
,
0
,
0
,
0
,
PM_REMOVE
))
{
TranslateMessage
(
&
msg
);
DispatchMessageA
(
&
msg
);
}
else
{
MsgWaitForMultipleObjects
(
1
,
&
data
->
thread_got_wm_app
,
FALSE
,
INFINITE
,
QS_SENDMESSAGE
);
}
}
/* Notify the main thread that we replied to its WM_APP message. */
SetEvent
(
data
->
thread_replied
);
while
(
GetMessageA
(
&
msg
,
0
,
0
,
0
))
{
TranslateMessage
(
&
msg
);
DispatchMessageA
(
&
msg
);
}
return
0
;
}
static
void
test_smresult
(
void
)
{
WNDCLASSA
cls
;
HANDLE
hThread
;
DWORD
tid
;
struct
smresult_thread_data
data
;
BOOL
ret
;
LRESULT
res
;
cls
.
style
=
CS_DBLCLKS
;
cls
.
lpfnWndProc
=
smresult_wndproc
;
cls
.
cbClsExtra
=
0
;
cls
.
cbWndExtra
=
0
;
cls
.
hInstance
=
GetModuleHandleA
(
0
);
cls
.
hIcon
=
0
;
cls
.
hCursor
=
LoadCursorA
(
0
,
(
LPCSTR
)
IDC_ARROW
);
cls
.
hbrBackground
=
GetStockObject
(
WHITE_BRUSH
);
cls
.
lpszMenuName
=
NULL
;
cls
.
lpszClassName
=
"SmresultClass"
;
ret
=
RegisterClassA
(
&
cls
);
ok
(
ret
,
"RegisterClassA failed
\n
"
);
data
.
thread_started
=
CreateEventA
(
NULL
,
TRUE
,
FALSE
,
NULL
);
ok
(
data
.
thread_started
!=
NULL
,
"CreateEventA failed
\n
"
);
data
.
thread_got_wm_app
=
CreateEventA
(
NULL
,
TRUE
,
FALSE
,
NULL
);
ok
(
data
.
thread_got_wm_app
!=
NULL
,
"CreateEventA failed
\n
"
);
data
.
main_in_wm_app_1
=
CreateEventA
(
NULL
,
TRUE
,
FALSE
,
NULL
);
ok
(
data
.
main_in_wm_app_1
!=
NULL
,
"CreateEventA failed
\n
"
);
data
.
thread_replied
=
CreateEventA
(
NULL
,
TRUE
,
FALSE
,
NULL
);
ok
(
data
.
thread_replied
!=
NULL
,
"CreateEventA failed
\n
"
);
data
.
main_hwnd
=
CreateWindowExA
(
0
,
"SmresultClass"
,
"window caption text"
,
WS_OVERLAPPEDWINDOW
,
100
,
100
,
200
,
200
,
0
,
0
,
0
,
NULL
);
hThread
=
CreateThread
(
NULL
,
0
,
smresult_thread_proc
,
&
data
,
0
,
&
tid
);
ok
(
hThread
!=
NULL
,
"CreateThread failed, error %d
\n
"
,
GetLastError
());
ok
(
WaitForSingleObject
(
data
.
thread_started
,
INFINITE
)
==
WAIT_OBJECT_0
,
"WaitForSingleObject failed
\n
"
);
res
=
SendMessageA
(
data
.
thread_hwnd
,
WM_APP
,
0
,
(
LPARAM
)
&
data
);
ok
(
res
==
0x240408ea
,
"unexpected result %lx
\n
"
,
res
);
SendMessageA
(
data
.
thread_hwnd
,
WM_CLOSE
,
0
,
0
);
DestroyWindow
(
data
.
main_hwnd
);
ok
(
WaitForSingleObject
(
hThread
,
INFINITE
)
==
WAIT_OBJECT_0
,
"WaitForSingleObject failed
\n
"
);
CloseHandle
(
data
.
thread_started
);
CloseHandle
(
data
.
thread_got_wm_app
);
CloseHandle
(
data
.
main_in_wm_app_1
);
CloseHandle
(
data
.
thread_replied
);
}
START_TEST
(
win
)
{
HMODULE
user32
=
GetModuleHandleA
(
"user32.dll"
);
...
...
@@ -7664,6 +7828,7 @@ START_TEST(win)
test_map_points
();
test_update_region
();
test_window_without_child_style
();
test_smresult
();
/* add the tests above this line */
if
(
hhook
)
UnhookWindowsHookEx
(
hhook
);
...
...
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