user32/tests: Test more flags for MessageBox.
This commit is contained in:
parent
b4280a486f
commit
adf77c1abe
1 changed files with 44 additions and 28 deletions
|
@ -2123,15 +2123,36 @@ static void test_timer_message(void)
|
|||
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 const LONG considered_ex_styles = WS_EX_CONTROLPARENT | WS_EX_WINDOWEDGE | WS_EX_DLGMODALFRAME | WS_EX_TOPMOST;
|
||||
|
||||
if (code == HCBT_ACTIVATE)
|
||||
{
|
||||
HWND msgbox = (HWND)wParam, msghwnd;
|
||||
LONG exstyles, expected_exstyles;
|
||||
BOOL system_modal;
|
||||
char text[64];
|
||||
|
||||
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;
|
||||
GetWindowTextA(msgbox, text, sizeof(text));
|
||||
ok(!strcmp(text, "MSGBOX caption"), "Unexpected window text \"%s\"\n", text);
|
||||
|
@ -2141,6 +2162,8 @@ static LRESULT CALLBACK msgbox_hook_proc(INT code, WPARAM wParam, LPARAM lParam)
|
|||
|
||||
text[0] = 0;
|
||||
GetWindowTextA(msghwnd, text, sizeof(text));
|
||||
|
||||
todo_wine_if(msgbox_type != MB_OKCANCEL && !*text)
|
||||
ok(!strcmp(text, "Text"), "Unexpected window text \"%s\"\n", text);
|
||||
|
||||
SendDlgItemMessageA(msgbox, IDCANCEL, WM_LBUTTONDOWN, 0, 0);
|
||||
|
@ -2151,41 +2174,34 @@ static LRESULT CALLBACK msgbox_hook_proc(INT code, WPARAM wParam, LPARAM lParam)
|
|||
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)
|
||||
{
|
||||
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_LBUTTONUP, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
return CallNextHookEx(NULL, code, wParam, lParam);
|
||||
}
|
||||
|
||||
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;
|
||||
int ret;
|
||||
|
||||
hook = SetWindowsHookExA(WH_CBT, msgbox_hook_proc, NULL, GetCurrentThreadId());
|
||||
|
||||
ret = MessageBoxA(NULL, "Text", "MSGBOX caption", MB_OKCANCEL);
|
||||
ok(ret == IDCANCEL, "got %d\n", ret);
|
||||
|
||||
UnhookWindowsHookEx(hook);
|
||||
|
||||
/* Test for MB_SYSTEMMODAL */
|
||||
hook = SetWindowsHookExA(WH_CBT, msgbox_sysmodal_hook_proc, NULL, GetCurrentThreadId());
|
||||
|
||||
MessageBoxA(NULL, NULL, "system modal", MB_OKCANCEL | MB_SYSTEMMODAL);
|
||||
for (i = 0; i < ARRAY_SIZE(tests); ++i)
|
||||
{
|
||||
msgbox_type = tests[i];
|
||||
winetest_push_context("type %#x", msgbox_type);
|
||||
msgbox_hook_proc_called = 0;
|
||||
ret = MessageBoxA(NULL, "Text", "MSGBOX caption", msgbox_type);
|
||||
ok(ret == IDCANCEL, "got %d\n", ret);
|
||||
ok(msgbox_hook_proc_called, "got %u.\n", msgbox_hook_proc_called);
|
||||
winetest_pop_context();
|
||||
}
|
||||
|
||||
UnhookWindowsHookEx(hook);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue