Module: wine Branch: master Commit: a87c1d251ed0b67a409806df9e5175bd3b5aa23e URL: https://gitlab.winehq.org/wine/wine/-/commit/a87c1d251ed0b67a409806df9e5175b...
Author: Zhiyi Zhang zzhang@codeweavers.com Date: Tue Sep 19 12:14:02 2023 +0800
ddraw/tests: Test WS_EX_TOPMOST restoration.
Test that there is a ~1.5s timer after entering fullscreen mode and restores WS_EX_TOPMOST if it's missing when the timer times out.
---
dlls/ddraw/tests/ddraw1.c | 30 ++++++++++++++++++++++++++++++ dlls/ddraw/tests/ddraw2.c | 30 ++++++++++++++++++++++++++++++ dlls/ddraw/tests/ddraw4.c | 30 ++++++++++++++++++++++++++++++ dlls/ddraw/tests/ddraw7.c | 30 ++++++++++++++++++++++++++++++ 4 files changed, 120 insertions(+)
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c index 453425ac2f9..e7483c30863 100644 --- a/dlls/ddraw/tests/ddraw1.c +++ b/dlls/ddraw/tests/ddraw1.c @@ -2779,6 +2779,36 @@ static void test_window_style(void) expected_style = exstyle | WS_EX_TOPMOST; todo_wine ok(tmp == expected_style, "Expected window extended style %#lx, got %#lx.\n", expected_style, tmp);
+ /* Test that there is a ~1.5s timer that checks and restores WS_EX_TOPMOST if it's missing */ + ret = ShowWindow(window, SW_RESTORE); + ok(ret, "ShowWindow failed, error %#lx.\n", GetLastError()); + hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); + ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr); + flush_events(); + + /* Remove WS_VISIBLE and WS_EX_TOPMOST */ + tmp = GetWindowLongA(window, GWL_STYLE); + ok(tmp & WS_VISIBLE, "Expected WS_VISIBLE.\n"); + tmp = GetWindowLongA(window, GWL_EXSTYLE); + ok(tmp & WS_EX_TOPMOST, "Expected WS_EX_TOPMOST.\n"); + ret = ShowWindow(window, SW_HIDE); + ok(ret, "ShowWindow failed, error %#lx.\n", GetLastError()); + ret = SetWindowPos(window, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); + ok(ret, "SetWindowPos failed, error %#lx.\n", GetLastError()); + tmp = GetWindowLongA(window, GWL_STYLE); + ok(!(tmp & WS_VISIBLE), "Got unexpected WS_VISIBLE.\n"); + tmp = GetWindowLongA(window, GWL_EXSTYLE); + ok(!(tmp & WS_EX_TOPMOST), "Got unexpected WS_EX_TOPMOST.\n"); + + Sleep(2000); + flush_events(); + + /* WS_VISIBLE is not restored but WS_EX_TOPMOST is */ + tmp = GetWindowLongA(window, GWL_STYLE); + ok(!(tmp & WS_VISIBLE), "Got unexpected WS_VISIBLE.\n"); + tmp = GetWindowLongA(window, GWL_EXSTYLE); + todo_wine ok(tmp & WS_EX_TOPMOST, "Expected WS_EX_TOPMOST.\n"); + ref = IDirectDraw_Release(ddraw); ok(!ref, "Unexpected refcount %lu.\n", ref);
diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c index 22a4033500c..b51ebff0006 100644 --- a/dlls/ddraw/tests/ddraw2.c +++ b/dlls/ddraw/tests/ddraw2.c @@ -2865,6 +2865,36 @@ static void test_window_style(void) expected_style = exstyle | WS_EX_TOPMOST; todo_wine ok(tmp == expected_style, "Expected window extended style %#lx, got %#lx.\n", expected_style, tmp);
+ /* Test that there is a ~1.5s timer that checks and restores WS_EX_TOPMOST if it's missing */ + ret = ShowWindow(window, SW_RESTORE); + ok(ret, "ShowWindow failed, error %#lx.\n", GetLastError()); + hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); + ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr); + flush_events(); + + /* Remove WS_VISIBLE and WS_EX_TOPMOST */ + tmp = GetWindowLongA(window, GWL_STYLE); + ok(tmp & WS_VISIBLE, "Expected WS_VISIBLE.\n"); + tmp = GetWindowLongA(window, GWL_EXSTYLE); + ok(tmp & WS_EX_TOPMOST, "Expected WS_EX_TOPMOST.\n"); + ret = ShowWindow(window, SW_HIDE); + ok(ret, "ShowWindow failed, error %#lx.\n", GetLastError()); + ret = SetWindowPos(window, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); + ok(ret, "SetWindowPos failed, error %#lx.\n", GetLastError()); + tmp = GetWindowLongA(window, GWL_STYLE); + ok(!(tmp & WS_VISIBLE), "Got unexpected WS_VISIBLE.\n"); + tmp = GetWindowLongA(window, GWL_EXSTYLE); + ok(!(tmp & WS_EX_TOPMOST), "Got unexpected WS_EX_TOPMOST.\n"); + + Sleep(2000); + flush_events(); + + /* WS_VISIBLE is not restored but WS_EX_TOPMOST is */ + tmp = GetWindowLongA(window, GWL_STYLE); + ok(!(tmp & WS_VISIBLE), "Got unexpected WS_VISIBLE.\n"); + tmp = GetWindowLongA(window, GWL_EXSTYLE); + todo_wine ok(tmp & WS_EX_TOPMOST, "Expected WS_EX_TOPMOST.\n"); + ref = IDirectDraw2_Release(ddraw); ok(!ref, "Unexpected refcount %lu.\n", ref);
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c index 3e951480bbe..0b1eb1e197b 100644 --- a/dlls/ddraw/tests/ddraw4.c +++ b/dlls/ddraw/tests/ddraw4.c @@ -3103,6 +3103,36 @@ static void test_window_style(void) expected_style = exstyle | WS_EX_TOPMOST; todo_wine ok(tmp == expected_style, "Expected window extended style %#lx, got %#lx.\n", expected_style, tmp);
+ /* Test that there is a ~1.5s timer that checks and restores WS_EX_TOPMOST if it's missing */ + ret = ShowWindow(window, SW_RESTORE); + ok(ret, "ShowWindow failed, error %#lx.\n", GetLastError()); + hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); + ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr); + flush_events(); + + /* Remove WS_VISIBLE and WS_EX_TOPMOST */ + tmp = GetWindowLongA(window, GWL_STYLE); + ok(tmp & WS_VISIBLE, "Expected WS_VISIBLE.\n"); + tmp = GetWindowLongA(window, GWL_EXSTYLE); + ok(tmp & WS_EX_TOPMOST, "Expected WS_EX_TOPMOST.\n"); + ret = ShowWindow(window, SW_HIDE); + ok(ret, "ShowWindow failed, error %#lx.\n", GetLastError()); + ret = SetWindowPos(window, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); + ok(ret, "SetWindowPos failed, error %#lx.\n", GetLastError()); + tmp = GetWindowLongA(window, GWL_STYLE); + ok(!(tmp & WS_VISIBLE), "Got unexpected WS_VISIBLE.\n"); + tmp = GetWindowLongA(window, GWL_EXSTYLE); + ok(!(tmp & WS_EX_TOPMOST), "Got unexpected WS_EX_TOPMOST.\n"); + + Sleep(2000); + flush_events(); + + /* WS_VISIBLE is not restored but WS_EX_TOPMOST is */ + tmp = GetWindowLongA(window, GWL_STYLE); + ok(!(tmp & WS_VISIBLE), "Got unexpected WS_VISIBLE.\n"); + tmp = GetWindowLongA(window, GWL_EXSTYLE); + todo_wine ok(tmp & WS_EX_TOPMOST, "Expected WS_EX_TOPMOST.\n"); + ref = IDirectDraw4_Release(ddraw); ok(!ref, "Unexpected refcount %lu.\n", ref);
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c index 91da029cc42..68b96ff6e7c 100644 --- a/dlls/ddraw/tests/ddraw7.c +++ b/dlls/ddraw/tests/ddraw7.c @@ -2822,6 +2822,36 @@ static void test_window_style(void) expected_style = exstyle | WS_EX_TOPMOST; todo_wine ok(tmp == expected_style, "Expected window extended style %#lx, got %#lx.\n", expected_style, tmp);
+ /* Test that there is a ~1.5s timer that checks and restores WS_EX_TOPMOST if it's missing */ + ret = ShowWindow(window, SW_RESTORE); + ok(ret, "ShowWindow failed, error %#lx.\n", GetLastError()); + hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); + ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr); + flush_events(); + + /* Remove WS_VISIBLE and WS_EX_TOPMOST */ + tmp = GetWindowLongA(window, GWL_STYLE); + ok(tmp & WS_VISIBLE, "Expected WS_VISIBLE.\n"); + tmp = GetWindowLongA(window, GWL_EXSTYLE); + ok(tmp & WS_EX_TOPMOST, "Expected WS_EX_TOPMOST.\n"); + ret = ShowWindow(window, SW_HIDE); + ok(ret, "ShowWindow failed, error %#lx.\n", GetLastError()); + ret = SetWindowPos(window, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); + ok(ret, "SetWindowPos failed, error %#lx.\n", GetLastError()); + tmp = GetWindowLongA(window, GWL_STYLE); + ok(!(tmp & WS_VISIBLE), "Got unexpected WS_VISIBLE.\n"); + tmp = GetWindowLongA(window, GWL_EXSTYLE); + ok(!(tmp & WS_EX_TOPMOST), "Got unexpected WS_EX_TOPMOST.\n"); + + Sleep(2000); + flush_events(); + + /* WS_VISIBLE is not restored but WS_EX_TOPMOST is */ + tmp = GetWindowLongA(window, GWL_STYLE); + ok(!(tmp & WS_VISIBLE), "Got unexpected WS_VISIBLE.\n"); + tmp = GetWindowLongA(window, GWL_EXSTYLE); + todo_wine ok(tmp & WS_EX_TOPMOST, "Expected WS_EX_TOPMOST.\n"); + ref = IDirectDraw7_Release(ddraw); ok(!ref, "Unexpected refcount %lu.\n", ref);