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

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

parent d02b4581
...@@ -2435,12 +2435,14 @@ struct message ...@@ -2435,12 +2435,14 @@ struct message
enum message_window window; enum message_window window;
BOOL check_wparam; BOOL check_wparam;
WPARAM expect_wparam; WPARAM expect_wparam;
HRESULT device_state;
WINDOWPOS *store_wp; WINDOWPOS *store_wp;
}; };
static const struct message *expect_messages; static const struct message *expect_messages;
static HWND device_window, focus_window; static HWND device_window, focus_window;
static LONG windowposchanged_received, syscommand_received; static LONG windowposchanged_received, syscommand_received;
static IDirect3DDevice8 *focus_test_device;
struct wndproc_thread_param struct wndproc_thread_param
{ {
...@@ -2452,6 +2454,8 @@ struct wndproc_thread_param ...@@ -2452,6 +2454,8 @@ struct wndproc_thread_param
static LRESULT CALLBACK test_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) static LRESULT CALLBACK test_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{ {
HRESULT hr;
if (filter_messages && filter_messages == hwnd) if (filter_messages && filter_messages == hwnd)
{ {
if (message != WM_DISPLAYCHANGE && message != WM_IME_NOTIFY) if (message != WM_DISPLAYCHANGE && message != WM_IME_NOTIFY)
...@@ -2487,6 +2491,18 @@ static LRESULT CALLBACK test_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM ...@@ -2487,6 +2491,18 @@ static LRESULT CALLBACK test_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM
if (expect_messages->store_wp) if (expect_messages->store_wp)
*expect_messages->store_wp = *(WINDOWPOS *)lparam; *expect_messages->store_wp = *(WINDOWPOS *)lparam;
if (focus_test_device)
{
hr = IDirect3DDevice8_TestCooperativeLevel(focus_test_device);
/* Wined3d marks the device lost earlier than Windows (it follows ddraw
* behavior. See test_wndproc before the focus_loss_messages sequence
* about the D3DERR_DEVICENOTRESET behavior, */
todo_wine_if(message != WM_ACTIVATEAPP || hr == D3D_OK)
ok(hr == expect_messages->device_state,
"Got device state %#x on message %#x, expected %#x.\n",
hr, message, expect_messages->device_state);
}
++expect_messages; ++expect_messages;
} }
} }
...@@ -2576,23 +2592,24 @@ static void test_wndproc(void) ...@@ -2576,23 +2592,24 @@ static void test_wndproc(void)
* not reliable on X11 WMs. When the window focus follows the * not reliable on X11 WMs. When the window focus follows the
* mouse pointer the message is not sent. * mouse pointer the message is not sent.
* {WM_ACTIVATE, FOCUS_WINDOW, TRUE, WA_INACTIVE}, */ * {WM_ACTIVATE, FOCUS_WINDOW, TRUE, WA_INACTIVE}, */
{WM_DISPLAYCHANGE, DEVICE_WINDOW, FALSE, 0}, {WM_DISPLAYCHANGE, DEVICE_WINDOW, FALSE, 0, D3DERR_DEVICENOTRESET},
/* WM_DISPLAYCHANGE is sent to the focus window too, but the order is /* WM_DISPLAYCHANGE is sent to the focus window too, but the order is
* not deterministic. */ * not deterministic. */
{WM_WINDOWPOSCHANGING, DEVICE_WINDOW, FALSE, 0}, {WM_WINDOWPOSCHANGING, DEVICE_WINDOW, FALSE, 0, D3DERR_DEVICENOTRESET},
/* Windows sends WM_ACTIVATE to the device window, indicating that /* Windows sends WM_ACTIVATE to the device window, indicating that
* SW_SHOWMINIMIZED is used instead of SW_MINIMIZE. Yet afterwards * SW_SHOWMINIMIZED is used instead of SW_MINIMIZE. Yet afterwards
* the foreground and focus window are NULL. On Wine SW_SHOWMINIMIZED * the foreground and focus window are NULL. On Wine SW_SHOWMINIMIZED
* leaves the device window active, breaking re-activation in the * leaves the device window active, breaking re-activation in the
* lost device test. * lost device test.
* {WM_ACTIVATE, DEVICE_WINDOW, TRUE, 0x200000 | WA_ACTIVE}, */ * {WM_ACTIVATE, DEVICE_WINDOW, TRUE, 0x200000 | WA_ACTIVE}, */
{WM_WINDOWPOSCHANGED, DEVICE_WINDOW, FALSE, 0}, {WM_WINDOWPOSCHANGED, DEVICE_WINDOW, FALSE, 0, D3DERR_DEVICENOTRESET},
{WM_SIZE, DEVICE_WINDOW, TRUE, SIZE_MINIMIZED}, {WM_SIZE, DEVICE_WINDOW, TRUE, SIZE_MINIMIZED,
{WM_ACTIVATEAPP, FOCUS_WINDOW, TRUE, FALSE}, D3DERR_DEVICENOTRESET},
{WM_ACTIVATEAPP, FOCUS_WINDOW, TRUE, FALSE, D3DERR_DEVICELOST},
/* WM_ACTIVATEAPP is sent to the device window too, but the order is /* WM_ACTIVATEAPP is sent to the device window too, but the order is
* not deterministic. It may be sent after the focus window handling * not deterministic. It may be sent after the focus window handling
* or before. */ * or before. */
{0, 0, FALSE, 0}, {0, 0, FALSE, 0, 0},
}; };
static const struct message reactivate_messages[] = static const struct message reactivate_messages[] =
{ {
...@@ -2673,7 +2690,7 @@ static void test_wndproc(void) ...@@ -2673,7 +2690,7 @@ static void test_wndproc(void)
{WM_WINDOWPOSCHANGED, DEVICE_WINDOW, FALSE, 0}, {WM_WINDOWPOSCHANGED, DEVICE_WINDOW, FALSE, 0},
{WM_SIZE, DEVICE_WINDOW, FALSE, 0}, {WM_SIZE, DEVICE_WINDOW, FALSE, 0},
{WM_SHOWWINDOW, DEVICE_WINDOW, FALSE, 0}, {WM_SHOWWINDOW, DEVICE_WINDOW, FALSE, 0},
{WM_WINDOWPOSCHANGING, DEVICE_WINDOW, FALSE, 0, &windowpos}, {WM_WINDOWPOSCHANGING, DEVICE_WINDOW, FALSE, 0, ~0U, &windowpos},
{WM_WINDOWPOSCHANGED, DEVICE_WINDOW, FALSE, 0}, {WM_WINDOWPOSCHANGED, DEVICE_WINDOW, FALSE, 0},
/* TODO: WM_DISPLAYCHANGE is sent to the focus window too, but the order is /* TODO: WM_DISPLAYCHANGE is sent to the focus window too, but the order is
* differs between Wine and Windows. */ * differs between Wine and Windows. */
...@@ -2832,6 +2849,7 @@ static void test_wndproc(void) ...@@ -2832,6 +2849,7 @@ static void test_wndproc(void)
ok(hr == D3DERR_DEVICENOTRESET, "Got unexpected hr %#x.\n", hr); ok(hr == D3DERR_DEVICENOTRESET, "Got unexpected hr %#x.\n", hr);
expect_messages = focus_loss_messages; expect_messages = focus_loss_messages;
focus_test_device = device;
/* SetForegroundWindow is a poor replacement for the user pressing alt-tab or /* SetForegroundWindow is a poor replacement for the user pressing alt-tab or
* manually changing the focus. It generates the same messages, but the task * manually changing the focus. It generates the same messages, but the task
* bar still shows the previous foreground window as active, and the window has * bar still shows the previous foreground window as active, and the window has
...@@ -2844,6 +2862,7 @@ static void test_wndproc(void) ...@@ -2844,6 +2862,7 @@ static void test_wndproc(void)
tmp = GetFocus(); tmp = GetFocus();
ok(tmp != device_window, "The device window is active.\n"); ok(tmp != device_window, "The device window is active.\n");
ok(tmp != focus_window, "The focus window is active.\n"); ok(tmp != focus_window, "The focus window is active.\n");
focus_test_device = NULL;
/* The Present call is necessary to make native realize the device is lost. */ /* The Present call is necessary to make native realize the device is lost. */
hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL); hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
......
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