ddraw/tests: Test when the device goes bad on focus loss.

Signed-off-by: Stefan Dösinger <stefan@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Stefan Dösinger 2018-10-13 16:13:53 -07:00 committed by Alexandre Julliard
parent 7a36efc3bc
commit d02b4581b5
2 changed files with 52 additions and 24 deletions

View File

@ -532,12 +532,16 @@ struct message
UINT message;
BOOL check_wparam;
WPARAM expect_wparam;
HRESULT ddraw_state;
};
static const struct message *expect_messages;
static IDirectDraw4 *focus_test_ddraw;
static LRESULT CALLBACK test_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
HRESULT hr;
if (expect_messages && message == expect_messages->message)
{
if (expect_messages->check_wparam)
@ -545,6 +549,13 @@ static LRESULT CALLBACK test_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM
"Got unexpected wparam %lx for message %x, expected %lx.\n",
wparam, message, expect_messages->expect_wparam);
if (focus_test_ddraw)
{
hr = IDirectDraw4_TestCooperativeLevel(focus_test_ddraw);
ok(hr == expect_messages->ddraw_state, "Got ddraw state %#x on message %#x, expected %#x.\n",
hr, message, expect_messages->ddraw_state);
}
++expect_messages;
}
@ -2712,22 +2723,22 @@ static void test_coop_level_mode_set(void)
};
static const struct message exclusive_focus_loss_messages[] =
{
{WM_ACTIVATE, TRUE, WA_INACTIVE},
{WM_WINDOWPOSCHANGING, FALSE, 0}, /* Window resize due to mode change. */
{WM_WINDOWPOSCHANGED, FALSE, 0},
{WM_SIZE, TRUE, SIZE_RESTORED}, /* Generated by DefWindowProc. */
{WM_DISPLAYCHANGE, FALSE, 0},
{WM_KILLFOCUS, FALSE, 0},
{WM_WINDOWPOSCHANGING, FALSE, 0}, /* Window minimized. */
{WM_ACTIVATE, TRUE, WA_INACTIVE, DD_OK},
{WM_WINDOWPOSCHANGING, FALSE, 0, DD_OK}, /* Window resize due to mode change. */
{WM_WINDOWPOSCHANGED, FALSE, 0, DD_OK},
{WM_SIZE, TRUE, SIZE_RESTORED, DD_OK}, /* Generated by DefWindowProc. */
{WM_DISPLAYCHANGE, FALSE, 0, DD_OK},
{WM_KILLFOCUS, FALSE, 0, DDERR_NOEXCLUSIVEMODE},
{WM_WINDOWPOSCHANGING, FALSE, 0, DDERR_NOEXCLUSIVEMODE}, /* Window minimized. */
/* Like d3d8 and d3d9 ddraw seems to use SW_SHOWMINIMIZED instead of
* SW_MINIMIZED, causing a recursive window activation that does not
* produce 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},
{WM_WINDOWPOSCHANGED, FALSE, 0, DDERR_NOEXCLUSIVEMODE},
{WM_MOVE, FALSE, 0, DDERR_NOEXCLUSIVEMODE},
{WM_SIZE, TRUE, SIZE_MINIMIZED, DDERR_NOEXCLUSIVEMODE},
{WM_ACTIVATEAPP, TRUE, FALSE, DDERR_NOEXCLUSIVEMODE},
{0, FALSE, 0, 0},
};
static const struct message exclusive_focus_restore_messages[] =
{
@ -2912,9 +2923,12 @@ static void test_coop_level_mode_set(void)
wine_dbgstr_rect(&r));
expect_messages = exclusive_focus_loss_messages;
focus_test_ddraw = ddraw;
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);
focus_test_ddraw = NULL;
memset(&devmode, 0, sizeof(devmode));
devmode.dmSize = sizeof(devmode);
ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);

View File

@ -448,12 +448,16 @@ struct message
UINT message;
BOOL check_wparam;
WPARAM expect_wparam;
HRESULT ddraw_state;
};
static const struct message *expect_messages;
static IDirectDraw7 *focus_test_ddraw;
static LRESULT CALLBACK test_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
HRESULT hr;
if (expect_messages && message == expect_messages->message)
{
if (expect_messages->check_wparam)
@ -461,6 +465,13 @@ static LRESULT CALLBACK test_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM
"Got unexpected wparam %lx for message %x, expected %lx.\n",
wparam, message, expect_messages->expect_wparam);
if (focus_test_ddraw)
{
hr = IDirectDraw7_TestCooperativeLevel(focus_test_ddraw);
ok(hr == expect_messages->ddraw_state, "Got ddraw state %#x on message %#x, expected %#x.\n",
hr, message, expect_messages->ddraw_state);
}
++expect_messages;
}
@ -2441,22 +2452,22 @@ static void test_coop_level_mode_set(void)
};
static const struct message exclusive_focus_loss_messages[] =
{
{WM_ACTIVATE, TRUE, WA_INACTIVE},
{WM_WINDOWPOSCHANGING, FALSE, 0}, /* Window resize due to mode change. */
{WM_WINDOWPOSCHANGED, FALSE, 0},
{WM_SIZE, TRUE, SIZE_RESTORED}, /* Generated by DefWindowProc. */
{WM_DISPLAYCHANGE, FALSE, 0},
{WM_KILLFOCUS, FALSE, 0},
{WM_WINDOWPOSCHANGING, FALSE, 0}, /* Window minimized. */
{WM_ACTIVATE, TRUE, WA_INACTIVE, DD_OK},
{WM_WINDOWPOSCHANGING, FALSE, 0, DD_OK}, /* Window resize due to mode change. */
{WM_WINDOWPOSCHANGED, FALSE, 0, DD_OK},
{WM_SIZE, TRUE, SIZE_RESTORED, DD_OK}, /* Generated by DefWindowProc. */
{WM_DISPLAYCHANGE, FALSE, 0, DD_OK},
{WM_KILLFOCUS, FALSE, 0, DDERR_NOEXCLUSIVEMODE},
{WM_WINDOWPOSCHANGING, FALSE, 0, DDERR_NOEXCLUSIVEMODE}, /* Window minimized. */
/* Like d3d8 and d3d9 ddraw seems to use SW_SHOWMINIMIZED instead of
* SW_MINIMIZED, causing a recursive window activation that does not
* produce 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},
{WM_WINDOWPOSCHANGED, FALSE, 0, DDERR_NOEXCLUSIVEMODE},
{WM_MOVE, FALSE, 0, DDERR_NOEXCLUSIVEMODE},
{WM_SIZE, TRUE, SIZE_MINIMIZED, DDERR_NOEXCLUSIVEMODE},
{WM_ACTIVATEAPP, TRUE, FALSE, DDERR_NOEXCLUSIVEMODE},
{0, FALSE, 0, 0},
};
static const struct message exclusive_focus_restore_messages[] =
{
@ -2641,9 +2652,12 @@ static void test_coop_level_mode_set(void)
wine_dbgstr_rect(&r));
expect_messages = exclusive_focus_loss_messages;
focus_test_ddraw = ddraw;
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);
focus_test_ddraw = NULL;
memset(&devmode, 0, sizeof(devmode));
devmode.dmSize = sizeof(devmode);
ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);