[PATCH 1/2] user32/tests/win.c: Fix Win9x detection

Michael Karcher wine at mkarcher.dialup.fu-berlin.de
Sun Jan 24 12:08:49 CST 2010


The current code misdetects both Windows XP and Wine as Win9x and skips
some tests due to this. The SetParent tests were not passing on XP, so
this patch also removes the tests that fail on XP SP3.

The detection method is based on an idea by Paul Vriens, see
http://www.mail-archive.com/[email protected]/msg53142.html

gdi32/tests/bitmap.c still has the same issue
---
 dlls/user32/tests/win.c |   16 +++++++---------
 1 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c
index 6fb6ce0..2e64f32 100644
--- a/dlls/user32/tests/win.c
+++ b/dlls/user32/tests/win.c
@@ -62,6 +62,7 @@ static HHOOK hhook;
 static const char* szAWRClass = "Winsize";
 static HMENU hmenu;
 static DWORD our_pid;
+static BOOL is_win9x;
 
 #define COUNTOF(arr) (sizeof(arr)/sizeof(arr[0]))
 
@@ -640,7 +641,6 @@ static LRESULT WINAPI main_window_procA(HWND hwnd, UINT msg, WPARAM wparam, LPAR
 	}
 	case WM_WINDOWPOSCHANGING:
 	{
-	    BOOL is_win9x = GetWindowLongPtrW(hwnd, GWLP_WNDPROC) == 0;
 	    WINDOWPOS *winpos = (WINDOWPOS *)lparam;
 	    trace("main: WM_WINDOWPOSCHANGING %p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
 		   winpos->hwnd, winpos->hwndInsertAfter,
@@ -849,7 +849,6 @@ static void test_nonclient_area(HWND hwnd)
     DWORD style, exstyle;
     RECT rc_window, rc_client, rc;
     BOOL menu;
-    BOOL is_win9x = GetWindowLongPtrW(hwnd, GWLP_WNDPROC) == 0;
     LRESULT ret;
 
     style = GetWindowLongA(hwnd, GWL_STYLE);
@@ -1900,7 +1899,6 @@ static void test_SetWindowPos(HWND hwnd)
 {
     RECT orig_win_rc, rect;
     LONG_PTR old_proc;
-    BOOL is_win9x = GetWindowLongPtrW(hwnd, GWLP_WNDPROC) == 0;
 
     SetRect(&rect, 111, 222, 333, 444);
     ok(!GetWindowRect(0, &rect), "GetWindowRect succeeded\n");
@@ -1963,7 +1961,6 @@ static void test_SetMenu(HWND parent)
 {
     HWND child;
     HMENU hMenu, ret;
-    BOOL is_win9x = GetWindowLongPtrW(parent, GWLP_WNDPROC) == 0;
     BOOL retok;
     DWORD style;
 
@@ -3205,7 +3202,6 @@ static void test_SetParent(void)
     BOOL ret;
     HWND desktop = GetDesktopWindow();
     HMENU hMenu;
-    BOOL is_win9x = GetWindowLongPtrW(desktop, GWLP_WNDPROC) == 0;
     HWND parent, child1, child2, child3, child4, sibling;
 
     parent = CreateWindowExA(0, "static", NULL, WS_OVERLAPPEDWINDOW,
@@ -3254,13 +3250,11 @@ static void test_SetParent(void)
         ok(!SetParent(parent, child1), "SetParent should fail\n");
         ok(!SetParent(child2, child3), "SetParent should fail\n");
         ok(SetParent(child1, parent) != 0, "SetParent should not fail\n");
-        ok(SetParent(parent, child2) != 0, "SetParent should not fail\n");
         ok(SetParent(parent, child3) != 0, "SetParent should not fail\n");
         ok(!SetParent(child2, parent), "SetParent should fail\n");
-        ok(SetParent(parent, child4) != 0, "SetParent should not fail\n");
 
-        check_parents(parent, child4, child4, 0, 0, child4, parent);
-        check_parents(child1, parent, parent, parent, 0, child4, parent);
+        check_parents(parent, child3, child3, 0, 0, child2, parent);
+        check_parents(child1, parent, parent, parent, 0, child2, parent);
         check_parents(child2, desktop, parent, parent, parent, child2, parent);
         check_parents(child3, child2, child2, child2, 0, child2, parent);
         check_parents(child4, desktop, child2, child2, child2, child4, parent);
@@ -5901,6 +5895,10 @@ START_TEST(win)
     pGetWindowRgnBox = (void *)GetProcAddress( user32, "GetWindowRgnBox" );
     pGetGUIThreadInfo = (void *)GetProcAddress( user32, "GetGUIThreadInfo" );
 
+    SetLastError(0xdeafbeef);
+    GetWindowLongPtrW(GetDesktopWindow(), GWLP_WNDPROC);
+    is_win9x = (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED);
+
     if (!RegisterWindowClasses()) assert(0);
 
     hhook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, 0, GetCurrentThreadId());
-- 
1.6.5




More information about the wine-patches mailing list