[2/2] user32: Add a test to demonstrate the z-order problem for a top level window with a region. Take 2.

Dmitry Timoshkov dmitry at baikal.ru
Wed Jun 6 00:47:55 CDT 2012


This version of the test tries harder to avoid races that could cause
the test failures.
---
 dlls/user32/tests/win.c |   61 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)

diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c
index dd5069b..b93b796 100644
--- a/dlls/user32/tests/win.c
+++ b/dlls/user32/tests/win.c
@@ -7063,6 +7063,60 @@ todo_wine
     ok(ret, "UnregisterClass(my_window) failed\n");
 }
 
+static void test_toplevel_zorder(void)
+{
+    HWND hwnd_1, hwnd_2, hwnd;
+    HRGN hrgn;
+    int ret;
+
+    hwnd_1 = CreateWindowEx(0, "MainWindowClass", NULL,
+                            WS_OVERLAPPEDWINDOW | WS_VISIBLE,
+                            240, 240, 360, 360,
+                            GetDesktopWindow(), 0, GetModuleHandle(0), NULL);
+    ok(hwnd_1 != 0, "CreateWindowEx failed\n");
+
+    hwnd_2 = CreateWindowEx(0, "MainWindowClass", NULL,
+                            WS_OVERLAPPEDWINDOW | WS_VISIBLE,
+                            360, 360, 120, 120,
+                            GetDesktopWindow(), 0, GetModuleHandle(0), NULL);
+    ok(hwnd_2 != 0, "CreateWindowEx failed\n");
+
+    hwnd = GetWindow(hwnd_2, GW_HWNDNEXT);
+    ok(hwnd == hwnd_1, "expected next window %p, got %p\n", hwnd_1, hwnd);
+    hwnd = GetWindow(hwnd_1, GW_HWNDPREV);
+    ok(hwnd == hwnd_2, "expected next window %p, got %p\n", hwnd_2, hwnd);
+
+    hrgn = CreateRectRgn(0, 0, 360, 360);
+    SetWindowRgn(hwnd_1, hrgn, TRUE);
+
+    hwnd = GetWindow(hwnd_2, GW_HWNDNEXT);
+    ok(hwnd == hwnd_1, "expected next window %p, got %p\n", hwnd_1, hwnd);
+    hwnd = GetWindow(hwnd_1, GW_HWNDPREV);
+    ok(hwnd == hwnd_2, "expected next window %p, got %p\n", hwnd_2, hwnd);
+
+    /* try harder to make sure we've got an expose event */
+    SetClassLongPtr(hwnd_1, GCLP_HICON, (LONG_PTR)LoadIcon(0, IDI_APPLICATION));
+    SetClassLongPtr(hwnd_2, GCLP_HICON, (LONG_PTR)LoadIcon(0, IDI_APPLICATION));
+    SetWindowText(hwnd_1, "Hello World!");
+    SetWindowText(hwnd_2, "Hello World!");
+    do flush_events(TRUE); while (GetUpdateRect(hwnd_1, NULL, 0));
+    do flush_events(TRUE); while (GetUpdateRect(hwnd_2, NULL, 0));
+
+    ret = GetUpdateRect(hwnd_1, NULL, 0);
+    ok(!ret, "update rect of hwnd_1 is not empty\n");
+    ret = GetUpdateRect(hwnd_2, NULL, 0);
+    ok(!ret, "update rect of hwnd_2 is not empty\n");
+
+    hwnd = GetWindow(hwnd_2, GW_HWNDNEXT);
+    ok(hwnd == hwnd_1, "expected next window %p, got %p\n", hwnd_1, hwnd);
+    hwnd = GetWindow(hwnd_1, GW_HWNDPREV);
+    ok(hwnd == hwnd_2, "expected previous window %p, got %p\n", hwnd_2, hwnd);
+
+    DestroyWindow(hwnd_1);
+    DestroyWindow(hwnd_2);
+    DeleteObject(hrgn);
+}
+
 START_TEST(win)
 {
     HMODULE user32 = GetModuleHandleA( "user32.dll" );
@@ -7176,4 +7230,11 @@ START_TEST(win)
 
     DestroyWindow(hwndMain2);
     DestroyWindow(hwndMain);
+
+    /* This test is intentionally here, so that both Wine and X11 server
+       connections are up to speed, desktop window exists, services and
+       modules that could slow things down are loaded and started up,
+       and there is no top level windows.
+     */
+    test_toplevel_zorder();
 }
-- 
1.7.10.1




More information about the wine-patches mailing list