From: Stefan Dösinger Subject: [PATCH 2/6] ddraw/tests: Test focus loss style changes. Message-Id: <1416342417-15963-2-git-send-email-stefan@codeweavers.com> Date: Tue, 18 Nov 2014 21:26:53 +0100 --- dlls/ddraw/tests/ddraw1.c | 37 ++++++++++++++++++++++++++++++++++++- dlls/ddraw/tests/ddraw2.c | 37 ++++++++++++++++++++++++++++++++++++- dlls/ddraw/tests/ddraw4.c | 37 ++++++++++++++++++++++++++++++++++++- dlls/ddraw/tests/ddraw7.c | 37 ++++++++++++++++++++++++++++++++++++- 4 files changed, 144 insertions(+), 4 deletions(-) diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c index c736f57..418e0d6 100644 --- a/dlls/ddraw/tests/ddraw1.c +++ b/dlls/ddraw/tests/ddraw1.c @@ -2009,12 +2009,13 @@ static void test_wndproc(void) static void test_window_style(void) { - LONG style, exstyle, tmp; + LONG style, exstyle, tmp, expected_style; RECT fullscreen_rect, r; IDirectDraw *ddraw; HWND window; HRESULT hr; ULONG ref; + BOOL ret; window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW, 0, 0, 100, 100, 0, 0, 0, 0); @@ -2040,6 +2041,20 @@ static void test_window_style(void) GetClientRect(window, &r); todo_wine ok(!EqualRect(&r, &fullscreen_rect), "Client rect and window rect are equal.\n"); + ret = SetForegroundWindow(GetDesktopWindow()); + ok(ret, "Failed to set foreground window.\n"); + + tmp = GetWindowLongA(window, GWL_STYLE); + todo_wine ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp); + tmp = GetWindowLongA(window, GWL_EXSTYLE); + todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp); + + ret = SetForegroundWindow(window); + ok(ret, "Failed to set foreground window.\n"); + /* Windows 7 (but not Vista and XP) show the window when it receives focus. Hide it again, + * the next tests expect this. */ + ShowWindow(window, SW_HIDE); + hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL); ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr); @@ -2048,6 +2063,26 @@ static void test_window_style(void) tmp = GetWindowLongA(window, GWL_EXSTYLE); todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp); + ShowWindow(window, SW_SHOW); + hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); + ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr); + + tmp = GetWindowLongA(window, GWL_STYLE); + expected_style = style | WS_VISIBLE; + todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp); + tmp = GetWindowLongA(window, GWL_EXSTYLE); + expected_style = exstyle | WS_EX_TOPMOST; + todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp); + + ret = SetForegroundWindow(GetDesktopWindow()); + ok(ret, "Failed to set foreground window.\n"); + tmp = GetWindowLongA(window, GWL_STYLE); + expected_style = style | WS_VISIBLE | WS_MINIMIZE; + todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp); + tmp = GetWindowLongA(window, GWL_EXSTYLE); + expected_style = exstyle | WS_EX_TOPMOST; + todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp); + ref = IDirectDraw_Release(ddraw); ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref); diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c index 0a7b27e..84a05ee 100644 --- a/dlls/ddraw/tests/ddraw2.c +++ b/dlls/ddraw/tests/ddraw2.c @@ -2197,12 +2197,13 @@ static void test_wndproc(void) static void test_window_style(void) { - LONG style, exstyle, tmp; + LONG style, exstyle, tmp, expected_style; RECT fullscreen_rect, r; IDirectDraw2 *ddraw; HWND window; HRESULT hr; ULONG ref; + BOOL ret; window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW, 0, 0, 100, 100, 0, 0, 0, 0); @@ -2228,6 +2229,20 @@ static void test_window_style(void) GetClientRect(window, &r); todo_wine ok(!EqualRect(&r, &fullscreen_rect), "Client rect and window rect are equal.\n"); + ret = SetForegroundWindow(GetDesktopWindow()); + ok(ret, "Failed to set foreground window.\n"); + + tmp = GetWindowLongA(window, GWL_STYLE); + todo_wine ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp); + tmp = GetWindowLongA(window, GWL_EXSTYLE); + todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp); + + ret = SetForegroundWindow(window); + ok(ret, "Failed to set foreground window.\n"); + /* Windows 7 (but not Vista and XP) show the window when it receives focus. Hide it again, + * the next tests expect this. */ + ShowWindow(window, SW_HIDE); + hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL); ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr); @@ -2236,6 +2251,26 @@ static void test_window_style(void) tmp = GetWindowLongA(window, GWL_EXSTYLE); todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp); + ShowWindow(window, SW_SHOW); + hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); + ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr); + + tmp = GetWindowLongA(window, GWL_STYLE); + expected_style = style | WS_VISIBLE; + todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp); + tmp = GetWindowLongA(window, GWL_EXSTYLE); + expected_style = exstyle | WS_EX_TOPMOST; + todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp); + + ret = SetForegroundWindow(GetDesktopWindow()); + ok(ret, "Failed to set foreground window.\n"); + tmp = GetWindowLongA(window, GWL_STYLE); + expected_style = style | WS_VISIBLE | WS_MINIMIZE; + todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp); + tmp = GetWindowLongA(window, GWL_EXSTYLE); + expected_style = exstyle | WS_EX_TOPMOST; + todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp); + ref = IDirectDraw2_Release(ddraw); ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref); diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c index f34f728..ac6a787 100644 --- a/dlls/ddraw/tests/ddraw4.c +++ b/dlls/ddraw/tests/ddraw4.c @@ -2384,12 +2384,13 @@ static void test_wndproc(void) static void test_window_style(void) { - LONG style, exstyle, tmp; + LONG style, exstyle, tmp, expected_style; RECT fullscreen_rect, r; IDirectDraw4 *ddraw; HWND window; HRESULT hr; ULONG ref; + BOOL ret; window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW, 0, 0, 100, 100, 0, 0, 0, 0); @@ -2415,6 +2416,20 @@ static void test_window_style(void) GetClientRect(window, &r); todo_wine ok(!EqualRect(&r, &fullscreen_rect), "Client rect and window rect are equal.\n"); + ret = SetForegroundWindow(GetDesktopWindow()); + ok(ret, "Failed to set foreground window.\n"); + + tmp = GetWindowLongA(window, GWL_STYLE); + todo_wine ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp); + tmp = GetWindowLongA(window, GWL_EXSTYLE); + todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp); + + ret = SetForegroundWindow(window); + ok(ret, "Failed to set foreground window.\n"); + /* Windows 7 (but not Vista and XP) show the window when it receives focus. Hide it again, + * the next tests expect this. */ + ShowWindow(window, SW_HIDE); + hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL); ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr); @@ -2423,6 +2438,26 @@ static void test_window_style(void) tmp = GetWindowLongA(window, GWL_EXSTYLE); todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp); + ShowWindow(window, SW_SHOW); + hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); + ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr); + + tmp = GetWindowLongA(window, GWL_STYLE); + expected_style = style | WS_VISIBLE; + todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp); + tmp = GetWindowLongA(window, GWL_EXSTYLE); + expected_style = exstyle | WS_EX_TOPMOST; + todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp); + + ret = SetForegroundWindow(GetDesktopWindow()); + ok(ret, "Failed to set foreground window.\n"); + tmp = GetWindowLongA(window, GWL_STYLE); + expected_style = style | WS_VISIBLE | WS_MINIMIZE; + todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp); + tmp = GetWindowLongA(window, GWL_EXSTYLE); + expected_style = exstyle | WS_EX_TOPMOST; + todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp); + ref = IDirectDraw4_Release(ddraw); ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref); diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c index 62eedf0..98e171e 100644 --- a/dlls/ddraw/tests/ddraw7.c +++ b/dlls/ddraw/tests/ddraw7.c @@ -2062,12 +2062,13 @@ static void test_wndproc(void) static void test_window_style(void) { - LONG style, exstyle, tmp; + LONG style, exstyle, tmp, expected_style; RECT fullscreen_rect, r; IDirectDraw7 *ddraw; HWND window; HRESULT hr; ULONG ref; + BOOL ret; window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW, 0, 0, 100, 100, 0, 0, 0, 0); @@ -2093,6 +2094,20 @@ static void test_window_style(void) GetClientRect(window, &r); todo_wine ok(!EqualRect(&r, &fullscreen_rect), "Client rect and window rect are equal.\n"); + ret = SetForegroundWindow(GetDesktopWindow()); + ok(ret, "Failed to set foreground window.\n"); + + tmp = GetWindowLongA(window, GWL_STYLE); + todo_wine ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp); + tmp = GetWindowLongA(window, GWL_EXSTYLE); + todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp); + + ret = SetForegroundWindow(window); + ok(ret, "Failed to set foreground window.\n"); + /* Windows 7 (but not Vista and XP) show the window when it receives focus. Hide it again, + * the next tests expect this. */ + ShowWindow(window, SW_HIDE); + hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL); ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr); @@ -2101,6 +2116,26 @@ static void test_window_style(void) tmp = GetWindowLongA(window, GWL_EXSTYLE); todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp); + ShowWindow(window, SW_SHOW); + hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); + ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr); + + tmp = GetWindowLongA(window, GWL_STYLE); + expected_style = style | WS_VISIBLE; + todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp); + tmp = GetWindowLongA(window, GWL_EXSTYLE); + expected_style = exstyle | WS_EX_TOPMOST; + todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp); + + ret = SetForegroundWindow(GetDesktopWindow()); + ok(ret, "Failed to set foreground window.\n"); + tmp = GetWindowLongA(window, GWL_STYLE); + expected_style = style | WS_VISIBLE | WS_MINIMIZE; + todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp); + tmp = GetWindowLongA(window, GWL_EXSTYLE); + expected_style = exstyle | WS_EX_TOPMOST; + todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp); + ref = IDirectDraw7_Release(ddraw); ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref); -- 2.0.4