From f41ea4fefec76d673abb025e16e50c4007a640c3 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Sun, 27 Nov 2011 21:34:47 +0100 Subject: [PATCH] ddraw/tests: Add tests for primary dimensions to test_coop_level_mode_set(). --- dlls/ddraw/tests/d3d.c | 238 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 238 insertions(+) diff --git a/dlls/ddraw/tests/d3d.c b/dlls/ddraw/tests/d3d.c index af6ea5a933d..7ed7575b658 100644 --- a/dlls/ddraw/tests/d3d.c +++ b/dlls/ddraw/tests/d3d.c @@ -4161,8 +4161,10 @@ static LRESULT CALLBACK mode_set_proc(HWND hwnd, UINT message, WPARAM wparam, LP static void test_coop_level_mode_set(void) { + IDirectDrawSurface7 *primary; RECT fullscreen_rect, r, s; IDirectDraw7 *ddraw7; + DDSURFACEDESC2 ddsd; WNDCLASSA wc = {0}; HWND window; HRESULT hr; @@ -4211,6 +4213,25 @@ static void test_coop_level_mode_set(void) goto done; } + GetWindowRect(window, &r); + ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n", + fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom, + r.left, r.top, r.right, r.bottom); + + memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + ddsd.dwFlags = DDSD_CAPS; + ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; + + hr = IDirectDraw7_CreateSurface(ddraw7, &ddsd, &primary, NULL); + ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr); + hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd); + ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr); + ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n", + fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth); + ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n", + fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight); + GetWindowRect(window, &r); ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n", fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom, @@ -4234,6 +4255,33 @@ static void test_coop_level_mode_set(void) s.left, s.top, s.right, s.bottom, r.left, r.top, r.right, r.bottom); + hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd); + ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr); + ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n", + fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth); + ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n", + fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight); + IDirectDrawSurface7_Release(primary); + + memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + ddsd.dwFlags = DDSD_CAPS; + ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; + + hr = IDirectDraw7_CreateSurface(ddraw7, &ddsd, &primary, NULL); + ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr); + hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd); + ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr); + ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n", + s.right - s.left, ddsd.dwWidth); + ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n", + s.bottom - s.top, ddsd.dwHeight); + + GetWindowRect(window, &r); + ok(EqualRect(&r, &s), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n", + s.left, s.top, s.right, s.bottom, + r.left, r.top, r.right, r.bottom); + expect_messages = exclusive_messages; screen_size.cx = 0; screen_size.cy = 0; @@ -4252,9 +4300,63 @@ static void test_coop_level_mode_set(void) fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom, r.left, r.top, r.right, r.bottom); + hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd); + ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr); + ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n", + s.right - s.left, ddsd.dwWidth); + ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n", + s.bottom - s.top, ddsd.dwHeight); + IDirectDrawSurface7_Release(primary); + + memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + ddsd.dwFlags = DDSD_CAPS; + ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; + + hr = IDirectDraw7_CreateSurface(ddraw7, &ddsd, &primary, NULL); + ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr); + hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd); + ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr); + ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n", + fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth); + ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n", + fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight); + + GetWindowRect(window, &r); + ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n", + fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom, + r.left, r.top, r.right, r.bottom); + hr = IDirectDraw7_SetCooperativeLevel(ddraw7, window, DDSCL_NORMAL); ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr); + GetWindowRect(window, &r); + ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n", + fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom, + r.left, r.top, r.right, r.bottom); + + hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd); + ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr); + ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n", + fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth); + ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n", + fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight); + IDirectDrawSurface7_Release(primary); + + memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + ddsd.dwFlags = DDSD_CAPS; + ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; + + hr = IDirectDraw7_CreateSurface(ddraw7, &ddsd, &primary, NULL); + ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr); + hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd); + ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr); + ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n", + fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth); + ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n", + fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight); + GetWindowRect(window, &r); ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n", fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom, @@ -4271,6 +4373,33 @@ static void test_coop_level_mode_set(void) expect_messages = NULL; ok(!screen_size.cx && !screen_size.cy, "Got unxpected screen size %ux%u.\n", screen_size.cx, screen_size.cy); + GetWindowRect(window, &r); + ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n", + fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom, + r.left, r.top, r.right, r.bottom); + + hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd); + ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr); + ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n", + fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth); + ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n", + fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight); + IDirectDrawSurface7_Release(primary); + + memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + ddsd.dwFlags = DDSD_CAPS; + ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; + + hr = IDirectDraw7_CreateSurface(ddraw7, &ddsd, &primary, NULL); + ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr); + hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd); + ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr); + ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n", + s.right - s.left, ddsd.dwWidth); + ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n", + s.bottom - s.top, ddsd.dwHeight); + GetWindowRect(window, &r); ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n", fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom, @@ -4287,6 +4416,33 @@ static void test_coop_level_mode_set(void) expect_messages = NULL; ok(!screen_size.cx && !screen_size.cy, "Got unxpected screen size %ux%u.\n", screen_size.cx, screen_size.cy); + GetWindowRect(window, &r); + ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n", + fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom, + r.left, r.top, r.right, r.bottom); + + hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd); + ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr); + ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n", + s.right - s.left, ddsd.dwWidth); + ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n", + s.bottom - s.top, ddsd.dwHeight); + IDirectDrawSurface7_Release(primary); + + memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + ddsd.dwFlags = DDSD_CAPS; + ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; + + hr = IDirectDraw7_CreateSurface(ddraw7, &ddsd, &primary, NULL); + ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr); + hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd); + ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr); + ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n", + fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth); + ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n", + fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight); + GetWindowRect(window, &r); ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n", fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom, @@ -4298,6 +4454,33 @@ static void test_coop_level_mode_set(void) hr = IDirectDraw7_SetCooperativeLevel(ddraw7, window, DDSCL_NORMAL | DDSCL_FULLSCREEN); ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr); + GetWindowRect(window, &r); + ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n", + fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom, + r.left, r.top, r.right, r.bottom); + + hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd); + ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr); + ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n", + fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth); + ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n", + fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight); + IDirectDrawSurface7_Release(primary); + + memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + ddsd.dwFlags = DDSD_CAPS; + ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; + + hr = IDirectDraw7_CreateSurface(ddraw7, &ddsd, &primary, NULL); + ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr); + hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd); + ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr); + ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n", + fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth); + ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n", + fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight); + GetWindowRect(window, &r); ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n", fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom, @@ -4314,6 +4497,33 @@ static void test_coop_level_mode_set(void) expect_messages = NULL; ok(!screen_size.cx && !screen_size.cy, "Got unxpected screen size %ux%u.\n", screen_size.cx, screen_size.cy); + GetWindowRect(window, &r); + ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n", + fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom, + r.left, r.top, r.right, r.bottom); + + hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd); + ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr); + ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n", + fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth); + ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n", + fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight); + IDirectDrawSurface7_Release(primary); + + memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + ddsd.dwFlags = DDSD_CAPS; + ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; + + hr = IDirectDraw7_CreateSurface(ddraw7, &ddsd, &primary, NULL); + ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr); + hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd); + ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr); + ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n", + s.right - s.left, ddsd.dwWidth); + ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n", + s.bottom - s.top, ddsd.dwHeight); + GetWindowRect(window, &r); ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n", fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom, @@ -4330,6 +4540,34 @@ static void test_coop_level_mode_set(void) expect_messages = NULL; ok(!screen_size.cx && !screen_size.cy, "Got unxpected screen size %ux%u.\n", screen_size.cx, screen_size.cy); + GetWindowRect(window, &r); + ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n", + fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom, + r.left, r.top, r.right, r.bottom); + + hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd); + ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr); + ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n", + s.right - s.left, ddsd.dwWidth); + ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n", + s.bottom - s.top, ddsd.dwHeight); + IDirectDrawSurface7_Release(primary); + + memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + ddsd.dwFlags = DDSD_CAPS; + ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; + + hr = IDirectDraw7_CreateSurface(ddraw7, &ddsd, &primary, NULL); + ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr); + hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd); + ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr); + ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n", + fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth); + ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n", + fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight); + IDirectDrawSurface7_Release(primary); + GetWindowRect(window, &r); ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n", fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,