[TEST v2] user32/tests: Add tests for LockWindowUpdate.

Lauri Kenttä lauri.kentta at gmail.com
Wed Dec 7 11:45:54 CST 2016


This is for the test bot. Sorry for the noise again.
The motivation behind this revision is that in the previous one,
the newest VMs didn't make sense and managed to return some pixels
that shouldn't exist anymore. This time I'm testing if some message
processing makes them any happier. If not, I may have to abandon
those parts of the tests.

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

diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c
index 428a88f..fc2a18c 100644
--- a/dlls/user32/tests/win.c
+++ b/dlls/user32/tests/win.c
@@ -9325,6 +9325,84 @@ 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];
+        COLORREF broken[6];
+        BOOL todo[6];
+    } TEST;
+
+    HWND hwnd_d = GetDesktopWindow();
+    int i;
+
+    COLORREF c0 = CLR_INVALID, c1 = 0x111100, c2 = 0x222200;
+    TEST tests[] = {
+        {hwnd_w, hwnd_w, 0, {c1, c0, c0, c0, c1, c1}, {0}, {0, 1, 1, 1, 1, 1}},
+        {hwnd_w, hwnd_w, 1, {c1, c1, c1, c2, c2, c2}, {0}, {0, 0, 0, 0, 0, 0}},
+        {hwnd_w, hwnd_d, 0, {c1, c0, c1, c2, c0, c2}, {0}, {0, 1, 0, 0, 1, 0}},
+        {hwnd_w, hwnd_d, 1, {c1, c0, c1, c2, c0, c2}, {0}, {0, 1, 0, 0, 1, 0}},
+        {hwnd_d, hwnd_w, 0, {c1, c0, c0, c0, c1, c1}, {0}, {0, 1, 1, 1, 1, 1}},
+        {hwnd_d, hwnd_w, 1, {c1, c1, c1, c2, c2, c2}, {0}, {0, 0, 0, 0, 0, 0}},
+        {hwnd_d, hwnd_d, 0, {c1, c0, c0, c0, c0, c1}, {0}, {0, 1, 1, 1, 1, 1}},
+        {hwnd_d, hwnd_d, 1, {c1, c0, c1, c2, c0, c2}, {0}, {0, 1, 0, 0, 1, 0}}
+    };
+
+    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)), "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 +9548,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