user32: Add a test for reparenting a WS_POPUP window to a WS_CHILD parent.

Dmitry Timoshkov dmitry at codeweavers.com
Fri Feb 4 03:12:06 CST 2011


This test is supposed to show the root of the problem with the test
application attached to the bug 13951. It appears that the check performed
by server/window.c,is_top_level_window() is not correct (which leads to
a SetWindowPos() failure to set foreground window), and probably should be
replaced by simple (win->style & (WS_CHILD | WS_POPUP)) != WS_CHILD.

Another problem discovered by the test app is that x11drv drops the managed
flag for the reparented window, but that's a separate issue.
---
 dlls/user32/tests/win.c |   45 +++++++++++++++++++++++++++++++++++++++------
 1 files changed, 39 insertions(+), 6 deletions(-)

diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c
index ca55c80..53e005c 100644
--- a/dlls/user32/tests/win.c
+++ b/dlls/user32/tests/win.c
@@ -3330,10 +3330,9 @@ static void test_nccalcscroll(HWND parent)
 
 static void test_SetParent(void)
 {
-    BOOL ret;
     HWND desktop = GetDesktopWindow();
     HMENU hMenu;
-    HWND parent, child1, child2, child3, child4, sibling;
+    HWND ret, parent, child1, child2, child3, child4, sibling, popup;
 
     parent = CreateWindowExA(0, "static", NULL, WS_OVERLAPPEDWINDOW,
 			     100, 100, 200, 200, 0, 0, 0, NULL);
@@ -3378,8 +3377,6 @@ static void test_SetParent(void)
 
     if (!is_win9x) /* Win9x doesn't survive this test */
     {
-        HWND ret;
-
         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");
@@ -3425,8 +3422,7 @@ static void test_SetParent(void)
     ok(SetParent(sibling, parent) != 0, "SetParent should not fail\n");
     ok(GetMenu(sibling) == hMenu, "SetParent should not remove menu\n");
 
-    ret = DestroyWindow(parent);
-    ok( ret, "DestroyWindow() error %d\n", GetLastError());
+    ok(DestroyWindow(parent), "DestroyWindow() error %d\n", GetLastError());
 
     ok(!IsWindow(parent), "parent still exists\n");
     ok(!IsWindow(sibling), "sibling still exists\n");
@@ -3434,6 +3430,43 @@ static void test_SetParent(void)
     ok(!IsWindow(child2), "child2 still exists\n");
     ok(!IsWindow(child3), "child3 still exists\n");
     ok(!IsWindow(child4), "child4 still exists\n");
+
+    parent = CreateWindowExA(0, "static", NULL, WS_OVERLAPPEDWINDOW,
+			     100, 100, 200, 200, 0, 0, 0, NULL);
+    assert(parent != 0);
+    child1 = CreateWindowExA(0, "static", NULL, WS_CHILD,
+			     0, 0, 50, 50, parent, 0, 0, NULL);
+    assert(child1 != 0);
+    popup = CreateWindowExA(0, "static", NULL, WS_POPUP,
+			     0, 0, 50, 50, 0, 0, 0, NULL);
+    assert(popup != 0);
+
+    trace("parent %p, child %p, popup %p\n", parent, child1, popup);
+
+    check_parents(parent, desktop, 0, 0, 0, parent, parent);
+    check_parents(child1, parent, parent, parent, 0, parent, parent);
+    check_parents(popup, desktop, 0, 0, 0, popup, popup);
+
+    ret = SetFocus(popup);
+todo_wine
+    ok(!ret || broken(ret != 0) /* NT4 */, "SetFocus() should fail\n");
+    SetLastError(0xdeadbeef);
+    ok(SetForegroundWindow(popup), "SetForegroundWindow() error %d\n", GetLastError());
+
+    ret = SetParent(popup, child1);
+    ok(ret == desktop, "expected %p, got %p\n", desktop, ret);
+    check_parents(popup, child1, child1, 0, 0, parent, popup);
+
+    SetLastError(0xdeadbeef);
+todo_wine
+    ok(SetForegroundWindow(popup), "SetForegroundWindow() error %d\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ok(DestroyWindow(parent), "DestroyWindow() error %d\n", GetLastError());
+
+    ok(!IsWindow(parent), "parent still exists\n");
+    ok(!IsWindow(child1), "child1 still exists\n");
+    ok(!IsWindow(popup), "popup still exists\n");
 }
 
 static LRESULT WINAPI StyleCheckProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
-- 
1.7.3.5




More information about the wine-patches mailing list