user32: Add ShowWindow test, make it pass under Wine
Dmitry Timoshkov
dmitry at codeweavers.com
Mon Dec 4 01:06:54 CST 2006
Hello,
an app I'm working on calls EnableWindow(FALSE) for one of its top level
windows and then does DefWindowProc(WM_SYSCOMMAND, SC_MINIMIZE) on it.
I wrote a test to see who is responsible for testing WS_DISABLED window style:
DefWindowProc or ShowWindow, according to the tests it's DefWindowProc.
The test also shows (in the traces) that while handling ShowWindow(SW_MINIMIZE)
Windows moves the window to (-32000,-32000) and resizes it to 160 x 31.
Wine resizes the window to SM_CXICON x SM_CYICON, and doesn't move it
outside of the visible desktop.
Changelog:
user32: Add ShowWindow test, make it pass under Wine.
---
dlls/user32/nonclient.c | 4 +-
dlls/user32/tests/win.c | 123 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 126 insertions(+), 1 deletions(-)
diff --git a/dlls/user32/nonclient.c b/dlls/user32/nonclient.c
index 3045397..cc3e66c 100644
--- a/dlls/user32/nonclient.c
+++ b/dlls/user32/nonclient.c
@@ -1541,7 +1541,9 @@ LRESULT NC_HandleNCLButtonDblClk( HWND h
*/
LRESULT NC_HandleSysCommand( HWND hwnd, WPARAM wParam, LPARAM lParam )
{
- TRACE("Handling WM_SYSCOMMAND %x %lx\n", wParam, lParam );
+ TRACE("hwnd %p WM_SYSCOMMAND %x %lx\n", hwnd, wParam, lParam );
+
+ if (!IsWindowEnabled( hwnd )) return 0;
if (HOOK_CallHooks( WH_CBT, HCBT_SYSCOMMAND, wParam, lParam, TRUE ))
return 0;
diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c
index 65795da..094a947 100644
--- a/dlls/user32/tests/win.c
+++ b/dlls/user32/tests/win.c
@@ -3943,6 +3943,128 @@ static void test_SetWindowLong(void)
}
}
+static void test_ShowWindow(void)
+{
+ HWND hwnd;
+ DWORD style;
+ RECT rcMain, rc;
+ LPARAM ret;
+
+ SetRect(&rcMain, 120, 120, 210, 210);
+
+ hwnd = CreateWindowEx(0, "MainWindowClass", NULL,
+ WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX |
+ WS_MAXIMIZEBOX | WS_POPUP,
+ rcMain.left, rcMain.top,
+ rcMain.right - rcMain.left, rcMain.bottom - rcMain.top,
+ 0, 0, 0, NULL);
+ assert(hwnd);
+
+ style = GetWindowLong(hwnd, GWL_STYLE);
+ ok(!(style & WS_DISABLED), "window should not be disabled\n");
+ ok(!(style & WS_VISIBLE), "window should not be visible\n");
+ ok(!(style & WS_MINIMIZE), "window should not be minimized\n");
+ ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
+ GetWindowRect(hwnd, &rc);
+ ok(EqualRect(&rcMain, &rc), "rects should match\n");
+
+ ret = ShowWindow(hwnd, SW_SHOW);
+ ok(!ret, "not expected ret: %lu\n", ret);
+ style = GetWindowLong(hwnd, GWL_STYLE);
+ ok(!(style & WS_DISABLED), "window should not be disabled\n");
+ ok(style & WS_VISIBLE, "window should be visible\n");
+ ok(!(style & WS_MINIMIZE), "window should not be minimized\n");
+ ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
+ GetWindowRect(hwnd, &rc);
+ ok(EqualRect(&rcMain, &rc), "rects should match\n");
+
+ ret = ShowWindow(hwnd, SW_MINIMIZE);
+ ok(ret, "not expected ret: %lu\n", ret);
+ style = GetWindowLong(hwnd, GWL_STYLE);
+ ok(!(style & WS_DISABLED), "window should not be disabled\n");
+ ok(style & WS_VISIBLE, "window should be visible\n");
+ ok(style & WS_MINIMIZE, "window should be minimized\n");
+ ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
+ GetWindowRect(hwnd, &rc);
+ ok(!EqualRect(&rcMain, &rc), "rects shouldn't match\n");
+
+ ShowWindow(hwnd, SW_RESTORE);
+ ok(ret, "not expected ret: %lu\n", ret);
+ style = GetWindowLong(hwnd, GWL_STYLE);
+ ok(!(style & WS_DISABLED), "window should not be disabled\n");
+ ok(style & WS_VISIBLE, "window should be visible\n");
+ ok(!(style & WS_MINIMIZE), "window should not be minimized\n");
+ ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
+ GetWindowRect(hwnd, &rc);
+ ok(EqualRect(&rcMain, &rc), "rects should match\n");
+
+ ret = EnableWindow(hwnd, FALSE);
+ ok(!ret, "not expected ret: %lu\n", ret);
+ style = GetWindowLong(hwnd, GWL_STYLE);
+ ok(style & WS_DISABLED, "window should be disabled\n");
+
+ ret = DefWindowProc(hwnd, WM_SYSCOMMAND, SC_MINIMIZE, 0);
+ ok(!ret, "not expected ret: %lu\n", ret);
+ style = GetWindowLong(hwnd, GWL_STYLE);
+ ok(style & WS_DISABLED, "window should be disabled\n");
+ ok(style & WS_VISIBLE, "window should be visible\n");
+ ok(!(style & WS_MINIMIZE), "window should not be minimized\n");
+ ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
+ GetWindowRect(hwnd, &rc);
+ ok(EqualRect(&rcMain, &rc), "rects should match\n");
+
+ ret = DefWindowProc(hwnd, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
+ ok(!ret, "not expected ret: %lu\n", ret);
+ style = GetWindowLong(hwnd, GWL_STYLE);
+ ok(style & WS_DISABLED, "window should be disabled\n");
+ ok(style & WS_VISIBLE, "window should be visible\n");
+ ok(!(style & WS_MINIMIZE), "window should not be minimized\n");
+ ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
+ GetWindowRect(hwnd, &rc);
+ ok(EqualRect(&rcMain, &rc), "rects should match\n");
+
+ ret = ShowWindow(hwnd, SW_MINIMIZE);
+ ok(ret, "not expected ret: %lu\n", ret);
+ style = GetWindowLong(hwnd, GWL_STYLE);
+ ok(style & WS_DISABLED, "window should be disabled\n");
+ ok(style & WS_VISIBLE, "window should be visible\n");
+ ok(style & WS_MINIMIZE, "window should be minimized\n");
+ ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
+ GetWindowRect(hwnd, &rc);
+ ok(!EqualRect(&rcMain, &rc), "rects shouldn't match\n");
+
+ ret = DefWindowProc(hwnd, WM_SYSCOMMAND, SC_RESTORE, 0);
+ ok(!ret, "not expected ret: %lu\n", ret);
+ style = GetWindowLong(hwnd, GWL_STYLE);
+ ok(style & WS_DISABLED, "window should be disabled\n");
+ ok(style & WS_VISIBLE, "window should be visible\n");
+ ok(style & WS_MINIMIZE, "window should be minimized\n");
+ ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
+ GetWindowRect(hwnd, &rc);
+ ok(!EqualRect(&rcMain, &rc), "rects shouldn't match\n");
+
+ ret = ShowWindow(hwnd, SW_RESTORE);
+ ok(ret, "not expected ret: %lu\n", ret);
+ style = GetWindowLong(hwnd, GWL_STYLE);
+ ok(style & WS_DISABLED, "window should be disabled\n");
+ ok(style & WS_VISIBLE, "window should be visible\n");
+ ok(!(style & WS_MINIMIZE), "window should not be minimized\n");
+ ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
+ GetWindowRect(hwnd, &rc);
+ ok(EqualRect(&rcMain, &rc), "rects should match\n");
+
+ ret = DefWindowProc(hwnd, WM_SYSCOMMAND, SC_CLOSE, 0);
+ ok(!ret, "not expected ret: %lu\n", ret);
+ ok(IsWindow(hwnd), "window should exist\n");
+
+ ret = EnableWindow(hwnd, TRUE);
+ ok(ret, "not expected ret: %lu\n", ret);
+
+ ret = DefWindowProc(hwnd, WM_SYSCOMMAND, SC_CLOSE, 0);
+ ok(!ret, "not expected ret: %lu\n", ret);
+ ok(!IsWindow(hwnd), "window should not exist\n");
+}
+
START_TEST(win)
{
pGetAncestor = (void *)GetProcAddress( GetModuleHandleA("user32.dll"), "GetAncestor" );
@@ -4019,6 +4141,7 @@ START_TEST(win)
test_redrawnow();
test_csparentdc();
test_SetWindowLong();
+ test_ShowWindow();
/* add the tests above this line */
UnhookWindowsHookEx(hhook);
--
1.4.2
More information about the wine-patches
mailing list