[PATCH] user32/tests: Add tests for LockWindowUpdate.

Lauri Kenttä lauri.kentta at gmail.com
Wed Dec 7 12:32:02 CST 2016


v2: Win8 and Win10 give different results (sometimes even
different different results), so mark some cases as broken.
Also simplify the patch overall.

Signed-off-by: Lauri Kenttä <lauri.kentta at gmail.com>
---
 dlls/user32/tests/win.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 80 insertions(+)

diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c
index 428a88f..af3b327 100644
--- a/dlls/user32/tests/win.c
+++ b/dlls/user32/tests/win.c
@@ -9325,6 +9325,85 @@ todo_wine
     ok(ret, "got %d\n", ret);
 }
 
+static void test_LockWindowUpdate(HWND hwnd_w)
+{
+    typedef struct
+    {
+        HWND hwnd_lock, hwnd_draw;
+        BOOL allow_drawing;
+        COLORREF expect[6];
+        BOOL todo[6];
+        COLORREF broken[6];
+    } TEST;
+
+    HWND hwnd_d = GetDesktopWindow();
+    int i;
+
+    COLORREF c0 = CLR_INVALID, c1 = 0x111100, c2 = 0x222200, badly_broken = 0xdeadbeef;
+    TEST tests[] = {
+        {hwnd_w, hwnd_w, 0, {c1, c0, c0, c0, c1, c1}, {0, 1, 1, 1, 1, 1}},
+        {hwnd_w, hwnd_w, 1, {c1, c1, c1, c2, c2, c2}, {0, 0, 0, 0, 0, 0}},
+        {hwnd_w, hwnd_d, 0, {c1, c0, c1, c2, c0, c2}, {0, 1, 0, 0, 1, 0}, {0, c1, 0, 0, c2}},
+        {hwnd_w, hwnd_d, 1, {c1, c0, c1, c2, c0, c2}, {0, 1, 0, 0, 1, 0}, {0, c1, 0, 0, c2}},
+        {hwnd_d, hwnd_w, 0, {c1, c0, c0, c0, c1, c1}, {0, 1, 1, 1, 1, 1}},
+        {hwnd_d, hwnd_w, 1, {c1, c1, c1, c2, c2, c2}, {0, 0, 0, 0, 0, 0}},
+        {hwnd_d, hwnd_d, 0, {c1, c0, c0, c0, c0, c1}, {0, 1, 1, 1, 1, 1}, {0, 0, 0, 0, badly_broken, badly_broken}},
+        {hwnd_d, hwnd_d, 1, {c1, c0, c1, c2, c0, c2}, {0, 1, 0, 0, 1, 0}, {0, c1, 0, 0, badly_broken, badly_broken}}
+    };
+
+    ShowWindow(hwnd_w, SW_SHOW);
+
+    for (i = 0; i < sizeof(tests) / sizeof(tests[0]); ++i)
+    {
+        HDC hdc;
+        POINT p = {10, 10};
+        BOOL ret;
+        DWORD dc_flags = tests[i].allow_drawing ? DCX_LOCKWINDOWUPDATE : 0;
+
+        if (tests[i].hwnd_draw == hwnd_d)
+            ClientToScreen(hwnd_w, &p);
+        else
+            dc_flags |= DCX_USESTYLE;
+
+        trace("hwnd_lock = %s, hwnd_draw = %s, allow_drawing = %d\n",
+            tests[i].hwnd_lock == hwnd_d ? "desktop" : "hwnd_w",
+            tests[i].hwnd_draw == hwnd_d ? "desktop" : "hwnd_w",
+            tests[i].allow_drawing);
+
+        UpdateWindow(hwnd_w);
+        flush_events(TRUE);
+
+        hdc = GetDCEx(tests[i].hwnd_draw, 0, dc_flags);
+
+        #define TEST_PIXEL(j) \
+            do { \
+                COLORREF c = GetPixel(hdc, p.x, p.y); \
+                COLORREF e = tests[i].expect[j], b = tests[i].broken[j]; \
+                todo_wine_if(tests[i].todo[j]) \
+                ok(c == e || (b && broken(c == b || b == badly_broken)), \
+                    "test %d: GetPixel: got %08x, expected %08x\n", j, c, e); \
+            } while (0)
+
+        SetPixel(hdc, p.x, p.y, c1);
+        TEST_PIXEL(0);
+        ret = LockWindowUpdate(tests[i].hwnd_lock);
+        ok(ret, "LockWindowUpdate failed\n");
+        TEST_PIXEL(1);
+        ReleaseDC(tests[i].hwnd_draw, hdc);
+        hdc = GetDCEx(tests[i].hwnd_draw, 0, dc_flags);
+        TEST_PIXEL(2);
+        SetPixel(hdc, p.x, p.y, c2);
+        TEST_PIXEL(3);
+        LockWindowUpdate(0);
+        TEST_PIXEL(4);
+        ReleaseDC(tests[i].hwnd_draw, hdc);
+        hdc = GetDCEx(tests[i].hwnd_draw, 0, dc_flags);
+        TEST_PIXEL(5);
+        ReleaseDC(tests[i].hwnd_draw, hdc);
+        #undef TEST_PIXEL
+    }
+}
+
 START_TEST(win)
 {
     char **argv;
@@ -9470,6 +9549,7 @@ START_TEST(win)
     test_activateapp(hwndMain);
     test_winproc_handles(argv[0]);
     test_deferwindowpos();
+    test_LockWindowUpdate(hwndMain);
 
     /* add the tests above this line */
     if (hhook) UnhookWindowsHookEx(hhook);
-- 
2.10.2




More information about the wine-patches mailing list