From 43aac32fd572982ae65a8c0a3cb7d64a87ae86cb Mon Sep 17 00:00:00 2001 From: Henri Verbeet <hverbeet@codeweavers.com> Date: Mon, 23 May 2011 22:11:33 +0200 Subject: [PATCH] ddraw/tests: Add a test for mode settings calls with different coop levels. --- dlls/ddraw/tests/d3d.c | 87 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/dlls/ddraw/tests/d3d.c b/dlls/ddraw/tests/d3d.c index 6511a2606d4..ff208c70310 100644 --- a/dlls/ddraw/tests/d3d.c +++ b/dlls/ddraw/tests/d3d.c @@ -3983,6 +3983,92 @@ static void test_redundant_mode_set(void) DestroyWindow(window); } + +static void test_coop_level_mode_set(void) +{ + RECT fullscreen_rect, r, s; + IDirectDraw7 *ddraw7; + HWND window; + HRESULT hr; + ULONG ref; + + hr = pDirectDrawCreateEx(NULL, (void **)&ddraw7, &IID_IDirectDraw7, NULL); + if (FAILED(hr)) + { + skip("Failed to create IDirectDraw7 object (%#x), skipping tests.\n", hr); + return; + } + + window = CreateWindowA("static", "d3d7_test", WS_OVERLAPPEDWINDOW, + 0, 0, 100, 100, 0, 0, 0, 0); + + SetRect(&fullscreen_rect, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN)); + SetRect(&s, 0, 0, 640, 480); + + hr = IDirectDraw7_SetCooperativeLevel(ddraw7, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); + ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr); + if (FAILED(hr)) + { + IDirectDraw7_Release(ddraw7); + DestroyWindow(window); + return; + } + + 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_SetDisplayMode(ddraw7, 640, 480, 32, 0, 0); + ok(SUCCEEDED(hr), "SetDipslayMode failed, hr %#x.\n", hr); + + 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); + + hr = IDirectDraw_RestoreDisplayMode(ddraw7); + ok(SUCCEEDED(hr), "RestoreDisplayMode 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 = IDirectDraw7_SetCooperativeLevel(ddraw7, window, DDSCL_NORMAL); + + 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_SetDisplayMode(ddraw7, 640, 480, 32, 0, 0); + ok(SUCCEEDED(hr), "SetDipslayMode failed, hr %#x.\n", hr); + + GetWindowRect(window, &r); + todo_wine 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 = IDirectDraw_RestoreDisplayMode(ddraw7); + ok(SUCCEEDED(hr), "RestoreDisplayMode 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); + + ref = IDirectDraw7_Release(ddraw7); + ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref); + + 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); + + DestroyWindow(window); +} + START_TEST(d3d) { init_function_pointers(); @@ -4026,4 +4112,5 @@ START_TEST(d3d) test_wndproc(); test_window_style(); test_redundant_mode_set(); + test_coop_level_mode_set(); } -- 2.24.1