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

ddraw/tests: Check if the current display settings match the registry settings.

parent a8ad62aa
......@@ -21,6 +21,8 @@
#include "wine/test.h"
#include "d3d.h"
static DEVMODEW registry_mode;
struct create_window_thread_param
{
HWND window;
......@@ -2007,7 +2009,7 @@ static void test_window_style(void)
style = GetWindowLongA(window, GWL_STYLE);
exstyle = GetWindowLongA(window, GWL_EXSTYLE);
SetRect(&fullscreen_rect, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
SetRect(&fullscreen_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
......@@ -2137,7 +2139,7 @@ static void test_coop_level_mode_set(void)
window = CreateWindowA("ddraw_test_wndproc_wc", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, 100, 100, 0, 0, 0, 0);
SetRect(&fullscreen_rect, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
SetRect(&fullscreen_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
SetRect(&s, 0, 0, 640, 480);
hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
......@@ -2559,7 +2561,7 @@ done:
static void test_coop_level_mode_set_multi(void)
{
IDirectDraw *ddraw1, *ddraw2;
UINT orig_w, orig_h, w, h;
UINT w, h;
HWND window;
HRESULT hr;
ULONG ref;
......@@ -2569,9 +2571,6 @@ static void test_coop_level_mode_set_multi(void)
ddraw1 = create_ddraw();
ok(!!ddraw1, "Failed to create a ddraw object.\n");
orig_w = GetSystemMetrics(SM_CXSCREEN);
orig_h = GetSystemMetrics(SM_CYSCREEN);
/* With just a single ddraw object, the display mode is restored on
* release. */
hr = set_display_mode(ddraw1, 800, 600);
......@@ -2591,9 +2590,9 @@ static void test_coop_level_mode_set_multi(void)
ref = IDirectDraw_Release(ddraw1);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
ok(w == orig_w, "Got unexpected screen width %u.\n", w);
ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
ok(h == orig_h, "Got unexpected screen height %u.\n", h);
ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
/* When there are multiple ddraw objects, the display mode is restored to
* the initial mode, before the first SetDisplayMode() call. */
......@@ -2616,16 +2615,16 @@ static void test_coop_level_mode_set_multi(void)
ref = IDirectDraw_Release(ddraw2);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
ok(w == orig_w, "Got unexpected screen width %u.\n", w);
ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
ok(h == orig_h, "Got unexpected screen height %u.\n", h);
ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
ref = IDirectDraw_Release(ddraw1);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
ok(w == orig_w, "Got unexpected screen width %u.\n", w);
ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
ok(h == orig_h, "Got unexpected screen height %u.\n", h);
ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
/* Regardless of release ordering. */
ddraw1 = create_ddraw();
......@@ -2647,16 +2646,16 @@ static void test_coop_level_mode_set_multi(void)
ref = IDirectDraw_Release(ddraw1);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
ok(w == orig_w, "Got unexpected screen width %u.\n", w);
ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
ok(h == orig_h, "Got unexpected screen height %u.\n", h);
ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
ref = IDirectDraw_Release(ddraw2);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
ok(w == orig_w, "Got unexpected screen width %u.\n", w);
ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
ok(h == orig_h, "Got unexpected screen height %u.\n", h);
ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
/* But only for ddraw objects that called SetDisplayMode(). */
ddraw1 = create_ddraw();
......@@ -2678,9 +2677,9 @@ static void test_coop_level_mode_set_multi(void)
ref = IDirectDraw_Release(ddraw2);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
ok(w == orig_w, "Got unexpected screen width %u.\n", w);
ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
ok(h == orig_h, "Got unexpected screen height %u.\n", h);
ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
/* If there's a ddraw object that's currently in exclusive mode, it blocks
* restoring the display mode. */
......@@ -2713,9 +2712,9 @@ static void test_coop_level_mode_set_multi(void)
ref = IDirectDraw_Release(ddraw2);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
ok(w == orig_w, "Got unexpected screen width %u.\n", w);
ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
ok(h == orig_h, "Got unexpected screen height %u.\n", h);
ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
/* Exclusive mode blocks mode setting on other ddraw objects in general. */
ddraw1 = create_ddraw();
......@@ -2736,16 +2735,16 @@ static void test_coop_level_mode_set_multi(void)
ref = IDirectDraw_Release(ddraw1);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
ok(w == orig_w, "Got unexpected screen width %u.\n", w);
ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
ok(h == orig_h, "Got unexpected screen height %u.\n", h);
ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
ref = IDirectDraw_Release(ddraw2);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
ok(w == orig_w, "Got unexpected screen width %u.\n", w);
ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
ok(h == orig_h, "Got unexpected screen height %u.\n", h);
ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
DestroyWindow(window);
}
......@@ -4217,8 +4216,8 @@ static void test_surface_attachment(void)
surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
surface_desc.dwWidth = GetSystemMetrics(SM_CXSCREEN);
surface_desc.dwHeight = GetSystemMetrics(SM_CYSCREEN);
surface_desc.dwWidth = registry_mode.dmPelsWidth;
surface_desc.dwHeight = registry_mode.dmPelsHeight;
hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface2, NULL);
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
......@@ -4226,8 +4225,8 @@ static void test_surface_attachment(void)
surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
surface_desc.dwWidth = GetSystemMetrics(SM_CXSCREEN);
surface_desc.dwHeight = GetSystemMetrics(SM_CYSCREEN);
surface_desc.dwWidth = registry_mode.dmPelsWidth;
surface_desc.dwHeight = registry_mode.dmPelsHeight;
hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface3, NULL);
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
......@@ -5635,6 +5634,7 @@ static void test_surface_desc_lock(void)
START_TEST(ddraw1)
{
IDirectDraw *ddraw;
DEVMODEW current_mode;
if (!(ddraw = create_ddraw()))
{
......@@ -5643,6 +5643,18 @@ START_TEST(ddraw1)
}
IDirectDraw_Release(ddraw);
memset(&current_mode, 0, sizeof(current_mode));
current_mode.dmSize = sizeof(current_mode);
ok(EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &current_mode), "Failed to get display mode.\n");
registry_mode.dmSize = sizeof(registry_mode);
ok(EnumDisplaySettingsW(NULL, ENUM_REGISTRY_SETTINGS, &registry_mode), "Failed to get display mode.\n");
if (registry_mode.dmPelsWidth != current_mode.dmPelsWidth
|| registry_mode.dmPelsHeight != current_mode.dmPelsHeight)
{
skip("Current mode does not match registry mode, skipping test.\n");
return;
}
test_coop_level_create_device_window();
test_clipper_blt();
test_coop_level_d3d_state();
......
......@@ -21,6 +21,8 @@
#include "wine/test.h"
#include "d3d.h"
static DEVMODEW registry_mode;
struct create_window_thread_param
{
HWND window;
......@@ -2195,7 +2197,7 @@ static void test_window_style(void)
style = GetWindowLongA(window, GWL_STYLE);
exstyle = GetWindowLongA(window, GWL_EXSTYLE);
SetRect(&fullscreen_rect, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
SetRect(&fullscreen_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
......@@ -2341,7 +2343,7 @@ static void test_coop_level_mode_set(void)
window2 = CreateWindowA("ddraw_test_wndproc_wc2", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, 100, 100, 0, 0, 0, 0);
SetRect(&fullscreen_rect, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
SetRect(&fullscreen_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
SetRect(&s, 0, 0, 640, 480);
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
......@@ -2854,7 +2856,7 @@ done:
static void test_coop_level_mode_set_multi(void)
{
IDirectDraw2 *ddraw1, *ddraw2;
UINT orig_w, orig_h, w, h;
UINT w, h;
HWND window;
HRESULT hr;
ULONG ref;
......@@ -2864,9 +2866,6 @@ static void test_coop_level_mode_set_multi(void)
ddraw1 = create_ddraw();
ok(!!ddraw1, "Failed to create a ddraw object.\n");
orig_w = GetSystemMetrics(SM_CXSCREEN);
orig_h = GetSystemMetrics(SM_CYSCREEN);
/* With just a single ddraw object, the display mode is restored on
* release. */
hr = set_display_mode(ddraw1, 800, 600);
......@@ -2886,9 +2885,9 @@ static void test_coop_level_mode_set_multi(void)
ref = IDirectDraw2_Release(ddraw1);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
ok(w == orig_w, "Got unexpected screen width %u.\n", w);
ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
ok(h == orig_h, "Got unexpected screen height %u.\n", h);
ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
/* When there are multiple ddraw objects, the display mode is restored to
* the initial mode, before the first SetDisplayMode() call. */
......@@ -2911,16 +2910,16 @@ static void test_coop_level_mode_set_multi(void)
ref = IDirectDraw2_Release(ddraw2);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
ok(w == orig_w, "Got unexpected screen width %u.\n", w);
ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
ok(h == orig_h, "Got unexpected screen height %u.\n", h);
ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
ref = IDirectDraw2_Release(ddraw1);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
ok(w == orig_w, "Got unexpected screen width %u.\n", w);
ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
ok(h == orig_h, "Got unexpected screen height %u.\n", h);
ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
/* Regardless of release ordering. */
ddraw1 = create_ddraw();
......@@ -2942,16 +2941,16 @@ static void test_coop_level_mode_set_multi(void)
ref = IDirectDraw2_Release(ddraw1);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
ok(w == orig_w, "Got unexpected screen width %u.\n", w);
ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
ok(h == orig_h, "Got unexpected screen height %u.\n", h);
ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
ref = IDirectDraw2_Release(ddraw2);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
ok(w == orig_w, "Got unexpected screen width %u.\n", w);
ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
ok(h == orig_h, "Got unexpected screen height %u.\n", h);
ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
/* But only for ddraw objects that called SetDisplayMode(). */
ddraw1 = create_ddraw();
......@@ -2973,9 +2972,9 @@ static void test_coop_level_mode_set_multi(void)
ref = IDirectDraw2_Release(ddraw2);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
ok(w == orig_w, "Got unexpected screen width %u.\n", w);
ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
ok(h == orig_h, "Got unexpected screen height %u.\n", h);
ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
/* If there's a ddraw object that's currently in exclusive mode, it blocks
* restoring the display mode. */
......@@ -3008,9 +3007,9 @@ static void test_coop_level_mode_set_multi(void)
ref = IDirectDraw2_Release(ddraw2);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
ok(w == orig_w, "Got unexpected screen width %u.\n", w);
ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
ok(h == orig_h, "Got unexpected screen height %u.\n", h);
ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
/* Exclusive mode blocks mode setting on other ddraw objects in general. */
ddraw1 = create_ddraw();
......@@ -3031,16 +3030,16 @@ static void test_coop_level_mode_set_multi(void)
ref = IDirectDraw2_Release(ddraw1);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
ok(w == orig_w, "Got unexpected screen width %u.\n", w);
ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
ok(h == orig_h, "Got unexpected screen height %u.\n", h);
ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
ref = IDirectDraw2_Release(ddraw2);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
ok(w == orig_w, "Got unexpected screen width %u.\n", w);
ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
ok(h == orig_h, "Got unexpected screen height %u.\n", h);
ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
DestroyWindow(window);
}
......@@ -5293,8 +5292,8 @@ static void test_surface_attachment(void)
surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
surface_desc.dwWidth = GetSystemMetrics(SM_CXSCREEN);
surface_desc.dwHeight = GetSystemMetrics(SM_CYSCREEN);
surface_desc.dwWidth = registry_mode.dmPelsWidth;
surface_desc.dwHeight = registry_mode.dmPelsHeight;
hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface2, NULL);
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
......@@ -5302,8 +5301,8 @@ static void test_surface_attachment(void)
surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
surface_desc.dwWidth = GetSystemMetrics(SM_CXSCREEN);
surface_desc.dwHeight = GetSystemMetrics(SM_CYSCREEN);
surface_desc.dwWidth = registry_mode.dmPelsWidth;
surface_desc.dwHeight = registry_mode.dmPelsHeight;
hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface3, NULL);
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
......@@ -6711,6 +6710,7 @@ static void test_surface_desc_lock(void)
START_TEST(ddraw2)
{
IDirectDraw2 *ddraw;
DEVMODEW current_mode;
if (!(ddraw = create_ddraw()))
{
......@@ -6719,6 +6719,18 @@ START_TEST(ddraw2)
}
IDirectDraw2_Release(ddraw);
memset(&current_mode, 0, sizeof(current_mode));
current_mode.dmSize = sizeof(current_mode);
ok(EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &current_mode), "Failed to get display mode.\n");
registry_mode.dmSize = sizeof(registry_mode);
ok(EnumDisplaySettingsW(NULL, ENUM_REGISTRY_SETTINGS, &registry_mode), "Failed to get display mode.\n");
if (registry_mode.dmPelsWidth != current_mode.dmPelsWidth
|| registry_mode.dmPelsHeight != current_mode.dmPelsHeight)
{
skip("Current mode does not match registry mode, skipping test.\n");
return;
}
test_coop_level_create_device_window();
test_clipper_blt();
test_coop_level_d3d_state();
......
......@@ -22,6 +22,8 @@
#include <limits.h>
#include "d3d.h"
static DEVMODEW registry_mode;
struct vec2
{
float x, y;
......@@ -2382,7 +2384,7 @@ static void test_window_style(void)
style = GetWindowLongA(window, GWL_STYLE);
exstyle = GetWindowLongA(window, GWL_EXSTYLE);
SetRect(&fullscreen_rect, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
SetRect(&fullscreen_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
......@@ -2528,7 +2530,7 @@ static void test_coop_level_mode_set(void)
window2 = CreateWindowA("ddraw_test_wndproc_wc2", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, 100, 100, 0, 0, 0, 0);
SetRect(&fullscreen_rect, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
SetRect(&fullscreen_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
SetRect(&s, 0, 0, 640, 480);
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
......@@ -3033,7 +3035,7 @@ static void test_coop_level_mode_set(void)
static void test_coop_level_mode_set_multi(void)
{
IDirectDraw4 *ddraw1, *ddraw2;
UINT orig_w, orig_h, w, h;
UINT w, h;
HWND window;
HRESULT hr;
ULONG ref;
......@@ -3043,9 +3045,6 @@ static void test_coop_level_mode_set_multi(void)
ddraw1 = create_ddraw();
ok(!!ddraw1, "Failed to create a ddraw object.\n");
orig_w = GetSystemMetrics(SM_CXSCREEN);
orig_h = GetSystemMetrics(SM_CYSCREEN);
/* With just a single ddraw object, the display mode is restored on
* release. */
hr = set_display_mode(ddraw1, 800, 600);
......@@ -3058,9 +3057,9 @@ static void test_coop_level_mode_set_multi(void)
ref = IDirectDraw4_Release(ddraw1);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
ok(w == orig_w, "Got unexpected screen width %u.\n", w);
ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
ok(h == orig_h, "Got unexpected screen height %u.\n", h);
ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
/* When there are multiple ddraw objects, the display mode is restored to
* the initial mode, before the first SetDisplayMode() call. */
......@@ -3083,16 +3082,16 @@ static void test_coop_level_mode_set_multi(void)
ref = IDirectDraw4_Release(ddraw2);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
ok(w == orig_w, "Got unexpected screen width %u.\n", w);
ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
ok(h == orig_h, "Got unexpected screen height %u.\n", h);
ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
ref = IDirectDraw4_Release(ddraw1);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
ok(w == orig_w, "Got unexpected screen width %u.\n", w);
ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
ok(h == orig_h, "Got unexpected screen height %u.\n", h);
ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
/* Regardless of release ordering. */
ddraw1 = create_ddraw();
......@@ -3114,16 +3113,16 @@ static void test_coop_level_mode_set_multi(void)
ref = IDirectDraw4_Release(ddraw1);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
ok(w == orig_w, "Got unexpected screen width %u.\n", w);
ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
ok(h == orig_h, "Got unexpected screen height %u.\n", h);
ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
ref = IDirectDraw4_Release(ddraw2);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
ok(w == orig_w, "Got unexpected screen width %u.\n", w);
ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
ok(h == orig_h, "Got unexpected screen height %u.\n", h);
ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
/* But only for ddraw objects that called SetDisplayMode(). */
ddraw1 = create_ddraw();
......@@ -3145,9 +3144,9 @@ static void test_coop_level_mode_set_multi(void)
ref = IDirectDraw4_Release(ddraw2);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
ok(w == orig_w, "Got unexpected screen width %u.\n", w);
ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
ok(h == orig_h, "Got unexpected screen height %u.\n", h);
ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
/* If there's a ddraw object that's currently in exclusive mode, it blocks
* restoring the display mode. */
......@@ -3180,9 +3179,9 @@ static void test_coop_level_mode_set_multi(void)
ref = IDirectDraw4_Release(ddraw2);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
ok(w == orig_w, "Got unexpected screen width %u.\n", w);
ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
ok(h == orig_h, "Got unexpected screen height %u.\n", h);
ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
/* Exclusive mode blocks mode setting on other ddraw objects in general. */
ddraw1 = create_ddraw();
......@@ -3203,16 +3202,16 @@ static void test_coop_level_mode_set_multi(void)
ref = IDirectDraw4_Release(ddraw1);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
ok(w == orig_w, "Got unexpected screen width %u.\n", w);
ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
ok(h == orig_h, "Got unexpected screen height %u.\n", h);
ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
ref = IDirectDraw4_Release(ddraw2);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
ok(w == orig_w, "Got unexpected screen width %u.\n", w);
ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
ok(h == orig_h, "Got unexpected screen height %u.\n", h);
ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
DestroyWindow(window);
}
......@@ -6075,8 +6074,8 @@ static void test_surface_attachment(void)
surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
surface_desc.dwWidth = GetSystemMetrics(SM_CXSCREEN);
surface_desc.dwHeight = GetSystemMetrics(SM_CYSCREEN);
surface_desc.dwWidth = registry_mode.dmPelsWidth;
surface_desc.dwHeight = registry_mode.dmPelsHeight;
hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface2, NULL);
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
......@@ -6084,8 +6083,8 @@ static void test_surface_attachment(void)
surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
surface_desc.dwWidth = GetSystemMetrics(SM_CXSCREEN);
surface_desc.dwHeight = GetSystemMetrics(SM_CYSCREEN);
surface_desc.dwWidth = registry_mode.dmPelsWidth;
surface_desc.dwHeight = registry_mode.dmPelsHeight;
hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface3, NULL);
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
......@@ -7786,6 +7785,7 @@ static void test_surface_desc_lock(void)
START_TEST(ddraw4)
{
IDirectDraw4 *ddraw;
DEVMODEW current_mode;
if (!(ddraw = create_ddraw()))
{
......@@ -7794,6 +7794,18 @@ START_TEST(ddraw4)
}
IDirectDraw4_Release(ddraw);
memset(&current_mode, 0, sizeof(current_mode));
current_mode.dmSize = sizeof(current_mode);
ok(EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &current_mode), "Failed to get display mode.\n");
registry_mode.dmSize = sizeof(registry_mode);
ok(EnumDisplaySettingsW(NULL, ENUM_REGISTRY_SETTINGS, &registry_mode), "Failed to get display mode.\n");
if (registry_mode.dmPelsWidth != current_mode.dmPelsWidth
|| registry_mode.dmPelsHeight != current_mode.dmPelsHeight)
{
skip("Current mode does not match registry mode, skipping test.\n");
return;
}
test_process_vertices();
test_coop_level_create_device_window();
test_clipper_blt();
......
......@@ -23,6 +23,7 @@
#include "d3d.h"
static HRESULT (WINAPI *pDirectDrawCreateEx)(GUID *guid, void **ddraw, REFIID iid, IUnknown *outer_unknown);
static DEVMODEW registry_mode;
struct vec2
{
......@@ -2061,7 +2062,7 @@ static void test_window_style(void)
style = GetWindowLongA(window, GWL_STYLE);
exstyle = GetWindowLongA(window, GWL_EXSTYLE);
SetRect(&fullscreen_rect, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
SetRect(&fullscreen_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
......@@ -2206,7 +2207,7 @@ static void test_coop_level_mode_set(void)
window2 = CreateWindowA("ddraw_test_wndproc_wc2", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, 100, 100, 0, 0, 0, 0);
SetRect(&fullscreen_rect, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
SetRect(&fullscreen_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
SetRect(&s, 0, 0, 640, 480);
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
......@@ -2711,7 +2712,7 @@ static void test_coop_level_mode_set(void)
static void test_coop_level_mode_set_multi(void)
{
IDirectDraw7 *ddraw1, *ddraw2;
UINT orig_w, orig_h, w, h;
UINT w, h;
HWND window;
HRESULT hr;
ULONG ref;
......@@ -2721,9 +2722,6 @@ static void test_coop_level_mode_set_multi(void)
ddraw1 = create_ddraw();
ok(!!ddraw1, "Failed to create a ddraw object.\n");
orig_w = GetSystemMetrics(SM_CXSCREEN);
orig_h = GetSystemMetrics(SM_CYSCREEN);
/* With just a single ddraw object, the display mode is restored on
* release. */
hr = set_display_mode(ddraw1, 800, 600);
......@@ -2736,9 +2734,9 @@ static void test_coop_level_mode_set_multi(void)
ref = IDirectDraw7_Release(ddraw1);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
ok(w == orig_w, "Got unexpected screen width %u.\n", w);
ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
ok(h == orig_h, "Got unexpected screen height %u.\n", h);
ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
/* When there are multiple ddraw objects, the display mode is restored to
* the initial mode, before the first SetDisplayMode() call. */
......@@ -2761,16 +2759,16 @@ static void test_coop_level_mode_set_multi(void)
ref = IDirectDraw7_Release(ddraw2);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
ok(w == orig_w, "Got unexpected screen width %u.\n", w);
ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
ok(h == orig_h, "Got unexpected screen height %u.\n", h);
ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
ref = IDirectDraw7_Release(ddraw1);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
ok(w == orig_w, "Got unexpected screen width %u.\n", w);
ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
ok(h == orig_h, "Got unexpected screen height %u.\n", h);
ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
/* Regardless of release ordering. */
ddraw1 = create_ddraw();
......@@ -2792,16 +2790,16 @@ static void test_coop_level_mode_set_multi(void)
ref = IDirectDraw7_Release(ddraw1);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
ok(w == orig_w, "Got unexpected screen width %u.\n", w);
ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
ok(h == orig_h, "Got unexpected screen height %u.\n", h);
ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
ref = IDirectDraw7_Release(ddraw2);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
ok(w == orig_w, "Got unexpected screen width %u.\n", w);
ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
ok(h == orig_h, "Got unexpected screen height %u.\n", h);
ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
/* But only for ddraw objects that called SetDisplayMode(). */
ddraw1 = create_ddraw();
......@@ -2823,9 +2821,9 @@ static void test_coop_level_mode_set_multi(void)
ref = IDirectDraw7_Release(ddraw2);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
ok(w == orig_w, "Got unexpected screen width %u.\n", w);
ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
ok(h == orig_h, "Got unexpected screen height %u.\n", h);
ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
/* If there's a ddraw object that's currently in exclusive mode, it blocks
* restoring the display mode. */
......@@ -2858,9 +2856,9 @@ static void test_coop_level_mode_set_multi(void)
ref = IDirectDraw7_Release(ddraw2);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
ok(w == orig_w, "Got unexpected screen width %u.\n", w);
ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
ok(h == orig_h, "Got unexpected screen height %u.\n", h);
ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
/* Exclusive mode blocks mode setting on other ddraw objects in general. */
ddraw1 = create_ddraw();
......@@ -2881,16 +2879,16 @@ static void test_coop_level_mode_set_multi(void)
ref = IDirectDraw7_Release(ddraw1);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
ok(w == orig_w, "Got unexpected screen width %u.\n", w);
ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
ok(h == orig_h, "Got unexpected screen height %u.\n", h);
ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
ref = IDirectDraw7_Release(ddraw2);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
ok(w == orig_w, "Got unexpected screen width %u.\n", w);
ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
ok(h == orig_h, "Got unexpected screen height %u.\n", h);
ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
DestroyWindow(window);
}
......@@ -5913,8 +5911,8 @@ static void test_surface_attachment(void)
surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
surface_desc.dwWidth = GetSystemMetrics(SM_CXSCREEN);
surface_desc.dwHeight = GetSystemMetrics(SM_CYSCREEN);
surface_desc.dwWidth = registry_mode.dmPelsWidth;
surface_desc.dwHeight = registry_mode.dmPelsHeight;
hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface2, NULL);
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
......@@ -5922,8 +5920,8 @@ static void test_surface_attachment(void)
surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
surface_desc.dwWidth = GetSystemMetrics(SM_CXSCREEN);
surface_desc.dwHeight = GetSystemMetrics(SM_CYSCREEN);
surface_desc.dwWidth = registry_mode.dmPelsWidth;
surface_desc.dwHeight = registry_mode.dmPelsHeight;
hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface3, NULL);
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
......@@ -7630,6 +7628,7 @@ START_TEST(ddraw7)
{
HMODULE module = GetModuleHandleA("ddraw.dll");
IDirectDraw7 *ddraw;
DEVMODEW current_mode;
if (!(pDirectDrawCreateEx = (void *)GetProcAddress(module, "DirectDrawCreateEx")))
{
......@@ -7644,6 +7643,18 @@ START_TEST(ddraw7)
}
IDirectDraw7_Release(ddraw);
memset(&current_mode, 0, sizeof(current_mode));
current_mode.dmSize = sizeof(current_mode);
ok(EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &current_mode), "Failed to get display mode.\n");
registry_mode.dmSize = sizeof(registry_mode);
ok(EnumDisplaySettingsW(NULL, ENUM_REGISTRY_SETTINGS, &registry_mode), "Failed to get display mode.\n");
if (registry_mode.dmPelsWidth != current_mode.dmPelsWidth
|| registry_mode.dmPelsHeight != current_mode.dmPelsHeight)
{
skip("Current mode does not match registry mode, skipping test.\n");
return;
}
test_process_vertices();
test_coop_level_create_device_window();
test_clipper_blt();
......
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