From: Vincent Povirk Subject: [2/5] user32: Add test calling EndMenu from WM_ENTERMENULOOP. Message-Id: Date: Wed, 16 Apr 2014 14:06:31 -0500 From 7babc4019526d1faa8a1e91aacc6a1a622654401 Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Wed, 16 Apr 2014 12:23:01 -0500 Subject: [PATCH 02/11] user32: Add test calling EndMenu from WM_ENTERMENULOOP. --- dlls/user32/tests/msg.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c index 684347d..d7ff868 100644 --- a/dlls/user32/tests/msg.c +++ b/dlls/user32/tests/msg.c @@ -1762,6 +1762,22 @@ static const struct message WmTrackPopupMenuEmpty[] = { { 0 } }; +static const struct message WmTrackPopupMenuAbort[] = { + { HCBT_CREATEWND, hook }, + { WM_ENTERMENULOOP, sent|wparam|lparam, TRUE, 0 }, + { WM_INITMENU, sent|lparam, 0, 0 }, + { WM_INITMENUPOPUP, sent|lparam, 0, 0 }, + { 0x0093, sent|optional }, + { 0x0094, sent|optional }, + { 0x0094, sent|optional }, + { WM_CAPTURECHANGED, sent }, + { HCBT_DESTROYWND, hook }, + { WM_UNINITMENUPOPUP, sent|lparam, 0, 0 }, + { WM_MENUSELECT, sent|wparam|lparam, 0xffff0000, 0 }, + { WM_EXITMENULOOP, sent|wparam|lparam, 1, 0 }, + { 0 } +}; + static BOOL after_end_dialog, test_def_id, paint_loop_done; static int sequence_cnt, sequence_size; static struct recvd_message* sequence; @@ -14395,6 +14411,47 @@ static void test_TrackPopupMenuEmpty(void) DestroyWindow(hwnd); } +static LRESULT WINAPI cancel_init_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + if (ignore_message( message )) return 0; + + switch (message) { + case WM_ENTERMENULOOP: + ok(EndMenu() == TRUE, "EndMenu() failed\n"); + break; + } + + return MsgCheckProc (FALSE, hwnd, message, wParam, lParam); +} + +static void test_TrackPopupMenuAbort(void) +{ + HWND hwnd; + BOOL ret; + + hwnd = CreateWindowExA(0, "TestWindowClass", NULL, 0, + 0, 0, 1, 1, 0, + NULL, NULL, 0); + ok(hwnd != NULL, "CreateWindowEx failed with error %d\n", GetLastError()); + + SetWindowLongPtrA( hwnd, GWLP_WNDPROC, (LONG_PTR)cancel_init_proc); + + hpopupmenu = CreatePopupMenu(); + ok(hpopupmenu != NULL, "CreateMenu failed with error %d\n", GetLastError()); + + AppendMenuA(hpopupmenu, MF_STRING, 100, "item 1"); + AppendMenuA(hpopupmenu, MF_STRING, 100, "item 2"); + + flush_events(); + flush_sequence(); + ret = TrackPopupMenu(hpopupmenu, 0, 100,100, 0, hwnd, NULL); + ok_sequence(WmTrackPopupMenuAbort, "WmTrackPopupMenuAbort", TRUE); + ok(ret == TRUE, "TrackPopupMenu failed\n"); + + DestroyMenu(hpopupmenu); + DestroyWindow(hwnd); +} + static void init_funcs(void) { HMODULE hKernel32 = GetModuleHandleA("kernel32.dll"); @@ -14525,6 +14582,7 @@ START_TEST(msg) test_layered_window(); test_TrackPopupMenu(); test_TrackPopupMenuEmpty(); + test_TrackPopupMenuAbort(); /* keep it the last test, under Windows it tends to break the tests * which rely on active/foreground windows being correct. */ -- 1.8.3.2