Commit 76a0ab7f authored by Zhiyi Zhang's avatar Zhiyi Zhang Committed by Alexandre Julliard

d3d9/tests: Fix possible test failures.

expect_messages points to a local variable. When it goes out of scope, it reads into random memory, causing failures. Signed-off-by: 's avatarZhiyi Zhang <zzhang@codeweavers.com> Signed-off-by: 's avatarHenri Verbeet <hverbeet@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 0bd130f2
......@@ -2631,6 +2631,7 @@ static void test_wndproc(void)
{
struct wndproc_thread_param thread_params;
struct device_desc device_desc;
static WINDOWPOS windowpos;
IDirect3DDevice9Ex *device;
WNDCLASSA wc = {0};
HANDLE thread;
......@@ -2646,7 +2647,6 @@ static void test_wndproc(void)
LONG change_ret, device_style;
BOOL ret;
IDirect3D9Ex *d3d9ex;
WINDOWPOS windowpos;
static const struct message create_messages[] =
{
......@@ -2747,7 +2747,7 @@ static void test_wndproc(void)
/* WM_SIZE(SIZE_MAXIMIZED) is unreliable on native. */
{0, 0, FALSE, 0},
};
struct message mode_change_messages[] =
static const struct message mode_change_messages[] =
{
{WM_WINDOWPOSCHANGING, DEVICE_WINDOW, FALSE, 0},
{WM_WINDOWPOSCHANGED, DEVICE_WINDOW, FALSE, 0},
......@@ -2760,7 +2760,7 @@ static void test_wndproc(void)
* ShowWindow does not send such a message because the window is already visible. */
{0, 0, FALSE, 0},
};
struct message mode_change_messages_hidden[] =
static const struct message mode_change_messages_hidden[] =
{
{WM_WINDOWPOSCHANGING, DEVICE_WINDOW, FALSE, 0},
{WM_WINDOWPOSCHANGED, DEVICE_WINDOW, FALSE, 0},
......@@ -2777,7 +2777,7 @@ static void test_wndproc(void)
{WM_DISPLAYCHANGE, FOCUS_WINDOW, FALSE, 0},
{0, 0, FALSE, 0},
};
struct
static const struct
{
DWORD create_flags;
const struct message *focus_loss_messages;
......@@ -2859,6 +2859,9 @@ static void test_wndproc(void)
return;
}
filter_messages = NULL;
expect_messages = NULL;
wc.lpfnWndProc = test_proc;
wc.lpszClassName = "d3d9_test_wndproc_wc";
ok(RegisterClassA(&wc), "Failed to register window class.\n");
......@@ -3189,6 +3192,7 @@ static void test_wndproc(void)
flush_events();
ok(!expect_messages->message, "Expected message %#x for window %#x, but didn't receive it, i=%u.\n",
expect_messages->message, expect_messages->window, i);
expect_messages = NULL;
/* World of Warplanes hides the window by removing WS_VISIBLE and expects Reset() to show it again. */
device_style = GetWindowLongA(device_window, GWL_STYLE);
......@@ -3208,6 +3212,7 @@ static void test_wndproc(void)
flush_events();
ok(!expect_messages->message, "Expected message %#x for window %#x, but didn't receive it, i=%u.\n",
expect_messages->message, expect_messages->window, i);
expect_messages = NULL;
if (!(tests[i].create_flags & CREATE_DEVICE_NOWINDOWCHANGES))
{
......@@ -3244,6 +3249,7 @@ static void test_wndproc(void)
done:
filter_messages = NULL;
expect_messages = NULL;
DestroyWindow(device_window);
DestroyWindow(focus_window);
SetEvent(thread_params.test_finished);
......@@ -3270,6 +3276,9 @@ static void test_wndproc_windowed(void)
DWORD res, tid;
HWND tmp;
filter_messages = NULL;
expect_messages = NULL;
wc.lpfnWndProc = test_proc;
wc.lpszClassName = "d3d9_test_wndproc_wc";
ok(RegisterClassA(&wc), "Failed to register window class.\n");
......
......@@ -3655,6 +3655,7 @@ static void test_wndproc(void)
{
struct wndproc_thread_param thread_params;
struct device_desc device_desc;
static WINDOWPOS windowpos;
IDirect3DDevice9 *device;
WNDCLASSA wc = {0};
IDirect3D9 *d3d9;
......@@ -3670,7 +3671,6 @@ static void test_wndproc(void)
DEVMODEW devmode;
LONG change_ret, device_style;
BOOL ret;
WINDOWPOS windowpos;
static const struct message create_messages[] =
{
......@@ -3784,7 +3784,7 @@ static void test_wndproc(void)
/* WM_SIZE(SIZE_MAXIMIZED) is unreliable on native. */
{0, 0, FALSE, 0},
};
struct message mode_change_messages[] =
static const struct message mode_change_messages[] =
{
{WM_WINDOWPOSCHANGING, DEVICE_WINDOW, FALSE, 0},
{WM_WINDOWPOSCHANGED, DEVICE_WINDOW, FALSE, 0},
......@@ -3797,7 +3797,7 @@ static void test_wndproc(void)
* ShowWindow does not send such a message because the window is already visible. */
{0, 0, FALSE, 0},
};
struct message mode_change_messages_hidden[] =
static const struct message mode_change_messages_hidden[] =
{
{WM_WINDOWPOSCHANGING, DEVICE_WINDOW, FALSE, 0},
{WM_WINDOWPOSCHANGED, DEVICE_WINDOW, FALSE, 0},
......@@ -3814,7 +3814,7 @@ static void test_wndproc(void)
{WM_DISPLAYCHANGE, FOCUS_WINDOW, FALSE, 0},
{0, 0, FALSE, 0},
};
struct
static const struct
{
DWORD create_flags;
const struct message *focus_loss_messages, *reactivate_messages;
......@@ -3893,6 +3893,9 @@ static void test_wndproc(void)
return;
}
filter_messages = NULL;
expect_messages = NULL;
wc.lpfnWndProc = test_proc;
wc.lpszClassName = "d3d9_test_wndproc_wc";
ok(RegisterClassA(&wc), "Failed to register window class.\n");
......@@ -4258,6 +4261,7 @@ static void test_wndproc(void)
flush_events();
ok(!expect_messages->message, "Expected message %#x for window %#x, but didn't receive it, i=%u.\n",
expect_messages->message, expect_messages->window, i);
expect_messages = NULL;
/* World of Warplanes hides the window by removing WS_VISIBLE and expects Reset() to show it again. */
device_style = GetWindowLongA(device_window, GWL_STYLE);
......@@ -4277,6 +4281,7 @@ static void test_wndproc(void)
flush_events();
ok(!expect_messages->message, "Expected message %#x for window %#x, but didn't receive it, i=%u.\n",
expect_messages->message, expect_messages->window, i);
expect_messages = NULL;
if (!(tests[i].create_flags & CREATE_DEVICE_NOWINDOWCHANGES))
{
......@@ -4314,6 +4319,7 @@ static void test_wndproc(void)
done:
filter_messages = NULL;
expect_messages = NULL;
DestroyWindow(device_window);
DestroyWindow(focus_window);
SetEvent(thread_params.test_finished);
......@@ -4344,6 +4350,9 @@ static void test_wndproc_windowed(void)
d3d9 = Direct3DCreate9(D3D_SDK_VERSION);
ok(!!d3d9, "Failed to create a D3D object.\n");
filter_messages = NULL;
expect_messages = NULL;
wc.lpfnWndProc = test_proc;
wc.lpszClassName = "d3d9_test_wndproc_wc";
ok(RegisterClassA(&wc), "Failed to register window class.\n");
......@@ -4557,6 +4566,7 @@ static void test_reset_fullscreen(void)
d3d = Direct3DCreate9(D3D_SDK_VERSION);
ok(!!d3d, "Failed to create a D3D object.\n");
filter_messages = NULL;
expect_messages = messages;
wc.cbSize = sizeof(wc);
......@@ -5259,6 +5269,9 @@ static void test_device_window_reset(void)
HRESULT hr;
ULONG ref;
filter_messages = NULL;
expect_messages = NULL;
wc.lpfnWndProc = test_proc;
wc.lpszClassName = "d3d9_test_wndproc_wc";
ok(RegisterClassA(&wc), "Failed to register window class.\n");
......
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