Commit adf77c1a authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

user32/tests: Test more flags for MessageBox.

parent b4280a48
...@@ -2123,15 +2123,36 @@ static void test_timer_message(void) ...@@ -2123,15 +2123,36 @@ static void test_timer_message(void)
DialogBoxA(g_hinst, "RADIO_TEST_DIALOG", NULL, timer_message_dlg_proc); DialogBoxA(g_hinst, "RADIO_TEST_DIALOG", NULL, timer_message_dlg_proc);
} }
static unsigned int msgbox_hook_proc_called;
static UINT msgbox_type;
static LRESULT CALLBACK msgbox_hook_proc(INT code, WPARAM wParam, LPARAM lParam) static LRESULT CALLBACK msgbox_hook_proc(INT code, WPARAM wParam, LPARAM lParam)
{ {
static const LONG considered_ex_styles = WS_EX_CONTROLPARENT | WS_EX_WINDOWEDGE | WS_EX_DLGMODALFRAME | WS_EX_TOPMOST;
if (code == HCBT_ACTIVATE) if (code == HCBT_ACTIVATE)
{ {
HWND msgbox = (HWND)wParam, msghwnd; HWND msgbox = (HWND)wParam, msghwnd;
LONG exstyles, expected_exstyles;
BOOL system_modal;
char text[64]; char text[64];
if (msgbox) if (msgbox)
{ {
exstyles = GetWindowLongA(msgbox, GWL_EXSTYLE) & considered_ex_styles;
++msgbox_hook_proc_called;
system_modal = msgbox_type & MB_SYSTEMMODAL && !(msgbox_type & MB_TASKMODAL);
expected_exstyles = WS_EX_CONTROLPARENT | WS_EX_WINDOWEDGE;
if ((msgbox_type & MB_TOPMOST) || system_modal)
expected_exstyles |= WS_EX_TOPMOST;
if (!system_modal)
expected_exstyles |= WS_EX_DLGMODALFRAME;
todo_wine_if((system_modal && exstyles == (expected_exstyles | WS_EX_DLGMODALFRAME))
|| (!system_modal && msgbox_type & MB_TOPMOST))
ok(exstyles == expected_exstyles, "got %#lx, expected %#lx\n", exstyles, expected_exstyles);
text[0] = 0; text[0] = 0;
GetWindowTextA(msgbox, text, sizeof(text)); GetWindowTextA(msgbox, text, sizeof(text));
ok(!strcmp(text, "MSGBOX caption"), "Unexpected window text \"%s\"\n", text); ok(!strcmp(text, "MSGBOX caption"), "Unexpected window text \"%s\"\n", text);
...@@ -2141,26 +2162,9 @@ static LRESULT CALLBACK msgbox_hook_proc(INT code, WPARAM wParam, LPARAM lParam) ...@@ -2141,26 +2162,9 @@ static LRESULT CALLBACK msgbox_hook_proc(INT code, WPARAM wParam, LPARAM lParam)
text[0] = 0; text[0] = 0;
GetWindowTextA(msghwnd, text, sizeof(text)); GetWindowTextA(msghwnd, text, sizeof(text));
ok(!strcmp(text, "Text"), "Unexpected window text \"%s\"\n", text);
SendDlgItemMessageA(msgbox, IDCANCEL, WM_LBUTTONDOWN, 0, 0);
SendDlgItemMessageA(msgbox, IDCANCEL, WM_LBUTTONUP, 0, 0);
}
}
return CallNextHookEx(NULL, code, wParam, lParam);
}
static LRESULT CALLBACK msgbox_sysmodal_hook_proc(INT code, WPARAM wParam, LPARAM lParam)
{
if (code == HCBT_ACTIVATE)
{
HWND msgbox = (HWND)wParam;
LONG exstyles = GetWindowLongA(msgbox, GWL_EXSTYLE);
if (msgbox) todo_wine_if(msgbox_type != MB_OKCANCEL && !*text)
{ ok(!strcmp(text, "Text"), "Unexpected window text \"%s\"\n", text);
ok(exstyles & WS_EX_TOPMOST, "expected message box to have topmost exstyle set\n");
SendDlgItemMessageA(msgbox, IDCANCEL, WM_LBUTTONDOWN, 0, 0); SendDlgItemMessageA(msgbox, IDCANCEL, WM_LBUTTONDOWN, 0, 0);
SendDlgItemMessageA(msgbox, IDCANCEL, WM_LBUTTONUP, 0, 0); SendDlgItemMessageA(msgbox, IDCANCEL, WM_LBUTTONUP, 0, 0);
...@@ -2172,20 +2176,32 @@ static LRESULT CALLBACK msgbox_sysmodal_hook_proc(INT code, WPARAM wParam, LPARA ...@@ -2172,20 +2176,32 @@ static LRESULT CALLBACK msgbox_sysmodal_hook_proc(INT code, WPARAM wParam, LPARA
static void test_MessageBox(void) static void test_MessageBox(void)
{ {
static const UINT tests[] =
{
MB_OKCANCEL,
MB_OKCANCEL | MB_SYSTEMMODAL,
MB_OKCANCEL | MB_TASKMODAL | MB_SYSTEMMODAL,
MB_OKCANCEL | MB_TOPMOST,
MB_OKCANCEL | MB_TOPMOST | MB_SYSTEMMODAL,
MB_OKCANCEL | MB_TASKMODAL | MB_TOPMOST,
MB_OKCANCEL | MB_TASKMODAL | MB_SYSTEMMODAL | MB_TOPMOST,
};
unsigned int i;
HHOOK hook; HHOOK hook;
int ret; int ret;
hook = SetWindowsHookExA(WH_CBT, msgbox_hook_proc, NULL, GetCurrentThreadId()); hook = SetWindowsHookExA(WH_CBT, msgbox_hook_proc, NULL, GetCurrentThreadId());
ret = MessageBoxA(NULL, "Text", "MSGBOX caption", MB_OKCANCEL); for (i = 0; i < ARRAY_SIZE(tests); ++i)
ok(ret == IDCANCEL, "got %d\n", ret); {
msgbox_type = tests[i];
UnhookWindowsHookEx(hook); winetest_push_context("type %#x", msgbox_type);
msgbox_hook_proc_called = 0;
/* Test for MB_SYSTEMMODAL */ ret = MessageBoxA(NULL, "Text", "MSGBOX caption", msgbox_type);
hook = SetWindowsHookExA(WH_CBT, msgbox_sysmodal_hook_proc, NULL, GetCurrentThreadId()); ok(ret == IDCANCEL, "got %d\n", ret);
ok(msgbox_hook_proc_called, "got %u.\n", msgbox_hook_proc_called);
MessageBoxA(NULL, NULL, "system modal", MB_OKCANCEL | MB_SYSTEMMODAL); winetest_pop_context();
}
UnhookWindowsHookEx(hook); UnhookWindowsHookEx(hook);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment