Commit be01a763 authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

ddraw/tests: Test messages on focus loss.

parent 9d63e3f9
......@@ -428,12 +428,26 @@ static void destroy_material(IDirect3DMaterial *material)
IDirect3DMaterial_Release(material);
}
static const UINT *expect_messages;
struct message
{
UINT message;
BOOL check_wparam;
WPARAM expect_wparam;
};
static const struct message *expect_messages;
static LRESULT CALLBACK test_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
if (expect_messages && message == *expect_messages)
if (expect_messages && message == expect_messages->message)
{
if (expect_messages->check_wparam)
ok (wparam == expect_messages->expect_wparam,
"Got unexpected wparam %lx for message %x, expected %lx.\n",
wparam, message, expect_messages->expect_wparam);
++expect_messages;
}
return DefWindowProcA(hwnd, message, wparam, lparam);
}
......@@ -1878,15 +1892,15 @@ static void test_wndproc(void)
HRESULT hr;
ULONG ref;
static const UINT messages[] =
static struct message messages[] =
{
WM_WINDOWPOSCHANGING,
WM_MOVE,
WM_SIZE,
WM_WINDOWPOSCHANGING,
WM_ACTIVATE,
WM_SETFOCUS,
0,
{WM_WINDOWPOSCHANGING, FALSE, 0},
{WM_MOVE, FALSE, 0},
{WM_SIZE, FALSE, 0},
{WM_WINDOWPOSCHANGING, FALSE, 0},
{WM_ACTIVATE, FALSE, 0},
{WM_SETFOCUS, FALSE, 0},
{0, FALSE, 0},
};
/* DDSCL_EXCLUSIVE replaces the window's window proc. */
......@@ -1906,7 +1920,7 @@ static void test_wndproc(void)
expect_messages = messages;
hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx, got %#lx.\n",
......@@ -2147,19 +2161,34 @@ static void test_coop_level_mode_set(void)
BOOL ret;
LONG change_ret;
static const UINT exclusive_messages[] =
static const struct message exclusive_messages[] =
{
{WM_WINDOWPOSCHANGING, FALSE, 0},
{WM_WINDOWPOSCHANGED, FALSE, 0},
{WM_SIZE, FALSE, 0},
{WM_DISPLAYCHANGE, FALSE, 0},
{0, FALSE, 0},
};
static const struct message exclusive_focus_loss_messages[] =
{
WM_WINDOWPOSCHANGING,
WM_WINDOWPOSCHANGED,
WM_SIZE,
WM_DISPLAYCHANGE,
0,
{WM_ACTIVATE, TRUE, WA_INACTIVE},
/*{WM_DISPLAYCHANGE, FALSE, 0}, Not yet implemented on Wine. */
{WM_WINDOWPOSCHANGING, FALSE, 0},
/* Like d3d8 and d3d9 ddraw seems to use SW_SHOWMINIMIZED instead of
* SW_MINIMIZED, causing a recursive window activation that does not
* produe the same result in Wine yet. Ignore the difference for now.
* {WM_ACTIVATE, TRUE, 0x200000 | WA_ACTIVE}, */
{WM_WINDOWPOSCHANGED, FALSE, 0},
{WM_MOVE, FALSE, 0},
{WM_SIZE, TRUE, SIZE_MINIMIZED},
{WM_ACTIVATEAPP, TRUE, FALSE},
{0, FALSE, 0},
};
static const UINT normal_messages[] =
static const struct message normal_messages[] =
{
WM_DISPLAYCHANGE,
0,
{WM_DISPLAYCHANGE, FALSE, 0},
{0, FALSE, 0},
};
ddraw = create_ddraw();
......@@ -2234,7 +2263,7 @@ static void test_coop_level_mode_set(void)
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(screen_size.cx == param.ddraw_width && screen_size.cy == param.ddraw_height,
"Expected screen size %ux%u, got %ux%u.\n",
......@@ -2280,7 +2309,7 @@ static void test_coop_level_mode_set(void)
change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(screen_size.cx == param.user32_width && screen_size.cy == param.user32_height,
"Expected screen size %ux%u, got %ux%u.\n",
......@@ -2291,6 +2320,19 @@ static void test_coop_level_mode_set(void)
user32_rect.left, user32_rect.top, user32_rect.right, user32_rect.bottom,
r.left, r.top, r.right, r.bottom);
expect_messages = exclusive_focus_loss_messages;
ret = SetForegroundWindow(GetDesktopWindow());
ok(ret, "Failed to set foreground window.\n");
ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
ShowWindow(window, SW_RESTORE);
hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
/* Normally the primary should be restored here. Unfortunately this causes the
* GetSurfaceDesc call after the next display mode change to crash on the Windows 8
* testbot. Another Restore call would presumably avoid the crash, but it also moots
* the point of the GetSurfaceDesc call. */
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
expect_messages = exclusive_messages;
screen_size.cx = 0;
......@@ -2299,7 +2341,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
todo_wine ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
todo_wine ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
todo_wine ok(screen_size.cx == registry_mode.dmPelsWidth
&& screen_size.cy == registry_mode.dmPelsHeight,
......@@ -2385,7 +2427,7 @@ static void test_coop_level_mode_set(void)
change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
......@@ -2409,7 +2451,7 @@ static void test_coop_level_mode_set(void)
}
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
......@@ -2453,7 +2495,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
......@@ -2548,7 +2590,7 @@ static void test_coop_level_mode_set(void)
change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
......@@ -2565,7 +2607,7 @@ static void test_coop_level_mode_set(void)
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
......@@ -2609,7 +2651,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
......
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