[PATCH] user32/tests: Add tests for LockWindowUpdate.
Lauri Kenttä
lauri.kentta at gmail.com
Tue Dec 6 12:24:17 CST 2016
Signed-off-by: Lauri Kenttä <lauri.kentta at gmail.com>
---
dlls/user32/tests/win.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 90 insertions(+)
diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c
index 428a88f..ff34e36 100644
--- a/dlls/user32/tests/win.c
+++ b/dlls/user32/tests/win.c
@@ -9325,6 +9325,95 @@ 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;
+ BOOL expect_invalid_after_lock;
+ BOOL expect_invalid_during_lock;
+ BOOL expect_drawing_ok;
+ BOOL expect_invalid_after_unlock;
+ BOOL todo[5];
+ } TEST;
+
+ HWND hwnd_d = GetDesktopWindow();
+ int i;
+
+ TEST tests[] = {
+ {hwnd_w, hwnd_w, 0, 1, 1, 0, 0, {1, 1, 1, 1, 1}},
+ {hwnd_w, hwnd_w, 1, 0, 0, 1, 0, {0, 0, 0, 0, 0}},
+ {hwnd_w, hwnd_d, 0, 1, 0, 1, 1, {1, 0, 0, 1, 0}},
+ {hwnd_w, hwnd_d, 1, 1, 0, 1, 1, {1, 0, 0, 1, 0}},
+ {hwnd_d, hwnd_w, 0, 1, 1, 0, 0, {1, 1, 1, 1, 1}},
+ {hwnd_d, hwnd_w, 1, 0, 0, 1, 0, {0, 0, 0, 0, 0}},
+ {hwnd_d, hwnd_d, 0, 1, 1, 0, 1, {1, 1, 1, 1, 1}},
+ {hwnd_d, hwnd_d, 1, 1, 0, 1, 1, {1, 0, 0, 1, 0}}
+ };
+
+ ShowWindow(hwnd_w, SW_SHOW);
+ UpdateWindow(hwnd_w);
+ flush_events(TRUE);
+
+ for (i = 0; i < sizeof(tests) / sizeof(tests[0]); ++i)
+ {
+ HDC hdc;
+ COLORREF c;
+ COLORREF c0 = 0xdedbef, c1 = 0x123456;
+ COLORREF c2 = tests[i].expect_drawing_ok ? c1 : c0;
+ 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);
+
+ hdc = GetDCEx(tests[i].hwnd_draw, 0, dc_flags);
+
+ #define TEST_PIXEL(todo, c_exp) \
+ do { \
+ c = GetPixel(hdc, p.x, p.y); \
+ todo_wine_if(todo) ok(c == (c_exp), "GetPixel: got %08x, expected %08x\n", c, (c_exp)); \
+ } while (0)
+
+ SetPixel(hdc, p.x, p.y, c0);
+ TEST_PIXEL(0, c0);
+
+ ret = LockWindowUpdate(tests[i].hwnd_lock);
+ ok(ret, "LockWindowUpdate failed\n");
+
+ TEST_PIXEL(tests[i].todo[0], tests[i].expect_invalid_after_lock ? CLR_INVALID : c0);
+
+ ReleaseDC(tests[i].hwnd_draw, hdc);
+ hdc = GetDCEx(tests[i].hwnd_draw, 0, dc_flags);
+
+ TEST_PIXEL(tests[i].todo[1], tests[i].expect_invalid_during_lock ? CLR_INVALID : c0);
+
+ SetPixel(hdc, p.x, p.y, c1);
+ TEST_PIXEL(tests[i].todo[2], tests[i].expect_invalid_during_lock ? CLR_INVALID : c2);
+
+ LockWindowUpdate(0);
+
+ TEST_PIXEL(tests[i].todo[3], tests[i].expect_invalid_after_unlock ? CLR_INVALID : c2);
+
+ ReleaseDC(tests[i].hwnd_draw, hdc);
+ hdc = GetDCEx(tests[i].hwnd_draw, 0, dc_flags);
+
+ TEST_PIXEL(tests[i].todo[4], c2);
+
+ ReleaseDC(tests[i].hwnd_draw, hdc);
+ #undef TEST_PIXEL
+ }
+}
+
START_TEST(win)
{
char **argv;
@@ -9470,6 +9559,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