d3d8/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:
parent
d02b4581b5
commit
9317303bae
|
@ -2435,12 +2435,14 @@ struct message
|
|||
enum message_window window;
|
||||
BOOL check_wparam;
|
||||
WPARAM expect_wparam;
|
||||
HRESULT device_state;
|
||||
WINDOWPOS *store_wp;
|
||||
};
|
||||
|
||||
static const struct message *expect_messages;
|
||||
static HWND device_window, focus_window;
|
||||
static LONG windowposchanged_received, syscommand_received;
|
||||
static IDirect3DDevice8 *focus_test_device;
|
||||
|
||||
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)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
if (filter_messages && filter_messages == hwnd)
|
||||
{
|
||||
if (message != WM_DISPLAYCHANGE && message != WM_IME_NOTIFY)
|
||||
|
@ -2487,6 +2491,18 @@ static LRESULT CALLBACK test_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM
|
|||
if (expect_messages->store_wp)
|
||||
*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;
|
||||
}
|
||||
}
|
||||
|
@ -2576,23 +2592,24 @@ static void test_wndproc(void)
|
|||
* not reliable on X11 WMs. When the window focus follows the
|
||||
* mouse pointer the message is not sent.
|
||||
* {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
|
||||
* 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
|
||||
* SW_SHOWMINIMIZED is used instead of SW_MINIMIZE. Yet afterwards
|
||||
* the foreground and focus window are NULL. On Wine SW_SHOWMINIMIZED
|
||||
* leaves the device window active, breaking re-activation in the
|
||||
* lost device test.
|
||||
* {WM_ACTIVATE, DEVICE_WINDOW, TRUE, 0x200000 | WA_ACTIVE}, */
|
||||
{WM_WINDOWPOSCHANGED, DEVICE_WINDOW, FALSE, 0},
|
||||
{WM_SIZE, DEVICE_WINDOW, TRUE, SIZE_MINIMIZED},
|
||||
{WM_ACTIVATEAPP, FOCUS_WINDOW, TRUE, FALSE},
|
||||
{WM_WINDOWPOSCHANGED, DEVICE_WINDOW, FALSE, 0, D3DERR_DEVICENOTRESET},
|
||||
{WM_SIZE, DEVICE_WINDOW, TRUE, SIZE_MINIMIZED,
|
||||
D3DERR_DEVICENOTRESET},
|
||||
{WM_ACTIVATEAPP, FOCUS_WINDOW, TRUE, FALSE, D3DERR_DEVICELOST},
|
||||
/* WM_ACTIVATEAPP is sent to the device window too, but the order is
|
||||
* not deterministic. It may be sent after the focus window handling
|
||||
* or before. */
|
||||
{0, 0, FALSE, 0},
|
||||
{0, 0, FALSE, 0, 0},
|
||||
};
|
||||
static const struct message reactivate_messages[] =
|
||||
{
|
||||
|
@ -2673,7 +2690,7 @@ static void test_wndproc(void)
|
|||
{WM_WINDOWPOSCHANGED, DEVICE_WINDOW, FALSE, 0},
|
||||
{WM_SIZE, 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},
|
||||
/* TODO: WM_DISPLAYCHANGE is sent to the focus window too, but the order is
|
||||
* differs between Wine and Windows. */
|
||||
|
@ -2832,6 +2849,7 @@ static void test_wndproc(void)
|
|||
ok(hr == D3DERR_DEVICENOTRESET, "Got unexpected hr %#x.\n", hr);
|
||||
|
||||
expect_messages = focus_loss_messages;
|
||||
focus_test_device = device;
|
||||
/* SetForegroundWindow is a poor replacement for the user pressing alt-tab or
|
||||
* 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
|
||||
|
@ -2844,6 +2862,7 @@ static void test_wndproc(void)
|
|||
tmp = GetFocus();
|
||||
ok(tmp != device_window, "The device 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. */
|
||||
hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
|
||||
|
|
Loading…
Reference in New Issue