ReactOS 0.4.15-dev-8222-g9164419
SystemMenu.c File Reference
#include "precomp.h"
Include dependency graph for SystemMenu.c:

Go to the source code of this file.

Classes

struct  message
 
struct  recvd_message
 

Macros

#define WND_PARENT_ID   1
 
#define WND_POPUP_ID   2
 
#define GET_PROC(dll, func)
 
#define add_message(msg)   add_message_(__LINE__, msg);
 
#define ok_sequence(exp, contx, todo)    ok_sequence_((exp), (contx), (todo), __FILE__, __LINE__)
 
#define expect(EXPECTED, GOT)   ok((GOT)==(EXPECTED), "Expected %d, got %d\n", (EXPECTED), (GOT))
 
#define X(f)   p##f = (void*)GetProcAddress(hKernel32, #f)
 

Enumerations

enum  msg_flags_t {
  sent = 0x1 , posted = 0x2 , parent = 0x4 , wparam = 0x8 ,
  lparam = 0x10 , defwinproc = 0x20 , beginpaint = 0x40 , optional = 0x80 ,
  hook = 0x100 , winevent_hook = 0x200 , kbd_hook = 0x400 , sent = 0x1 ,
  posted = 0x2 , parent = 0x4 , wparam = 0x8 , lparam = 0x10 ,
  defwinproc = 0x20 , beginpaint = 0x40 , optional = 0x80 , hook = 0x100 ,
  winevent_hook =0x200 , id = 0x400 , custdraw = 0x800 , sent = 0x1 ,
  posted = 0x2 , parent = 0x4 , wparam = 0x8 , lparam = 0x10 ,
  defwinproc = 0x20 , beginpaint = 0x40 , optional = 0x80 , hook = 0x100 ,
  winevent_hook =0x200 , id = 0x400 , sent =0x1 , posted =0x2 ,
  parent =0x4 , wparam =0x8 , lparam =0x10 , defwinproc =0x20 ,
  beginpaint =0x40 , optional =0x80 , hook =0x100 , winevent_hook =0x200 ,
  sent =0x1 , posted =0x2 , parent =0x4 , wparam =0x8 ,
  lparam =0x10 , defwinproc =0x20 , beginpaint =0x40 , optional =0x80 ,
  hook =0x100 , winevent_hook =0x200 , kbd_hook =0x400
}
 

Functions

static BOOL (WINAPI *pGetCurrentActCtx)(HANDLE *)
 
static HWND (WINAPI *pGetAncestor)(HWND
 
static void init_procs (void)
 
static BOOL ignore_message (UINT message)
 
static void add_message_ (int line, const struct recvd_message *msg)
 
static void flush_events (void)
 
static void flush_sequence (void)
 
static void dump_sequence (const struct message *expected, const char *context, const char *file, int line)
 
static void ok_sequence_ (const struct message *expected_list, const char *context, BOOL todo, const char *file, int line)
 
static LRESULT MsgCheckProc (BOOL unicode, HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
 
static LRESULT WINAPI MsgCheckProcA (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
 
static BOOL RegisterWindowClasses (void)
 
static BOOL is_our_logged_class (HWND hwnd)
 
static LRESULT CALLBACK cbt_hook_proc (int nCode, WPARAM wParam, LPARAM lParam)
 
static LRESULT WINAPI parent_menu_proc (HWND hwnd, UINT message, WPARAM wp, LPARAM lp)
 
static void test_menu_messages (void)
 
static void init_funcs (void)
 
static void init_tests ()
 
static void cleanup_tests ()
 
 START_TEST (SystemMenu)
 

Variables

static HANDLE
 
static void ULONG
 
static void void SIZE_T
 
static void void SIZE_T *static BOOL test_DestroyWindow_flag
 
static HWINEVENTHOOK hEvent_hook
 
static HHOOK hKBD_hook
 
static HHOOK hCBT_hook
 
static DWORD cbt_hook_thread_id
 
static int sequence_cnt
 
static int sequence_size
 
static struct recvd_messagesequence
 
static CRITICAL_SECTION sequence_cs
 
static UINT
 
static const struct message wm_popup_menu_4 []
 

Macro Definition Documentation

◆ add_message

#define add_message (   msg)    add_message_(__LINE__, msg);

Definition at line 98 of file SystemMenu.c.

◆ expect

#define expect (   EXPECTED,
  GOT 
)    ok((GOT)==(EXPECTED), "Expected %d, got %d\n", (EXPECTED), (GOT))

Definition at line 483 of file SystemMenu.c.

◆ GET_PROC

#define GET_PROC (   dll,
  func 
)
Value:
p ## func = (void*)GetProcAddress(dll, #func); \
if (!p ## func) { \
trace("GetProcAddress(%s) failed\n", #func); \
}
#define GetProcAddress(x, y)
Definition: compat.h:753
GLenum func
Definition: glext.h:6028
GLfloat GLfloat p
Definition: glext.h:8902
static HMODULE dll
Definition: str.c:188

◆ ok_sequence

#define ok_sequence (   exp,
  contx,
  todo 
)     ok_sequence_((exp), (contx), (todo), __FILE__, __LINE__)

Definition at line 275 of file SystemMenu.c.

◆ WND_PARENT_ID

#define WND_PARENT_ID   1

Definition at line 13 of file SystemMenu.c.

◆ WND_POPUP_ID

#define WND_POPUP_ID   2

Definition at line 14 of file SystemMenu.c.

◆ X

#define X (   f)    p##f = (void*)GetProcAddress(hKernel32, #f)

Enumeration Type Documentation

◆ msg_flags_t

Enumerator
sent 
posted 
parent 
wparam 
lparam 
defwinproc 
beginpaint 
optional 
hook 
winevent_hook 
kbd_hook 
sent 
posted 
parent 
wparam 
lparam 
defwinproc 
beginpaint 
optional 
hook 
winevent_hook 
id 
custdraw 
sent 
posted 
parent 
wparam 
lparam 
defwinproc 
beginpaint 
optional 
hook 
winevent_hook 
id 
sent 
posted 
parent 
wparam 
lparam 
defwinproc 
beginpaint 
optional 
hook 
winevent_hook 
sent 
posted 
parent 
wparam 
lparam 
defwinproc 
beginpaint 
optional 
hook 
winevent_hook 
kbd_hook 

Definition at line 25 of file SystemMenu.c.

26{
27 sent = 0x1,
28 posted = 0x2,
29 parent = 0x4,
30 wparam = 0x8,
31 lparam = 0x10,
32 defwinproc = 0x20,
33 beginpaint = 0x40,
34 optional = 0x80,
35 hook = 0x100,
36 winevent_hook = 0x200,
37 kbd_hook = 0x400
msg_flags_t
Definition: SystemMenu.c:26
@ sent
Definition: SystemMenu.c:27
@ beginpaint
Definition: SystemMenu.c:33
@ defwinproc
Definition: SystemMenu.c:32
@ kbd_hook
Definition: SystemMenu.c:37
@ parent
Definition: SystemMenu.c:29
@ posted
Definition: SystemMenu.c:28
@ lparam
Definition: SystemMenu.c:31
@ hook
Definition: SystemMenu.c:35
@ winevent_hook
Definition: SystemMenu.c:36
@ wparam
Definition: SystemMenu.c:30
@ optional
Definition: SystemMenu.c:34

Function Documentation

◆ add_message_()

static void add_message_ ( int  line,
const struct recvd_message msg 
)
static

Definition at line 99 of file SystemMenu.c.

100{
101 struct recvd_message *seq;
102
104 if (!sequence)
105 {
106 sequence_size = 10;
108 }
110 {
111 sequence_size *= 2;
113 }
115
116 seq = &sequence[sequence_cnt++];
117 seq->hwnd = msg->hwnd;
118 seq->message = msg->message;
119 seq->flags = msg->flags;
120 seq->wParam = msg->wParam;
121 seq->lParam = msg->lParam;
122 seq->line = line;
123 seq->descr = msg->descr;
124 seq->output[0] = 0;
126
127 if (msg->descr)
128 {
129 if (msg->flags & hook)
130 {
131 static const char * const CBT_code_name[10] =
132 {
133 "HCBT_MOVESIZE",
134 "HCBT_MINMAX",
135 "HCBT_QS",
136 "HCBT_CREATEWND",
137 "HCBT_DESTROYWND",
138 "HCBT_ACTIVATE",
139 "HCBT_CLICKSKIPPED",
140 "HCBT_KEYSKIPPED",
141 "HCBT_SYSCOMMAND",
142 "HCBT_SETFOCUS"
143 };
144 const char *code_name = (msg->message <= HCBT_SETFOCUS ? CBT_code_name[msg->message] : "Unknown");
145
146 sprintf(seq->output, "%s: hook %d (%s) wp %08Ix lp %08Ix",
147 msg->descr, msg->message, code_name, msg->wParam, msg->lParam);
148 }
149 else if (msg->flags & winevent_hook)
150 {
151 sprintf(seq->output, "%s: winevent %p %08x %08Ix %08Ix",
152 msg->descr, msg->hwnd, msg->message, msg->wParam, msg->lParam);
153 }
154 else
155 {
156 if (msg->message >= 0xc000)
157 return; /* ignore registered messages */
158 sprintf(seq->output, "%s: %p %04x wp %08Ix lp %08Ix",
159 msg->descr, msg->hwnd, msg->message, msg->wParam, msg->lParam);
160 if (msg->flags & (sent | posted | parent | defwinproc | beginpaint))
161 sprintf(seq->output + strlen(seq->output), " (flags %x)", msg->flags);
162 }
163 }
164}
static CRITICAL_SECTION sequence_cs
Definition: SystemMenu.c:64
static int sequence_size
Definition: SystemMenu.c:62
static struct recvd_message * sequence
Definition: SystemMenu.c:63
static int sequence_cnt
Definition: SystemMenu.c:62
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define msg(x)
Definition: auth_time.c:54
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapReAlloc
Definition: compat.h:734
#define assert(x)
Definition: debug.h:53
#define sprintf(buf, format,...)
Definition: sprintf.c:55
WPARAM wParam
Definition: SystemMenu.c:55
const char * descr
Definition: SystemMenu.c:58
char output[512]
Definition: SystemMenu.c:59
msg_flags_t flags
Definition: SystemMenu.c:53
LPARAM lParam
Definition: SystemMenu.c:56
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define HCBT_SETFOCUS
Definition: winuser.h:64

◆ BOOL()

static BOOL ( WINAPI pGetCurrentActCtx)
static

◆ cbt_hook_proc()

static LRESULT CALLBACK cbt_hook_proc ( int  nCode,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 567 of file SystemMenu.c.

568{
569 HWND hwnd;
570
571 ok(cbt_hook_thread_id == GetCurrentThreadId(), "we didn't ask for events from other threads\n");
572
573 if (nCode == HCBT_CLICKSKIPPED)
574 {
575 /* ignore this event, XP sends it a lot when switching focus between windows */
576 return CallNextHookEx(hCBT_hook, nCode, wParam, lParam);
577 }
578
579 if (nCode == HCBT_SYSCOMMAND || nCode == HCBT_KEYSKIPPED)
580 {
581 struct recvd_message msg;
582
583 msg.hwnd = 0;
584 msg.message = nCode;
585 msg.flags = hook | wparam | lparam;
586 msg.wParam = wParam;
587 msg.lParam = lParam;
588 msg.descr = "CBT";
590
591 return CallNextHookEx(hCBT_hook, nCode, wParam, lParam);
592 }
593
594 if (nCode == HCBT_DESTROYWND)
595 {
597 {
599 if (style & WS_CHILD)
601 else if (style & WS_POPUP)
603 else
605 }
606 }
607
608 /* Log also SetFocus(0) calls */
610
612 {
613 struct recvd_message msg;
614
615 msg.hwnd = hwnd;
616 msg.message = nCode;
617 msg.flags = hook | wparam | lparam;
618 msg.wParam = wParam;
619 msg.lParam = lParam;
620 msg.descr = "CBT";
622 }
623 return CallNextHookEx(hCBT_hook, nCode, wParam, lParam);
624}
#define add_message(msg)
Definition: SystemMenu.c:98
#define WND_PARENT_ID
Definition: SystemMenu.c:13
static HHOOK hCBT_hook
Definition: SystemMenu.c:22
#define WND_POPUP_ID
Definition: SystemMenu.c:14
static DWORD cbt_hook_thread_id
Definition: SystemMenu.c:23
static BOOL is_our_logged_class(HWND hwnd)
Definition: SystemMenu.c:538
static void void SIZE_T *static BOOL test_DestroyWindow_flag
Definition: SystemMenu.c:19
Arabic default style
Definition: afstyles.h:94
#define ok(value,...)
Definition: atltest.h:57
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
HANDLE HWND
Definition: compat.h:19
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WS_CHILD
Definition: pedump.c:617
#define WS_POPUP
Definition: pedump.c:616
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:459
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG WINAPI GetWindowLongA(_In_ HWND, _In_ int)
#define HCBT_DESTROYWND
Definition: winuser.h:59
#define GetWindowLongPtrA
Definition: winuser.h:4828
#define HCBT_CLICKSKIPPED
Definition: winuser.h:61
LRESULT WINAPI CallNextHookEx(_In_opt_ HHOOK, _In_ int, _In_ WPARAM, _In_ LPARAM)
#define GWLP_ID
Definition: winuser.h:860
#define GWL_STYLE
Definition: winuser.h:852
#define HCBT_SYSCOMMAND
Definition: winuser.h:63
#define HCBT_KEYSKIPPED
Definition: winuser.h:62

Referenced by init_tests().

◆ cleanup_tests()

static void cleanup_tests ( )
static

Definition at line 755 of file SystemMenu.c.

756{
757 BOOL ret;
759 if (pUnhookWinEvent && hEvent_hook)
760 {
761 ret = pUnhookWinEvent(hEvent_hook);
762 ok(ret, "UnhookWinEvent error %ld\n", GetLastError());
763 SetLastError(0xdeadbeef);
764 ok(!pUnhookWinEvent(hEvent_hook), "UnhookWinEvent succeeded\n");
765 ok(GetLastError() == ERROR_INVALID_HANDLE || /* Win2k */
766 GetLastError() == 0xdeadbeef, /* Win9x */
767 "unexpected error %ld\n", GetLastError());
768 }
770}
static HWINEVENTHOOK hEvent_hook
Definition: SystemMenu.c:20
#define SetLastError(x)
Definition: compat.h:752
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
unsigned int BOOL
Definition: ntddk_ex.h:94
int ret
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
BOOL WINAPI UnhookWindowsHookEx(_In_ HHOOK)

Referenced by START_TEST().

◆ dump_sequence()

static void dump_sequence ( const struct message expected,
const char context,
const char file,
int  line 
)
static

Definition at line 193 of file SystemMenu.c.

194{
195 const struct recvd_message *actual = sequence;
196 unsigned int count = 0;
197
198 trace_(file, line)("Failed sequence %s:\n", context);
199
200 while (expected->message && actual->message)
201 {
202 if (actual->output[0])
203 {
204 if (expected->flags & hook)
205 {
206 trace_(file, line)(" %u: expected: hook %04x - actual: %s\n",
207 count, expected->message, actual->output);
208 }
209 else if (expected->flags & winevent_hook)
210 {
211 trace_(file, line)(" %u: expected: winevent %04x - actual: %s\n",
212 count, expected->message, actual->output);
213 }
214 else if (expected->flags & kbd_hook)
215 {
216 trace_(file, line)(" %u: expected: kbd %04x - actual: %s\n",
217 count, expected->message, actual->output);
218 }
219 else
220 {
221 trace_(file, line)(" %u: expected: msg %04x - actual: %s\n",
222 count, expected->message, actual->output);
223 }
224 }
225
226 if (expected->message == actual->message)
227 {
228 if ((expected->flags & defwinproc) != (actual->flags & defwinproc) &&
229 (expected->flags & optional))
230 {
231 /* don't match messages if their defwinproc status differs */
232 expected++;
233 }
234 else
235 {
236 expected++;
237 actual++;
238 }
239 }
240 /* silently drop winevent messages if there is no support for them */
241 else if ((expected->flags & optional) || ((expected->flags & winevent_hook) && !hEvent_hook))
242 expected++;
243 else
244 {
245 expected++;
246 actual++;
247 }
248
249 count++;
250 }
251
252 /* optional trailing messages */
253 while (expected->message && ((expected->flags & optional) ||
254 ((expected->flags & winevent_hook) && !hEvent_hook)))
255 {
256 trace_(file, line)(" %u: expected: msg %04x - actual: nothing\n", count, expected->message);
257 expected++;
258 count++;
259 }
260
261 if (expected->message)
262 {
263 trace_(file, line)(" %u: expected: msg %04x - actual: nothing\n", count, expected->message);
264 return;
265 }
266
267 while (actual->message && actual->output[0])
268 {
269 trace_(file, line)(" %u: expected: nothing - actual: %s\n", count, actual->output);
270 actual++;
271 count++;
272 }
273}
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define trace_(file, line,...)
Definition: kmt_test.h:223
BOOL expected
Definition: store.c:2063
Definition: http.c:7252
Definition: fci.c:127
Definition: parser.c:49

Referenced by ok_sequence_().

◆ flush_events()

static void flush_events ( void  )
static

Definition at line 167 of file SystemMenu.c.

168{
169 MSG msg;
170 int diff = 200;
171 int min_timeout = 100;
172 DWORD time = GetTickCount() + diff;
173
174 while (diff > 0)
175 {
176 if (MsgWaitForMultipleObjects( 0, NULL, FALSE, min_timeout, QS_ALLINPUT ) == WAIT_TIMEOUT)
177 break;
178 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
180 diff = time - GetTickCount();
181 }
182}
#define WAIT_TIMEOUT
Definition: dderror.h:14
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
__u16 time
Definition: mkdosfs.c:8
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
LRESULT WINAPI DispatchMessageA(_In_ const MSG *)
#define QS_ALLINPUT
Definition: winuser.h:903
DWORD WINAPI MsgWaitForMultipleObjects(_In_ DWORD nCount, _In_reads_opt_(nCount) CONST HANDLE *pHandles, _In_ BOOL fWaitAll, _In_ DWORD dwMilliseconds, _In_ DWORD dwWakeMask)
#define PM_REMOVE
Definition: winuser.h:1196
BOOL WINAPI PeekMessageA(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)

Referenced by check_dialog_style(), check_window_style(), main_window_procA(), ok_event_sequence(), run_NCRedrawLoop(), test_csparentdc(), test_customdraw(), test_events(), test_GetMessagePos(), test_GetUpdateRect(), test_keyboard_input(), test_menu_messages(), test_mouse_input(), test_scrolldc(), test_scrollwindow(), test_SetActiveWindow(), test_SetForegroundWindow(), test_setinfo(), test_SetWindowPos(), test_track(), test_TTN_SHOW(), test_window_from_point(), test_window_without_child_style(), and window_from_point_proc().

◆ flush_sequence()

static void flush_sequence ( void  )
static

Definition at line 184 of file SystemMenu.c.

185{
188 sequence = 0;
191}
#define HeapFree(x, y, z)
Definition: compat.h:735

Referenced by flush_sequences(), ok_sequence_(), run_test(), and test_menu_messages().

◆ HWND()

static HWND ( WINAPI pGetAncestor)
static

◆ ignore_message()

static BOOL ignore_message ( UINT  message)
static

Definition at line 86 of file SystemMenu.c.

87{
88 /* these are always ignored */
89 return (message >= 0xc000 ||
90 message == WM_GETICON ||
91 message == WM_GETOBJECT ||
93 message == WM_DISPLAYCHANGE ||
96}
Definition: tftpd.h:60
#define WM_DWMNCRENDERINGCHANGED
Definition: winuser.h:1885
#define WM_DEVICECHANGE
Definition: winuser.h:1811
#define WM_TIMECHANGE
Definition: winuser.h:1634

Referenced by MsgCheckProc().

◆ init_funcs()

static void init_funcs ( void  )
static

Definition at line 729 of file SystemMenu.c.

730{
731 HMODULE hKernel32 = GetModuleHandleA("kernel32.dll");
732
733#define X(f) p##f = (void*)GetProcAddress(hKernel32, #f)
736#undef X
737}
#define X(f)
BOOL WINAPI QueryActCtxW(IN DWORD dwFlags, IN HANDLE hActCtx, IN PVOID pvSubInstance, IN ULONG ulInfoClass, IN PVOID pvBuffer, IN SIZE_T cbBuffer, IN OUT SIZE_T *pcbWrittenOrRequired OPTIONAL)
Definition: actctx.c:328
BOOL WINAPI GetCurrentActCtx(OUT PHANDLE phActCtx)
Definition: actctx.c:298
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
HANDLE hKernel32
Definition: locale.c:13

Referenced by init_tests().

◆ init_procs()

static void init_procs ( void  )
static

Definition at line 70 of file SystemMenu.c.

71{
72 HMODULE user32 = GetModuleHandleA("user32.dll");
73
74#define GET_PROC(dll, func) \
75 p ## func = (void*)GetProcAddress(dll, #func); \
76 if (!p ## func) { \
77 trace("GetProcAddress(%s) failed\n", #func); \
78 }
79
80 GET_PROC(user32, GetAncestor)
82
83#undef GET_PROC
84}
#define GET_PROC(dll, func)
BOOL WINAPI UnhookWinEvent(HWINEVENTHOOK)
HWND WINAPI GetAncestor(_In_ HWND, _In_ UINT)

Referenced by init_tests().

◆ init_tests()

static void init_tests ( void  )
static

Definition at line 739 of file SystemMenu.c.

740{
741 init_funcs();
742
744 init_procs();
745
747 assert(0);
748
751 if (!hCBT_hook)
752 win_skip("cannot set global hook, will skip hook tests\n");
753}
static void init_procs(void)
Definition: SystemMenu.c:70
static LRESULT CALLBACK cbt_hook_proc(int nCode, WPARAM wParam, LPARAM lParam)
Definition: SystemMenu.c:567
static void init_funcs(void)
Definition: SystemMenu.c:729
static BOOL RegisterWindowClasses(void)
Definition: SystemMenu.c:519
#define win_skip
Definition: test.h:163
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
#define WH_CBT
Definition: winuser.h:35
HHOOK WINAPI SetWindowsHookExA(_In_ int, _In_ HOOKPROC, _In_opt_ HINSTANCE, _In_ DWORD)

Referenced by START_TEST().

◆ is_our_logged_class()

static BOOL is_our_logged_class ( HWND  hwnd)
static

Definition at line 538 of file SystemMenu.c.

539{
540 char buf[256];
541
542 if (GetClassNameA(hwnd, buf, sizeof(buf)))
543 {
544 if (!lstrcmpiA(buf, "TestWindowClass") ||
545 !lstrcmpiA(buf, "ShowWindowClass") ||
546 !lstrcmpiA(buf, "RecursiveActivationClass") ||
547 !lstrcmpiA(buf, "TestParentClass") ||
548 !lstrcmpiA(buf, "TestPopupClass") ||
549 !lstrcmpiA(buf, "SimpleWindowClass") ||
550 !lstrcmpiA(buf, "TestDialogClass") ||
551 !lstrcmpiA(buf, "MDI_frame_class") ||
552 !lstrcmpiA(buf, "MDI_client_class") ||
553 !lstrcmpiA(buf, "MDI_child_class") ||
554 !lstrcmpiA(buf, "my_button_class") ||
555 !lstrcmpiA(buf, "my_edit_class") ||
556 !lstrcmpiA(buf, "static") ||
557 !lstrcmpiA(buf, "ListBox") ||
558 !lstrcmpiA(buf, "ComboBox") ||
559 !lstrcmpiA(buf, "MyDialogClass") ||
560 !lstrcmpiA(buf, "#32770") ||
561 !lstrcmpiA(buf, "#32768"))
562 return TRUE;
563 }
564 return FALSE;
565}
#define TRUE
Definition: types.h:120
int WINAPI lstrcmpiA(LPCSTR str1, LPCSTR str2)
Definition: locale.c:4223
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
int WINAPI GetClassNameA(_In_ HWND hWnd, _Out_writes_to_(nMaxCount, return) LPSTR lpClassName, _In_ int nMaxCount)

Referenced by cbt_hook_proc().

◆ MsgCheckProc()

static LRESULT MsgCheckProc ( BOOL  unicode,
HWND  hwnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 487 of file SystemMenu.c.

488{
489 static LONG defwndproc_counter = 0;
490 static LONG beginpaint_counter = 0;
491 LRESULT ret;
492 struct recvd_message msg;
493
494 if (ignore_message(message)) return 0;
495
496 msg.hwnd = hwnd;
497 msg.message = message;
498 msg.flags = sent | wparam | lparam;
499 if (defwndproc_counter) msg.flags |= defwinproc;
500 if (beginpaint_counter) msg.flags |= beginpaint;
501 msg.wParam = wParam;
502 msg.lParam = lParam;
503 msg.descr = "MsgCheckProc";
505
506 defwndproc_counter++;
507 ret = unicode ? DefWindowProcW(hwnd, message, wParam, lParam)
509 defwndproc_counter--;
510
511 return ret;
512}
static BOOL ignore_message(UINT message)
Definition: SystemMenu.c:86
long LONG
Definition: pedump.c:60
LONG_PTR LRESULT
Definition: windef.h:209
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by MsgCheckProcA().

◆ MsgCheckProcA()

static LRESULT WINAPI MsgCheckProcA ( HWND  hwnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 514 of file SystemMenu.c.

515{
517}
static LRESULT MsgCheckProc(BOOL unicode, HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: SystemMenu.c:487

Referenced by RegisterWindowClasses().

◆ ok_sequence_()

static void ok_sequence_ ( const struct message expected_list,
const char context,
BOOL  todo,
const char file,
int  line 
)
static

Definition at line 279 of file SystemMenu.c.

281{
282 static const struct recvd_message end_of_sequence;
283 const struct message *expected = expected_list;
284 const struct recvd_message *actual;
285 int failcount = 0, dump = 0;
286 unsigned int count = 0;
287
288 add_message(&end_of_sequence);
289
290 actual = sequence;
291
292 while (expected->message && actual->message)
293 {
294 if (expected->message == actual->message &&
295 !((expected->flags ^ actual->flags) & (hook | winevent_hook | kbd_hook)))
296 {
297 if (expected->flags & wparam)
298 {
299 if (((expected->wParam ^ actual->wParam) & ~expected->wp_mask) && todo)
300 {
302 {
303 failcount++;
304 if (strcmp(winetest_platform, "wine"))
305 dump++;
306 ok_( file, line) (FALSE,
307 "%s: %u: in msg 0x%04x expecting wParam 0x%x got 0x%x\n",
308 context, count, expected->message, expected->wParam, actual->wParam);
309 }
310 }
311 else
312 {
313 ok_( file, line)(((expected->wParam ^ actual->wParam) & ~expected->wp_mask) == 0,
314 "%s: %u: in msg 0x%04x expecting wParam 0x%x got 0x%x\n",
315 context, count, expected->message, expected->wParam, actual->wParam);
316 if ((expected->wParam ^ actual->wParam) & ~expected->wp_mask)
317 dump++;
318 }
319 }
320
321 if (expected->flags & lparam)
322 {
323 if (((expected->lParam ^ actual->lParam) & ~expected->lp_mask) && todo)
324 {
326 {
327 failcount++;
328 if (strcmp(winetest_platform, "wine"))
329 dump++;
330 ok_( file, line) (FALSE,
331 "%s: %u: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
332 context, count, expected->message, expected->lParam, actual->lParam);
333 }
334 }
335 else
336 {
337 ok_( file, line)(((expected->lParam ^ actual->lParam) & ~expected->lp_mask) == 0,
338 "%s: %u: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
339 context, count, expected->message, expected->lParam, actual->lParam);
340 if ((expected->lParam ^ actual->lParam) & ~expected->lp_mask)
341 dump++;
342 }
343 }
344 if ((expected->flags & optional) &&
345 ((expected->flags ^ actual->flags) & (defwinproc | parent)))
346 {
347 /* don't match optional messages if their defwinproc or parent status differs */
348 expected++;
349 count++;
350 continue;
351 }
352 if ((expected->flags & defwinproc) != (actual->flags & defwinproc) && todo)
353 {
355 {
356 failcount++;
357 if (strcmp(winetest_platform, "wine"))
358 dump++;
359 ok_(file, line) (FALSE,
360 "%s: %u: the msg 0x%04x should %shave been sent by DefWindowProc\n",
361 context, count, expected->message, (expected->flags & defwinproc) ? "" : "NOT ");
362 }
363 }
364 else
365 {
366 ok_(file, line) ((expected->flags & defwinproc) == (actual->flags & defwinproc),
367 "%s: %u: the msg 0x%04x should %shave been sent by DefWindowProc\n",
368 context, count, expected->message, (expected->flags & defwinproc) ? "" : "NOT ");
369 if ((expected->flags & defwinproc) != (actual->flags & defwinproc))
370 dump++;
371 }
372
373 ok_(file, line) ((expected->flags & beginpaint) == (actual->flags & beginpaint),
374 "%s: %u: the msg 0x%04x should %shave been sent by BeginPaint\n",
375 context, count, expected->message, (expected->flags & beginpaint) ? "" : "NOT ");
376 if ((expected->flags & beginpaint) != (actual->flags & beginpaint))
377 dump++;
378
379 ok_(file, line) ((expected->flags & (sent | posted)) == (actual->flags & (sent | posted)),
380 "%s: %u: the msg 0x%04x should have been %s\n",
381 context, count, expected->message, (expected->flags & posted) ? "posted" : "sent");
382 if ((expected->flags & (sent | posted)) != (actual->flags & (sent | posted)))
383 dump++;
384
385 ok_(file, line) ((expected->flags & parent) == (actual->flags & parent),
386 "%s: %u: the msg 0x%04x was expected in %s\n",
387 context, count, expected->message, (expected->flags & parent) ? "parent" : "child");
388 if ((expected->flags & parent) != (actual->flags & parent))
389 dump++;
390
391 ok_(file, line) ((expected->flags & hook) == (actual->flags & hook),
392 "%s: %u: the msg 0x%04x should have been sent by a hook\n",
393 context, count, expected->message);
394 if ((expected->flags & hook) != (actual->flags & hook))
395 dump++;
396
397 ok_(file, line) ((expected->flags & winevent_hook) == (actual->flags & winevent_hook),
398 "%s: %u: the msg 0x%04x should have been sent by a winevent hook\n",
399 context, count, expected->message);
400 if ((expected->flags & winevent_hook) != (actual->flags & winevent_hook))
401 dump++;
402
403 ok_(file, line) ((expected->flags & kbd_hook) == (actual->flags & kbd_hook),
404 "%s: %u: the msg 0x%04x should have been sent by a keyboard hook\n",
405 context, count, expected->message);
406 if ((expected->flags & kbd_hook) != (actual->flags & kbd_hook))
407 dump++;
408
409 expected++;
410 actual++;
411 }
412 /* silently drop hook messages if there is no support for them */
413 else if ((expected->flags & optional) ||
414 ((expected->flags & hook) && !hCBT_hook) ||
415 ((expected->flags & winevent_hook) && !hEvent_hook) ||
416 ((expected->flags & kbd_hook) && !hKBD_hook))
417 expected++;
418 else if (todo)
419 {
420 failcount++;
422 {
423 if (strcmp(winetest_platform, "wine"))
424 dump++;
425 ok_(file, line) (FALSE, "%s: %u: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
426 context, count, expected->message, actual->message);
427 }
428 goto done;
429 }
430 else
431 {
432 ok_(file, line) (FALSE, "%s: %u: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
433 context, count, expected->message, actual->message);
434 dump++;
435 expected++;
436 actual++;
437 }
438 count++;
439 }
440
441 /* skip all optional trailing messages */
442 while (expected->message && ((expected->flags & optional) ||
443 ((expected->flags & hook) && !hCBT_hook) ||
444 ((expected->flags & winevent_hook) && !hEvent_hook)))
445 expected++;
446
447 if (todo)
448 {
450 {
451 if (expected->message || actual->message)
452 {
453 failcount++;
454 if (strcmp(winetest_platform, "wine"))
455 dump++;
456 ok_(file, line) (FALSE, "%s: %u: the msg sequence is not complete: expected %04x - actual %04x\n",
457 context, count, expected->message, actual->message);
458 }
459 }
460 }
461 else
462 {
463 if (expected->message || actual->message)
464 {
465 dump++;
466 ok_(file, line) (FALSE, "%s: %u: the msg sequence is not complete: expected %04x - actual %04x\n",
467 context, count, expected->message, actual->message);
468 }
469 }
470 if (todo && !failcount) /* succeeded yet marked todo */
472 {
473 if (!strcmp(winetest_platform, "wine"))
474 dump++;
475 ok_(file, line) (TRUE, "%s: marked \"todo_wine\" but succeeds\n", context);
476 }
477
478done:
479 if (dump) dump_sequence(expected_list, context, file, line);
481}
static HHOOK hKBD_hook
Definition: SystemMenu.c:21
static void flush_sequence(void)
Definition: SystemMenu.c:184
static void dump_sequence(const struct message *expected, const char *context, const char *file, int line)
Definition: SystemMenu.c:193
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define ok_(x1, x2)
Definition: atltest.h:61
BOOL todo
Definition: filedlg.c:313
#define todo_wine
Definition: custom.c:79
static void dump(const void *ptr, unsigned len)
Definition: msc.c:95
const char * winetest_platform

Referenced by run_test_().

◆ parent_menu_proc()

static LRESULT WINAPI parent_menu_proc ( HWND  hwnd,
UINT  message,
WPARAM  wp,
LPARAM  lp 
)
static

Definition at line 647 of file SystemMenu.c.

648{
649 if (message == WM_ENTERIDLE ||
650 message == WM_INITMENU ||
656 message == WM_UNINITMENUPOPUP ||
657 message == WM_KEYDOWN ||
658 message == WM_KEYUP ||
659 message == WM_CHAR ||
661 message == WM_SYSKEYUP ||
662 message == WM_SYSCHAR ||
663 message == WM_COMMAND ||
664 message == WM_MENUCOMMAND)
665 {
666 struct recvd_message msg;
667
668 msg.hwnd = hwnd;
669 msg.message = message;
670 msg.flags = sent | wparam | lparam;
671 msg.wParam = wp;
672 msg.lParam = lp;
673 msg.descr = "parent_menu_proc";
675 }
676
677 return DefWindowProcA(hwnd, message, wp, lp);
678}
#define WM_KEYUP
Definition: winuser.h:1716
#define WM_COMMAND
Definition: winuser.h:1740
#define WM_INITMENU
Definition: winuser.h:1745
#define WM_SYSCHAR
Definition: winuser.h:1721
#define WM_ENTERMENULOOP
Definition: winuser.h:1804
#define WM_INITMENUPOPUP
Definition: winuser.h:1746
#define WM_SYSKEYUP
Definition: winuser.h:1720
#define WM_EXITMENULOOP
Definition: winuser.h:1805
#define WM_CHAR
Definition: winuser.h:1717
#define WM_KEYDOWN
Definition: winuser.h:1715
#define WM_PARENTNOTIFY
Definition: winuser.h:1803
#define WM_MENUSELECT
Definition: winuser.h:1747
#define WM_ENTERIDLE
Definition: winuser.h:1749
#define WM_SYSKEYDOWN
Definition: winuser.h:1719

Referenced by test_menu_messages().

◆ RegisterWindowClasses()

static BOOL RegisterWindowClasses ( void  )
static

Definition at line 519 of file SystemMenu.c.

520{
521 WNDCLASSA cls;
522
523 cls.style = 0;
525 cls.cbClsExtra = 0;
526 cls.cbWndExtra = 0;
528 cls.hIcon = 0;
531 cls.lpszMenuName = NULL;
532 cls.lpszClassName = "TestWindowClass";
533 if (!RegisterClassA(&cls)) return FALSE;
534
535 return TRUE;
536}
static LRESULT WINAPI MsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: SystemMenu.c:514
HBRUSH hbrBackground
Definition: winuser.h:3170
HICON hIcon
Definition: winuser.h:3168
HINSTANCE hInstance
Definition: winuser.h:3167
HCURSOR hCursor
Definition: winuser.h:3169
int cbWndExtra
Definition: winuser.h:3166
UINT style
Definition: winuser.h:3163
LPCSTR lpszMenuName
Definition: winuser.h:3171
LPCSTR lpszClassName
Definition: winuser.h:3172
WNDPROC lpfnWndProc
Definition: winuser.h:3164
int cbClsExtra
Definition: winuser.h:3165
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define WHITE_BRUSH
Definition: wingdi.h:902
#define IDC_ARROW
Definition: winuser.h:687
ATOM WINAPI RegisterClassA(_In_ CONST WNDCLASSA *)
HCURSOR WINAPI LoadCursorA(_In_opt_ HINSTANCE, _In_ LPCSTR)
Definition: cursoricon.c:2121
const char * LPCSTR
Definition: xmlstorage.h:183

Referenced by init_tests().

◆ START_TEST()

START_TEST ( SystemMenu  )

Definition at line 772 of file SystemMenu.c.

773{
774 init_tests();
777}
static void cleanup_tests()
Definition: SystemMenu.c:755
static void test_menu_messages(void)
Definition: SystemMenu.c:680
static void init_tests()
Definition: SystemMenu.c:739

◆ test_menu_messages()

static void test_menu_messages ( void  )
static

Definition at line 680 of file SystemMenu.c.

681{
682 MSG msg;
683 WNDCLASSA cls;
684 HWND hwnd;
685 RECT rect;
686
687 cls.style = 0;
689 cls.cbClsExtra = 0;
690 cls.cbWndExtra = 0;
692 cls.hIcon = 0;
695 cls.lpszMenuName = NULL;
696 cls.lpszClassName = "TestMenuClass";
698 if (!RegisterClassA(&cls))
699 assert(0);
700
701 SetLastError(0xdeadbeef);
702 hwnd = CreateWindowExA(0, "TestMenuClass", NULL, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
703 100, 100, 200, 200, 0, 0, 0, NULL);
704 ok(hwnd != 0, "LoadMenuA error %lu\n", GetLastError());
705
707 flush_events();
708
709 trace("testing system menu\n");
711 SetCursorPos(rect.left + 30, rect.top + 10);
714 mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0);
715 keybd_event(VK_DOWN, 0, 0, 0);
717 keybd_event(VK_ESCAPE, 0, 0, 0);
719 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
720 {
723 }
724 ok_sequence(wm_popup_menu_4, "system menu command", FALSE);
725
727}
#define ok_sequence(exp, contx, todo)
Definition: SystemMenu.c:275
static void flush_events(void)
Definition: SystemMenu.c:167
static const struct message wm_popup_menu_4[]
Definition: SystemMenu.c:628
static LRESULT WINAPI parent_menu_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp)
Definition: SystemMenu.c:647
#define trace
Definition: atltest.h:70
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define WS_VISIBLE
Definition: pedump.c:620
& rect
Definition: startmenu.cpp:1413
void WINAPI mouse_event(_In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ ULONG_PTR)
BOOL WINAPI TranslateMessage(_In_ const MSG *)
HWND WINAPI CreateWindowExA(_In_ DWORD dwExStyle, _In_opt_ LPCSTR lpClassName, _In_opt_ LPCSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
BOOL WINAPI UnregisterClassA(_In_ LPCSTR, HINSTANCE)
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI SetForegroundWindow(_In_ HWND)
#define MOUSEEVENTF_RIGHTUP
Definition: winuser.h:1187
BOOL WINAPI SetCursorPos(_In_ int, _In_ int)
Definition: cursoricon.c:2693
VOID WINAPI keybd_event(_In_ BYTE, _In_ BYTE, _In_ DWORD, _In_ ULONG_PTR)
#define VK_DOWN
Definition: winuser.h:2227
#define MOUSEEVENTF_RIGHTDOWN
Definition: winuser.h:1186
#define VK_ESCAPE
Definition: winuser.h:2214
BOOL WINAPI DestroyWindow(_In_ HWND)
#define KEYEVENTF_KEYUP
Definition: winuser.h:1102

Referenced by START_TEST().

Variable Documentation

◆ cbt_hook_thread_id

DWORD cbt_hook_thread_id
static

Definition at line 23 of file SystemMenu.c.

Referenced by cbt_hook_proc(), and init_tests().

◆ HANDLE

Definition at line 17 of file SystemMenu.c.

◆ hCBT_hook

HHOOK hCBT_hook
static

Definition at line 22 of file SystemMenu.c.

Referenced by cbt_hook_proc(), cleanup_tests(), init_tests(), and ok_sequence_().

◆ hEvent_hook

HWINEVENTHOOK hEvent_hook
static

Definition at line 20 of file SystemMenu.c.

Referenced by cleanup_tests(), dump_sequence(), and ok_sequence_().

◆ hKBD_hook

HHOOK hKBD_hook
static

Definition at line 21 of file SystemMenu.c.

Referenced by ok_sequence_().

◆ sequence

◆ sequence_cnt

int sequence_cnt
static

Definition at line 62 of file SystemMenu.c.

Referenced by add_message_(), and flush_sequence().

◆ sequence_cs

CRITICAL_SECTION sequence_cs
static

Definition at line 64 of file SystemMenu.c.

Referenced by add_message_(), cleanup_tests(), flush_sequence(), and init_tests().

◆ sequence_size

int sequence_size
static

Definition at line 62 of file SystemMenu.c.

Referenced by add_message_(), and flush_sequence().

◆ SIZE_T

Definition at line 17 of file SystemMenu.c.

◆ test_DestroyWindow_flag

void void SIZE_T* static BOOL test_DestroyWindow_flag
static

Definition at line 19 of file SystemMenu.c.

Referenced by cbt_hook_proc().

◆ UINT

Definition at line 67 of file SystemMenu.c.

◆ ULONG

Definition at line 17 of file SystemMenu.c.

◆ wm_popup_menu_4

const struct message wm_popup_menu_4[]
static
Initial value:
=
{
{ WM_INITMENU, sent | lparam, 0, 0 },
{ WM_INITMENUPOPUP, sent | lparam, 0, 0x10000 },
{ HCBT_KEYSKIPPED, hook | wparam | lparam | optional, VK_DOWN, 0x10000001 },
{ WM_MENUSELECT, sent, MAKEWPARAM(0,0xffff), 0 },
{ HCBT_KEYSKIPPED, hook | wparam | lparam | optional, VK_DOWN, 0xd0000001 },
{ WM_UNINITMENUPOPUP, sent | lparam, 0, 0x20000000 },
{ WM_MENUSELECT, sent, MAKEWPARAM(0,0xffff), 0 },
{ WM_KEYUP, sent | wparam | lparam, VK_ESCAPE, 0xc0000001 },
{ 0 }
}
#define MAKEWPARAM(l, h)
Definition: winuser.h:4009
#define HCBT_CREATEWND
Definition: winuser.h:58

Definition at line 628 of file SystemMenu.c.

Referenced by test_menu_messages().