ddraw/tests: Add get display mode tests.

Signed-off-by: Zhiyi Zhang <zzhang@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zhiyi Zhang 2020-05-11 15:34:24 +08:00 committed by Alexandre Julliard
parent 9f4f385fcc
commit 248b5d7427
4 changed files with 152 additions and 0 deletions

View File

@ -13694,6 +13694,43 @@ static void test_window_position(void)
EnumDisplayMonitors(NULL, NULL, test_window_position_cb, 0); EnumDisplayMonitors(NULL, NULL, test_window_position_cb, 0);
} }
static BOOL CALLBACK test_get_display_mode_cb(HMONITOR monitor, HDC hdc, RECT *monitor_rect,
LPARAM lparam)
{
DDSURFACEDESC surface_desc;
IDirectDraw *ddraw;
HWND window;
HRESULT hr;
BOOL ret;
ddraw = create_ddraw();
ok(!!ddraw, "Failed to create a ddraw object.\n");
window = create_window();
ok(!!window, "Failed to create a window.\n");
/* Test that DirectDraw doesn't use the device window to determine which monitor to use */
ret = SetWindowPos(window, 0, monitor_rect->left, monitor_rect->top, 0, 0,
SWP_NOZORDER | SWP_NOSIZE);
ok(ret, "SetWindowPos failed, error %#x.\n", GetLastError());
surface_desc.dwSize = sizeof(surface_desc);
hr = IDirectDraw_GetDisplayMode(ddraw, &surface_desc);
ok(hr == DD_OK, "GetDisplayMode failed, hr %#x.\n", hr);
ok(surface_desc.dwWidth == GetSystemMetrics(SM_CXSCREEN), "Expect width %d, got %d.\n",
GetSystemMetrics(SM_CXSCREEN), surface_desc.dwWidth);
ok(surface_desc.dwHeight == GetSystemMetrics(SM_CYSCREEN), "Expect height %d, got %d.\n",
GetSystemMetrics(SM_CYSCREEN), surface_desc.dwHeight);
DestroyWindow(window);
IDirectDraw_Release(ddraw);
return TRUE;
}
static void test_get_display_mode(void)
{
EnumDisplayMonitors(NULL, NULL, test_get_display_mode_cb, 0);
}
START_TEST(ddraw1) START_TEST(ddraw1)
{ {
DDDEVICEIDENTIFIER identifier; DDDEVICEIDENTIFIER identifier;
@ -13809,4 +13846,5 @@ START_TEST(ddraw1)
test_cursor_clipping(); test_cursor_clipping();
test_vtbl_protection(); test_vtbl_protection();
test_window_position(); test_window_position();
test_get_display_mode();
} }

View File

@ -14466,6 +14466,43 @@ static void test_window_position(void)
EnumDisplayMonitors(NULL, NULL, test_window_position_cb, 0); EnumDisplayMonitors(NULL, NULL, test_window_position_cb, 0);
} }
static BOOL CALLBACK test_get_display_mode_cb(HMONITOR monitor, HDC hdc, RECT *monitor_rect,
LPARAM lparam)
{
DDSURFACEDESC surface_desc;
IDirectDraw2 *ddraw;
HWND window;
HRESULT hr;
BOOL ret;
ddraw = create_ddraw();
ok(!!ddraw, "Failed to create a ddraw object.\n");
window = create_window();
ok(!!window, "Failed to create a window.\n");
/* Test that DirectDraw doesn't use the device window to determine which monitor to use */
ret = SetWindowPos(window, 0, monitor_rect->left, monitor_rect->top, 0, 0,
SWP_NOZORDER | SWP_NOSIZE);
ok(ret, "SetWindowPos failed, error %#x.\n", GetLastError());
surface_desc.dwSize = sizeof(surface_desc);
hr = IDirectDraw2_GetDisplayMode(ddraw, &surface_desc);
ok(hr == DD_OK, "GetDisplayMode failed, hr %#x.\n", hr);
ok(surface_desc.dwWidth == GetSystemMetrics(SM_CXSCREEN), "Expect width %d, got %d.\n",
GetSystemMetrics(SM_CXSCREEN), surface_desc.dwWidth);
ok(surface_desc.dwHeight == GetSystemMetrics(SM_CYSCREEN), "Expect height %d, got %d.\n",
GetSystemMetrics(SM_CYSCREEN), surface_desc.dwHeight);
DestroyWindow(window);
IDirectDraw2_Release(ddraw);
return TRUE;
}
static void test_get_display_mode(void)
{
EnumDisplayMonitors(NULL, NULL, test_get_display_mode_cb, 0);
}
START_TEST(ddraw2) START_TEST(ddraw2)
{ {
DDDEVICEIDENTIFIER identifier; DDDEVICEIDENTIFIER identifier;
@ -14587,4 +14624,5 @@ START_TEST(ddraw2)
test_d32_support(); test_d32_support();
test_cursor_clipping(); test_cursor_clipping();
test_window_position(); test_window_position();
test_get_display_mode();
} }

View File

@ -17493,6 +17493,43 @@ static void test_window_position(void)
EnumDisplayMonitors(NULL, NULL, test_window_position_cb, 0); EnumDisplayMonitors(NULL, NULL, test_window_position_cb, 0);
} }
static BOOL CALLBACK test_get_display_mode_cb(HMONITOR monitor, HDC hdc, RECT *monitor_rect,
LPARAM lparam)
{
DDSURFACEDESC2 surface_desc;
IDirectDraw4 *ddraw;
HWND window;
HRESULT hr;
BOOL ret;
ddraw = create_ddraw();
ok(!!ddraw, "Failed to create a ddraw object.\n");
window = create_window();
ok(!!window, "Failed to create a window.\n");
/* Test that DirectDraw doesn't use the device window to determine which monitor to use */
ret = SetWindowPos(window, 0, monitor_rect->left, monitor_rect->top, 0, 0,
SWP_NOZORDER | SWP_NOSIZE);
ok(ret, "SetWindowPos failed, error %#x.\n", GetLastError());
surface_desc.dwSize = sizeof(surface_desc);
hr = IDirectDraw4_GetDisplayMode(ddraw, &surface_desc);
ok(hr == DD_OK, "GetDisplayMode failed, hr %#x.\n", hr);
ok(surface_desc.dwWidth == GetSystemMetrics(SM_CXSCREEN), "Expect width %d, got %d.\n",
GetSystemMetrics(SM_CXSCREEN), surface_desc.dwWidth);
ok(surface_desc.dwHeight == GetSystemMetrics(SM_CYSCREEN), "Expect height %d, got %d.\n",
GetSystemMetrics(SM_CYSCREEN), surface_desc.dwHeight);
DestroyWindow(window);
IDirectDraw4_Release(ddraw);
return TRUE;
}
static void test_get_display_mode(void)
{
EnumDisplayMonitors(NULL, NULL, test_get_display_mode_cb, 0);
}
START_TEST(ddraw4) START_TEST(ddraw4)
{ {
DDDEVICEIDENTIFIER identifier; DDDEVICEIDENTIFIER identifier;
@ -17630,4 +17667,5 @@ START_TEST(ddraw4)
test_surface_format_conversion_alpha(); test_surface_format_conversion_alpha();
test_cursor_clipping(); test_cursor_clipping();
test_window_position(); test_window_position();
test_get_display_mode();
} }

View File

@ -17728,6 +17728,43 @@ static void test_window_position(void)
EnumDisplayMonitors(NULL, NULL, test_window_position_cb, 0); EnumDisplayMonitors(NULL, NULL, test_window_position_cb, 0);
} }
static BOOL CALLBACK test_get_display_mode_cb(HMONITOR monitor, HDC hdc, RECT *monitor_rect,
LPARAM lparam)
{
DDSURFACEDESC2 surface_desc;
IDirectDraw7 *ddraw;
HWND window;
HRESULT hr;
BOOL ret;
ddraw = create_ddraw();
ok(!!ddraw, "Failed to create a ddraw object.\n");
window = create_window();
ok(!!window, "Failed to create a window.\n");
/* Test that DirectDraw doesn't use the device window to determine which monitor to use */
ret = SetWindowPos(window, 0, monitor_rect->left, monitor_rect->top, 0, 0,
SWP_NOZORDER | SWP_NOSIZE);
ok(ret, "SetWindowPos failed, error %#x.\n", GetLastError());
surface_desc.dwSize = sizeof(surface_desc);
hr = IDirectDraw7_GetDisplayMode(ddraw, &surface_desc);
ok(hr == DD_OK, "GetDisplayMode failed, hr %#x.\n", hr);
ok(surface_desc.dwWidth == GetSystemMetrics(SM_CXSCREEN), "Expect width %d, got %d.\n",
GetSystemMetrics(SM_CXSCREEN), surface_desc.dwWidth);
ok(surface_desc.dwHeight == GetSystemMetrics(SM_CYSCREEN), "Expect height %d, got %d.\n",
GetSystemMetrics(SM_CYSCREEN), surface_desc.dwHeight);
DestroyWindow(window);
IDirectDraw7_Release(ddraw);
return TRUE;
}
static void test_get_display_mode(void)
{
EnumDisplayMonitors(NULL, NULL, test_get_display_mode_cb, 0);
}
START_TEST(ddraw7) START_TEST(ddraw7)
{ {
DDDEVICEIDENTIFIER2 identifier; DDDEVICEIDENTIFIER2 identifier;
@ -17880,4 +17917,5 @@ START_TEST(ddraw7)
test_compressed_surface_stretch(); test_compressed_surface_stretch();
test_cursor_clipping(); test_cursor_clipping();
test_window_position(); test_window_position();
test_get_display_mode();
} }